mirror of
https://github.com/ankitects/anki.git
synced 2025-09-21 23:42:23 -04:00
more robustly handle win32 brokenness
This commit is contained in:
parent
b235a45f6b
commit
cba494c5ad
1 changed files with 24 additions and 0 deletions
|
@ -78,8 +78,11 @@ class AnkiApp(QApplication):
|
||||||
def run():
|
def run():
|
||||||
import config
|
import config
|
||||||
|
|
||||||
|
mustQuit = False
|
||||||
|
|
||||||
# home on win32 is broken
|
# home on win32 is broken
|
||||||
if sys.platform == "win32":
|
if sys.platform == "win32":
|
||||||
|
# use appdata if available
|
||||||
if 'APPDATA' in os.environ:
|
if 'APPDATA' in os.environ:
|
||||||
oldConf = os.path.expanduser("~/.anki/config.db")
|
oldConf = os.path.expanduser("~/.anki/config.db")
|
||||||
oldPlugins = os.path.expanduser("~/.anki/plugins")
|
oldPlugins = os.path.expanduser("~/.anki/plugins")
|
||||||
|
@ -87,10 +90,25 @@ def run():
|
||||||
else:
|
else:
|
||||||
oldConf = None
|
oldConf = None
|
||||||
os.environ['HOME'] = "c:\\anki"
|
os.environ['HOME'] = "c:\\anki"
|
||||||
|
# make and check accessible
|
||||||
try:
|
try:
|
||||||
os.makedirs(os.path.expanduser("~/.anki"))
|
os.makedirs(os.path.expanduser("~/.anki"))
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
try:
|
||||||
|
os.listdir(os.path.expanduser("~/.anki"))
|
||||||
|
except:
|
||||||
|
oldConf = None
|
||||||
|
os.environ['HOME'] = "c:\\anki"
|
||||||
|
# check accessible again
|
||||||
|
try:
|
||||||
|
os.makedirs(os.path.expanduser("~/.anki"))
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
os.listdir(os.path.expanduser("~/.anki"))
|
||||||
|
except:
|
||||||
|
mustQuit = True
|
||||||
if (oldConf and os.path.exists(oldConf) and not os.path.exists(
|
if (oldConf and os.path.exists(oldConf) and not os.path.exists(
|
||||||
oldConf.replace("config.db", "config.db.old"))):
|
oldConf.replace("config.db", "config.db.old"))):
|
||||||
try:
|
try:
|
||||||
|
@ -115,6 +133,12 @@ def run():
|
||||||
app = AnkiApp(sys.argv)
|
app = AnkiApp(sys.argv)
|
||||||
QCoreApplication.setApplicationName("Anki")
|
QCoreApplication.setApplicationName("Anki")
|
||||||
|
|
||||||
|
if mustQuit:
|
||||||
|
QMessageBox.warning(
|
||||||
|
None, "Anki", "Can't open APPDATA, nor c:\\anki.\n"
|
||||||
|
"Please try removing foreign characters from your username.")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
import forms
|
import forms
|
||||||
import ui
|
import ui
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue