Commit 849ead09 authored by Julien Muchembled's avatar Julien Muchembled

build: code cleanup

parent 49e5b835
......@@ -263,7 +263,6 @@ class Script:
cleanup_dir_list = cleanup_file_list = property(
lambda self: self.cleanup_list)
script = 'raise NotImplementedError'
def __init__(self, buildout, name, options):
self.cleanup_list = []
......@@ -271,16 +270,16 @@ class Script:
self.buildout = buildout
self.name = name
self.logger = logging.getLogger('SlapOS build of %s' % self.name)
self.options.setdefault('location',
os.path.join(buildout['buildout']['parts-directory'], self.name))
# cleanup some variables
for k in ['location', 'url', 'md5sum', 'path']:
try:
self.options['location'] = self.options['location'].strip()
except KeyError:
self.options['location'] = os.path.join(
buildout['buildout']['parts-directory'], self.name)
for k in 'url', 'md5sum', 'path':
self.options[k] = self.options.get(k, '').strip()
if self.options.get('format', 'yes') in ['y', 'yes', '1', 'on']:
self.options['script'] = self.options.get('script', self.script) % \
self.options
self.script = self.options['script']
if self.options.get('format', 'yes') in TRUE_LIST:
self.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
......@@ -324,7 +323,7 @@ class Script:
rmtree(location)
env = self.getEnvironment() # env is used in script exec'ed below
try:
exec self.options['script']
exec self.script
self._checkPromise('slapos_promise', location)
except:
self.cleanup_list.append(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