Catch the exception in Python2 or Python 3

This commit is contained in:
Bernhard F.W. Gschaider 2014-07-10 11:38:13 +02:00 committed by Dominik Christ
parent 93ca2b71ee
commit 170d1bb369

View file

@ -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