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):
"""
url, callable = script.rsplit(':', 1)
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:
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)
if not is_temp:
filename = os.path.abspath(filename)
module = imp.load_source('script', filename)
script = getattr(module, callable.strip())
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:
if is_temp:
os.remove(filename)
......@@ -282,9 +283,12 @@ class Recipe(object):
log.info('Applying patches')
for patch in patches:
patch_filename, is_temp = self.download_file(patch)
self.run('%s %s < %s' % (patch_cmd, patch_options, patch_filename))
if is_temp:
os.remove(patch_filename)
try:
self.run('%s %s < %s' % (patch_cmd, patch_options,
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:
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