sys.exit(<errornumber>) not passed to %errorlevel% ?

52 views
Skip to first unread message

Nick Corrie

unread,
Apr 1, 2015, 12:37:38 PM4/1/15
to portabl...@googlegroups.com
Hi - I'm using Python-Portable to run a Python script which exits with a non-zero value if there has been an error:

e.g.:

except:
exc_type, exc_value, exc_traceback = sys.exc_info()
logging.error("Unexpected error: " + str(exc_type))
logging.error("Unexpected error: " + str(exc_value))
sys.exit(-1)

When I run this script using regular Python installed on Windows I can see an %errorlevel% of -1 passed back to the command shell, yet if I run it with Python-Portable the errorlevel is always 0, even if I raise a sys.exist(-1) from within the called script.

Is there a way of asking Python-Portable to exit with a specific error level from within a Python script?

Perica Zivkovic

unread,
May 11, 2015, 3:44:56 PM5/11/15
to portabl...@googlegroups.com, nickc...@gmail.com
Nick,

at the moment this is not possible if you are using "Portable" shortcuts.

You could workaround this with a batch file that starts python.exe (or pythonw.exe) from the App folder directy but don't forget to extend the PATH env variable with the "App" folder and set PYTHONPATH env variable to the "App" folder.

After that call python.exe with your script as a parameter and you should be good to go.

hope it helps!
Reply all
Reply to author
Forward
0 new messages