Add option to store saveddata in pyfa root

Useful for these who use folder synchronization tools (e.g. dropbox)
This commit is contained in:
DarkPhoenix
2011-11-29 19:11:39 +04:00
parent f2532cdd37
commit 07a19ac3eb
2 changed files with 65 additions and 34 deletions

View File

@@ -9,6 +9,8 @@ except ImportError:
# Turns on debug mode
debug = False
# Defines if our saveddata will be in pyfa root or not
saveInRoot = False
# Version data
version = "1.1"
@@ -16,35 +18,51 @@ tag = "git"
expansionName = "Crucible"
expansionVersion = "1.0"
# You can adjust these paths to your needs
pyfaPath = None
savePath = None
staticPath = None
saveDB = None
gameDB = None
# The main pyfa directory which contains run.py
# Python 2.X uses ANSI by default, so we need to convert the character encoding
pyfaPath = getattr(configforced, "pyfaPath", None)
if pyfaPath is None:
pyfaPath = unicode(os.path.dirname(os.path.abspath(sys.modules['__main__'].__file__)), sys.getfilesystemencoding())
def defPaths():
global pyfaPath
global savePath
global staticPath
global saveDB
global gameDB
global saveInRoot
# The main pyfa directory which contains run.py
# Python 2.X uses ANSI by default, so we need to convert the character encoding
pyfaPath = getattr(configforced, "pyfaPath", None)
if pyfaPath is None:
pyfaPath = unicode(os.path.dirname(os.path.abspath(sys.modules['__main__'].__file__)), sys.getfilesystemencoding())
# Where we store the saved fits etc, default is the current users home directory
savePath = getattr(configforced, "savePath", None)
if savePath is None:
savePath = unicode(os.path.expanduser(os.path.join("~", ".pyfa")), sys.getfilesystemencoding())
# Where we store the saved fits etc, default is the current users home directory
if saveInRoot is True:
savePath = getattr(configforced, "savePath", None)
if savePath is None:
savePath = os.path.join(pyfaPath, "saveddata")
else:
savePath = getattr(configforced, "savePath", None)
if savePath is None:
savePath = unicode(os.path.expanduser(os.path.join("~", ".pyfa")), sys.getfilesystemencoding())
# Static EVE Data from the staticdata repository, should be in the staticdata directory in our pyfa directory
staticPath = os.path.join(pyfaPath, "staticdata")
# Static EVE Data from the staticdata repository, should be in the staticdata directory in our pyfa directory
staticPath = os.path.join(pyfaPath, "staticdata")
# The database where we store all the fits etc
saveDB = os.path.join(savePath, "saveddata.db")
# The database where we store all the fits etc
saveDB = os.path.join(savePath, "saveddata.db")
# The database where the static EVE data from the datadump is kept.
# This is not the standard sqlite datadump but a modified version created by eos
# maintenance script
gameDB = os.path.join(staticPath, "eve.db")
# The database where the static EVE data from the datadump is kept.
# This is not the standard sqlite datadump but a modified version created by eos
# maintenance script
gameDB = os.path.join(staticPath, "eve.db")
## DON'T MODIFY ANYTHING BELOW ##
import eos.config
## DON'T MODIFY ANYTHING BELOW ##
import eos.config
#Caching modifiers, disable all gamedata caching, its unneeded.
eos.config.gamedataCache = False
# saveddata db location modifier, shouldn't ever need to touch this
eos.config.saveddata_connectionstring = "sqlite:///" + saveDB + "?check_same_thread=False"
eos.config.gamedata_connectionstring = "sqlite:///" + gameDB + "?check_same_thread=False"
#Caching modifiers, disable all gamedata caching, its unneeded.
eos.config.gamedataCache = False
# saveddata db location modifier, shouldn't ever need to touch this
eos.config.saveddata_connectionstring = "sqlite:///" + saveDB + "?check_same_thread=False"
eos.config.gamedata_connectionstring = "sqlite:///" + gameDB + "?check_same_thread=False"

31
pyfa.py
View File

@@ -54,17 +54,30 @@ if not hasattr(sys, 'frozen'):
print "Cannot find sqlalchemy.\nYou can download sqlalchemy (0.6+) from http://www.sqlalchemy.org/"
sys.exit(1)
import wx
import os
import os.path
import config
import eos.db
import service.prefetch
from gui.mainFrame import MainFrame
from optparse import OptionParser
if __name__ == "__main__":
# Parse command line options
usage = "usage: %prog [--root]"
parser = OptionParser(usage=usage)
parser.add_option("-r", "--root", action="store_true", dest="rootsavedata", help="if you want pyfa to store its data in root folder, use this option", default=False)
(options, args) = parser.parse_args()
import config
# Configure paths
if options.rootsavedata is True:
config.saveInRoot = True
config.defPaths()
# Import everything
import wx
import os
import os.path
import eos.db
import service.prefetch
from gui.mainFrame import MainFrame
#Make sure the saveddata db exists
if not os.path.exists(config.savePath):
os.mkdir(config.savePath)