Catch the exception in Python2 or Python 3
This commit is contained in:
parent
93ca2b71ee
commit
170d1bb369
1 changed files with 7 additions and 2 deletions
|
@ -315,14 +315,19 @@ except Exception:
|
|||
traceback.print_exception(err,detail,tb,file=sys.stderr)
|
||||
sys.exit(-1)
|
||||
|
||||
if PY3:
|
||||
osException=OSError
|
||||
else:
|
||||
osException=IOError
|
||||
|
||||
try:
|
||||
open(path.abspath(sys.argv[0])+"."+destShell,"w").write(result)
|
||||
except OSError:
|
||||
except osException:
|
||||
# We are not allowed to write here. Try tmp
|
||||
try:
|
||||
open(path.join("/tmp",
|
||||
path.basename(sys.argv[0])+"."+destShell),"w").write(result)
|
||||
except OSError:
|
||||
except osException:
|
||||
# Nobody wants this
|
||||
pass
|
||||
|
||||
|
|
Reference in a new issue