Skip to content

Commit

Permalink
Merge pull request #87 from dhellmann/retry-81
Browse files Browse the repository at this point in the history
Improve error message for IOErrors
  • Loading branch information
dhellmann committed Dec 21, 2023
2 parents 513621b + 389610e commit 0b60b4d
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions virtualenvwrapper/hook_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,16 @@ def main():
log.debug('Saving sourcable %s hooks to %s',
hook, options.script_filename)
options.sourcing = True
output = open(options.script_filename, "w")
try:
output.write('# %s\n' % hook)
# output.write('echo %s\n' % hook)
# output.write('set -x\n')
run_hooks(hook + '_source', options, args, output)
finally:
output.close()
with open(options.script_filename, "w") as output:
output.write('# %s\n' % hook)
# output.write('echo %s\n' % hook)
# output.write('set -x\n')
run_hooks(hook + '_source', options, args, output)
except (IOError, OSError) as e:
log.error('Error while writing to %s: \n %s',
options.script_filename, e)
sys.exit(1)

return 0

Expand Down

0 comments on commit 0b60b4d

Please sign in to comment.