Add --temp-basedir option.

This commit is contained in:
Florian Bruhin 2015-05-16 23:26:15 +02:00
parent d7999577dd
commit a1f7eed5a7
3 changed files with 13 additions and 0 deletions

View File

@ -96,6 +96,9 @@ show it.
*--pdb-postmortem*:: *--pdb-postmortem*::
Drop into pdb on exceptions. Drop into pdb on exceptions.
*--temp-basedir*::
Use a temporary basedir.
*--qt-name* 'NAME':: *--qt-name* 'NAME'::
Set the window name. Set the window name.

View File

@ -26,6 +26,8 @@ import configparser
import functools import functools
import json import json
import time import time
import shutil
import tempfile
from PyQt5.QtWidgets import QApplication, QMessageBox from PyQt5.QtWidgets import QApplication, QMessageBox
from PyQt5.QtGui import QDesktopServices, QPixmap, QIcon, QCursor, QWindow from PyQt5.QtGui import QDesktopServices, QPixmap, QIcon, QCursor, QWindow
@ -66,6 +68,9 @@ def run(args):
print(version.GPL_BOILERPLATE.strip()) print(version.GPL_BOILERPLATE.strip())
sys.exit(0) sys.exit(0)
if args.temp_basedir:
args.basedir = tempfile.mkdtemp()
quitter = Quitter(args) quitter = Quitter(args)
objreg.register('quitter', quitter) objreg.register('quitter', quitter)
@ -638,6 +643,9 @@ class Quitter:
# Re-enable faulthandler to stdout, then remove crash log # Re-enable faulthandler to stdout, then remove crash log
log.destroy.debug("Deactivating crash log...") log.destroy.debug("Deactivating crash log...")
objreg.get('crash-handler').destroy_crashlogfile() objreg.get('crash-handler').destroy_crashlogfile()
# Delete temp basedir
if self._args.temp_basedir:
shutil.rmtree(self._args.basedir)
# If we don't kill our custom handler here we might get segfaults # If we don't kill our custom handler here we might get segfaults
log.destroy.debug("Deactiving message handler...") log.destroy.debug("Deactiving message handler...")
qInstallMessageHandler(None) qInstallMessageHandler(None)

View File

@ -94,6 +94,8 @@ def get_argparser():
"show a crash dialog.") "show a crash dialog.")
debug.add_argument('--pdb-postmortem', action='store_true', debug.add_argument('--pdb-postmortem', action='store_true',
help="Drop into pdb on exceptions.") help="Drop into pdb on exceptions.")
debug.add_argument('--temp-basedir', action='store_true', help="Use a "
"temporary basedir.")
# For the Qt args, we use store_const with const=True rather than # For the Qt args, we use store_const with const=True rather than
# store_true because we want the default to be None, to make # store_true because we want the default to be None, to make
# utils.qt:get_args easier. # utils.qt:get_args easier.