mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-31 14:33:54 -04:00
A nicer error message when calibre fails to create the temporary directory. Fixes #1622131 [Inelegant fail when TEMP folder is missing, having been set by an environment variable.](https://bugs.launchpad.net/calibre/+bug/1622131)
This commit is contained in:
parent
0f6be31b89
commit
b41426373e
@ -15,6 +15,7 @@ from PyQt5.Qt import (
|
|||||||
from calibre import prints
|
from calibre import prints
|
||||||
from calibre.constants import (islinux, iswindows, isbsd, isfrozen, isosx,
|
from calibre.constants import (islinux, iswindows, isbsd, isfrozen, isosx,
|
||||||
plugins, config_dir, filesystem_encoding, isxp, DEBUG, __version__, __appname__ as APP_UID)
|
plugins, config_dir, filesystem_encoding, isxp, DEBUG, __version__, __appname__ as APP_UID)
|
||||||
|
from calibre.ptempfile import base_dir
|
||||||
from calibre.utils.config import Config, ConfigProxy, dynamic, JSONConfig
|
from calibre.utils.config import Config, ConfigProxy, dynamic, JSONConfig
|
||||||
from calibre.ebooks.metadata import MetaInformation
|
from calibre.ebooks.metadata import MetaInformation
|
||||||
from calibre.utils.date import UNDEFINED_DATE
|
from calibre.utils.date import UNDEFINED_DATE
|
||||||
@ -858,6 +859,15 @@ def setup_gui_option_parser(parser):
|
|||||||
parser.add_option('--detach', default=False, action='store_true',
|
parser.add_option('--detach', default=False, action='store_true',
|
||||||
help=_('Detach from the controlling terminal, if any (linux only)'))
|
help=_('Detach from the controlling terminal, if any (linux only)'))
|
||||||
|
|
||||||
|
def show_temp_dir_error(err):
|
||||||
|
import traceback
|
||||||
|
extra = _('Click "Show details" for more information.')
|
||||||
|
if 'CALIBRE_TEMP_DIR' in os.environ:
|
||||||
|
extra = _('The %s environment variable is set. Try unsetting it.') % 'CALIBRE_TEMP_DIR'
|
||||||
|
error_dialog(None, _('Could not create temporary directory'), _(
|
||||||
|
'Could not create temporary directory, calibre cannot start.') + ' ' + extra, det_msg=traceback.format_exc(), show=True)
|
||||||
|
|
||||||
|
|
||||||
class Application(QApplication):
|
class Application(QApplication):
|
||||||
|
|
||||||
shutdown_signal_received = pyqtSignal()
|
shutdown_signal_received = pyqtSignal()
|
||||||
@ -890,6 +900,12 @@ class Application(QApplication):
|
|||||||
QApplication.setApplicationName(APP_UID)
|
QApplication.setApplicationName(APP_UID)
|
||||||
QApplication.__init__(self, qargs)
|
QApplication.__init__(self, qargs)
|
||||||
self.setAttribute(Qt.AA_UseHighDpiPixmaps)
|
self.setAttribute(Qt.AA_UseHighDpiPixmaps)
|
||||||
|
try:
|
||||||
|
base_dir()
|
||||||
|
except EnvironmentError as err:
|
||||||
|
if not headless:
|
||||||
|
show_temp_dir_error(err)
|
||||||
|
raise SystemExit('Failed to create temporary directory')
|
||||||
if DEBUG and not headless:
|
if DEBUG and not headless:
|
||||||
prints('devicePixelRatio:', self.devicePixelRatio())
|
prints('devicePixelRatio:', self.devicePixelRatio())
|
||||||
s = self.primaryScreen()
|
s = self.primaryScreen()
|
||||||
|
@ -49,7 +49,10 @@ if not _run_once:
|
|||||||
#
|
#
|
||||||
# Ensure that all temp files/dirs are created under a calibre tmp dir
|
# Ensure that all temp files/dirs are created under a calibre tmp dir
|
||||||
from calibre.ptempfile import base_dir
|
from calibre.ptempfile import base_dir
|
||||||
|
try:
|
||||||
base_dir()
|
base_dir()
|
||||||
|
except EnvironmentError:
|
||||||
|
pass # Ignore this error during startup, so we can show a better error message to the user later.
|
||||||
|
|
||||||
#
|
#
|
||||||
# Convert command line arguments to unicode
|
# Convert command line arguments to unicode
|
||||||
|
Loading…
x
Reference in New Issue
Block a user