Commit 3b128565 authored by Julien Muchembled's avatar Julien Muchembled

More reliable cleanup of temporary downloaded file

parent 6b76cb03
...@@ -165,17 +165,18 @@ class Recipe(object): ...@@ -165,17 +165,18 @@ class Recipe(object):
""" """
url, callable = script.rsplit(':', 1) url, callable = script.rsplit(':', 1)
filename, is_temp = self.download_file(url) filename, is_temp = self.download_file(url)
if not is_temp:
filename = os.path.abspath(filename)
module = imp.load_source('script', filename)
script = getattr(module, callable.strip())
try: try:
script(self.options, self.buildout, self.augmented_environment()) if not is_temp:
except TypeError: filename = os.path.abspath(filename)
# BBB: Support hook scripts that do not take the environment as module = imp.load_source('script', filename)
# the third parameter script = getattr(module, callable.strip())
script(self.options, self.buildout) try:
script(self.options, self.buildout,
self.augmented_environment())
except TypeError:
# BBB: Support hook scripts that do not take the environment as
# the third parameter
script(self.options, self.buildout)
finally: finally:
if is_temp: if is_temp:
os.remove(filename) os.remove(filename)
...@@ -282,9 +283,12 @@ class Recipe(object): ...@@ -282,9 +283,12 @@ class Recipe(object):
log.info('Applying patches') log.info('Applying patches')
for patch in patches: for patch in patches:
patch_filename, is_temp = self.download_file(patch) patch_filename, is_temp = self.download_file(patch)
self.run('%s %s < %s' % (patch_cmd, patch_options, patch_filename)) try:
if is_temp: self.run('%s %s < %s' % (patch_cmd, patch_options,
os.remove(patch_filename) patch_filename))
finally:
if is_temp:
os.remove(patch_filename)
if 'pre-configure-hook' in self.options and len(self.options['pre-configure-hook'].strip()) > 0: if 'pre-configure-hook' in self.options and len(self.options['pre-configure-hook'].strip()) > 0:
log.info('Executing pre-configure-hook') log.info('Executing pre-configure-hook')
......
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