allow setting base via env var

This commit is contained in:
Damien Elmes 2017-02-15 13:41:19 +10:00
parent 4430785122
commit 88d8be32d9

View file

@ -66,12 +66,7 @@ class ProfileManager:
self.name = None self.name = None
self.db = None self.db = None
# instantiate base folder # instantiate base folder
if base: self._setBaseFolder(base)
self.base = os.path.abspath(base)
else:
self.base = self._defaultBase()
self.maybeMigrateFolder()
self.ensureBaseExists()
# load metadata # load metadata
self.firstRun = self._loadMeta() self.firstRun = self._loadMeta()
# did the user request a profile to start up with? # did the user request a profile to start up with?
@ -226,6 +221,16 @@ and no other programs are accessing your profile folders, then try again."""))
os.makedirs(path) os.makedirs(path)
return path return path
def _setBaseFolder(self, cmdlineBase):
if cmdlineBase:
self.base = os.path.abspath(cmdlineBase)
elif os.environ.get("ANKI_BASE"):
self.base = os.path.abspath(os.environ["ANKI_BASE"])
else:
self.base = self._defaultBase()
self.maybeMigrateFolder()
self.ensureBaseExists()
def _defaultBase(self): def _defaultBase(self):
if isWin: if isWin:
loc = QStandardPaths.writableLocation(QStandardPaths.DocumentsLocation) loc = QStandardPaths.writableLocation(QStandardPaths.DocumentsLocation)