check for valid temp file on startup

This commit is contained in:
Damien Elmes 2012-09-29 21:25:33 +09:00
parent f3c3281654
commit 0b80b8bdf5

View file

@ -1,7 +1,7 @@
# Copyright: Damien Elmes <anki@ichi2.net> # Copyright: Damien Elmes <anki@ichi2.net>
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html # License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import os, sys, optparse, atexit, __builtin__ import os, sys, optparse, atexit, tempfile, __builtin__
from aqt.qt import * from aqt.qt import *
import locale, gettext import locale, gettext
import anki.lang import anki.lang
@ -191,6 +191,16 @@ def run():
# we've signaled the primary instance, so we should close # we've signaled the primary instance, so we should close
return return
# we must have a usable temp dir
try:
tempfile.gettempdir()
except:
QMessageBox.critical(
None, "Error", """\
No usable temporary folder found. Make sure C:\\temp exists or TEMP in your \
environment points to a valid, writable folder.""")
return
# parse args # parse args
opts, args = parseArgs(sys.argv) opts, args = parseArgs(sys.argv)
opts.base = unicode(opts.base or "", sys.getfilesystemencoding()) opts.base = unicode(opts.base or "", sys.getfilesystemencoding())