I want to run a script in Blender in background mode. If the script fails, I want to print my own error and have Blender exit with a return code of 1. I can do this:
print("script failed", file=sys.stderr)
sys.exit(1)
In older versions of Blender e.g. 2.69, this causes Blender to print stuff like:
Error: Not freed memory blocks: 5
IDProperty group len: 128 0x7f98be0ff938
TEXT_OT_run_script len: 168 0x7f98be064938
wmOperatorPtrRNA len: 24 0x7f98be5f1c18
IDProperty array dup len: 128 0x7f98be16deb8
wmOperatorReportList len: 40 0x7f98be0b1078
Blender quit
In 2.73a, it prints:
Error: Not freed memory blocks: 5
Which is better but not ideal, because it might make it hard for a user of my script to see what the real error is.
Is there a better way to make Blender exit?
stderrhas a special meaning in the environment I'm using: it's for debugging and error messages. I suppose I could wrap the Blender execution in another script that redirects stuff fromstderrtostdout... hoping not to though :) $\endgroup$2>&1$\endgroup$