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

build: code cleanup

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