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

More reliable cleanup of temporary downloaded file

parent 6b76cb03
......@@ -165,13 +165,14 @@ class Recipe(object):
"""
url, callable = script.rsplit(':', 1)
filename, is_temp = self.download_file(url)
try:
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())
script(self.options, self.buildout,
self.augmented_environment())
except TypeError:
# BBB: Support hook scripts that do not take the environment as
# the third parameter
......@@ -282,7 +283,10 @@ 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))
try:
self.run('%s %s < %s' % (patch_cmd, patch_options,
patch_filename))
finally:
if is_temp:
os.remove(patch_filename)
......
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