We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 513621b + 389610e commit 0b60b4dCopy full SHA for 0b60b4d
virtualenvwrapper/hook_loader.py
@@ -146,14 +146,16 @@ def main():
146
log.debug('Saving sourcable %s hooks to %s',
147
hook, options.script_filename)
148
options.sourcing = True
149
- output = open(options.script_filename, "w")
150
try:
151
- output.write('# %s\n' % hook)
152
- # output.write('echo %s\n' % hook)
153
- # output.write('set -x\n')
154
- run_hooks(hook + '_source', options, args, output)
155
- finally:
156
- 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',
157
+ options.script_filename, e)
158
+ sys.exit(1)
159
160
return 0
161
0 commit comments