Commit 8934eb92 authored by Łukasz Nowak's avatar Łukasz Nowak

Allow to keep directories in case of error.

Default is to remove.
parent 74d0b2bd
...@@ -102,6 +102,8 @@ def guessPlatform(): ...@@ -102,6 +102,8 @@ def guessPlatform():
return target return target
TRUE_LIST = ('y', 'on', 'yes', 'true', '1')
class Script: class Script:
"""Free script building system""" """Free script building system"""
def _checkPromise(self, promise_key, location): def _checkPromise(self, promise_key, location):
...@@ -247,7 +249,11 @@ class Script: ...@@ -247,7 +249,11 @@ class Script:
self.options[k] = self.options.get(k, '').strip() self.options[k] = self.options.get(k, '').strip()
self.options['script'] = self.options.get('script', self.script) % \ self.options['script'] = self.options.get('script', self.script) % \
self.options self.options
if self.options.get('keep-on-error', '').strip().lower() in TRUE_LIST:
self.logger.debug('Keeping directories in case of errors')
self.keep_on_error = True
else:
self.keep_on_error = False
def getEnvironment(self): def getEnvironment(self):
# prepare cool dictionary # prepare cool dictionary
wanted_env = {} wanted_env = {}
...@@ -293,8 +299,11 @@ class Script: ...@@ -293,8 +299,11 @@ class Script:
finally: finally:
for d in self.cleanup_dir_list: for d in self.cleanup_dir_list:
if os.path.exists(d): if os.path.exists(d):
self.logger.debug('Cleanup directory %r' % d) if not self.keep_on_error:
shutil.rmtree(d) self.logger.debug('Cleanup directory %r' % d)
shutil.rmtree(d)
else:
self.logger.info('Left directory %r as requested' % d)
return [self.options['location']] return [self.options['location']]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment