1
$\begingroup$

I am running a python expression through blender from the commandline. I want to know if the python expression is executed correctly or not. But Blender always exits with a 0 code. Is there any way to make it exit with the same code as the python expression?

For example I would expect the following command exit with a non-zero code:

"\Program Files\blender foundation\blender\blender.exe" --background --python-expr "2/0"
$\endgroup$
1
$\begingroup$

You will have to put the expr in try and explicitly exit with an error code on exception.

E.g. following exits with exit code 10 (user defined):

"\Program Files\blender foundation\blender\blender.exe" --background --python-expr "exec('import sys\ntry: 2/0\nexcept: sys.exit(10)')"
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.