Skip to content

Commit

Permalink
added cleanup blocking with -N to options.
Browse files Browse the repository at this point in the history
  • Loading branch information
Titus Brown committed Sep 4, 2009
1 parent a1ea905 commit ed2415f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 17 deletions.
2 changes: 1 addition & 1 deletion client/build-pony-build
Expand Up @@ -35,7 +35,7 @@ commands = [ GitClone(repo_url, name='checkout', cache_dir='~/.pony-build/pony-b
name='run tests', run_cwd='pony-build')
]

context = TempDirectoryContext()
context = TempDirectoryContext(options.cleanup_temp)
results = do(name, commands, context=context)
client_info, reslist = results

Expand Down
27 changes: 11 additions & 16 deletions client/pony_build_client.py
Expand Up @@ -43,9 +43,9 @@ def update_client_info(self, info):
info['duration'] = self.end - self.start

class TempDirectoryContext(Context):
def __init__(self, always_cleanup=True):
def __init__(self, cleanup=True):
Context.__init__(self)
self.always_cleanup = always_cleanup
self.cleanup = cleanup

def initialize(self):
Context.initialize(self)
Expand All @@ -56,20 +56,12 @@ def initialize(self):
os.chdir(self.tempdir)

def finish(self):
Context.finish(self)

do_cleanup = False
if self.always_cleanup:
do_cleanup = self.always_cleanup
else:
success = [ c.success() for c in self.history ]
if all(success):
print 'all commands succeeded; setting cleanup=True'
do_cleanup = True

if do_cleanup:
print 'removing', self.tempdir
shutil.rmtree(self.tempdir)
try:
Context.finish(self)
finally:
if self.cleanup:
print 'removing', self.tempdir
shutil.rmtree(self.tempdir)

os.chdir(self.cwd)

Expand Down Expand Up @@ -426,6 +418,9 @@ def parse_cmdline(argv=[]):
cmdline.add_option('-n', '--no-report', dest='report',
action='store_false', default=True,
help="do not report build results to server")
cmdline.add_option('-N', '--no-clean-temp', dest='cleanup_temp',
action='store_false', default=True,
help='do not clean up the temp directory')

if not argv:
(options, args) = cmdline.parse_args()
Expand Down

0 comments on commit ed2415f

Please sign in to comment.