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():
return target
TRUE_LIST = ('y', 'on', 'yes', 'true', '1')
class Script:
"""Free script building system"""
def _checkPromise(self, promise_key, location):
......@@ -247,7 +249,11 @@ class Script:
self.options[k] = self.options.get(k, '').strip()
self.options['script'] = self.options.get('script', self.script) % \
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):
# prepare cool dictionary
wanted_env = {}
......@@ -293,8 +299,11 @@ class Script:
finally:
for d in self.cleanup_dir_list:
if os.path.exists(d):
if not self.keep_on_error:
self.logger.debug('Cleanup directory %r' % d)
shutil.rmtree(d)
else:
self.logger.info('Left directory %r as requested' % d)
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