I would like to run a Python script via qgis --code myscript.py and then immediately exit. I'm using iface.actionExit().trigger(), which kills QGIS when I run it from the Python console, but not when put in the script that I pass to --code.
What's the right way to immediately exit? I'm running QGIS 2.0.1
I've also tried sys.exit(). QGIS catches it and pops up a window with the following:
An error occured during execution of following code:
execfile('myscript.py')
Traceback (most recent call last):
File "", line 1, in
File "myscript.py", line 14, in
sys.exit()
SystemExit
os.kill(os.getpid(), 9) works but it's a dirty hack and I'm looking for something better.


--screenshotflag just doesn't cut it).sys.exit()in my scripts which have worked.echo "sys.exit()" > code.py; qgis --code code.pyWhat version of QGIS were you running? How were you invoking the scripts?