From d2d17596012122171c826cc6d8c91414fd2f54fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20B=C3=B6lter?= Date: Sat, 13 Nov 2010 17:40:02 +0100 Subject: [PATCH] Reworked config.py (better variable names autodetection) --- config.py | 29 ++++++++++++++++++++--------- gui/bitmapLoader.py | 4 ++-- gui/shipBrowser.py | 2 +- run.py | 4 ++-- service/settings.py | 2 +- 5 files changed, 26 insertions(+), 15 deletions(-) diff --git a/config.py b/config.py index 86077a8a0..86fb2ea64 100644 --- a/config.py +++ b/config.py @@ -1,20 +1,31 @@ -import os.path +import os import sys +# Turns on debug mode debug = False -#Path autodetection, only change if it doesn't work -path = os.path.dirname(unicode(__file__, sys.getfilesystemencoding())) +# You can adjust these paths to your needs +# The main pyfa directory which contains run.py +pyfaPath = os.path.join(os.getcwd(), os.path.dirname(sys.modules['__main__'].__file__)) -homePath = os.path.expanduser(os.path.join("~", ".pyfa")) -staticPath = homePath -saveddata = os.path.join(homePath, "saveddata.db") -gamedata = os.path.join(homePath, "eve.db") +# Where we store the saved fits etc, default is the current users home directory +savePath = os.path.expanduser(os.path.join("~", ".pyfa")) +# 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 the static EVE data from the datadump is kept. +# WARNING: This is not the standard sqlite datadump but a modified version for EOS +gameDB = os.path.join(staticPath, "eve.db") + +## DON'T MODIFY ANYTHING BELOW ## import eos.config #Caching modifiers, disable all gamedata caching, its unneeded. eos.config.gamedataCache = None # saveddata db location modifier, shouldn't ever need to touch this -eos.config.saveddata_connectionstring = "sqlite:///" + saveddata + "?check_same_thread=False" -eos.config.gamedata_connectionstring = "sqlite:///" + gamedata + "?check_same_thread=False" +eos.config.saveddata_connectionstring = "sqlite:///" + saveDB + "?check_same_thread=False" +eos.config.gamedata_connectionstring = "sqlite:///" + gameDB + "?check_same_thread=False" diff --git a/gui/bitmapLoader.py b/gui/bitmapLoader.py index 3d25d7c6d..2535c5c74 100644 --- a/gui/bitmapLoader.py +++ b/gui/bitmapLoader.py @@ -81,8 +81,8 @@ def getImage(name, location): path = os.path.join(location, "%s.png" % name) else: - location = os.path.join(config.path, location) + location = os.path.join(config.pyfaPath, location) path = os.path.join(location, name + ".png") - + if os.path.exists(path): return wx.Image(path) diff --git a/gui/shipBrowser.py b/gui/shipBrowser.py index 832910fb7..4fa790b10 100644 --- a/gui/shipBrowser.py +++ b/gui/shipBrowser.py @@ -722,7 +722,7 @@ class ListPane (wx.ScrolledWindow): self.Bind(wx.EVT_SCROLLWIN_LINEUP, self.MScrollUp) self.Bind(wx.EVT_SCROLLWIN_LINEDOWN, self.MScrollDown) self.Bind(wx.EVT_CHILD_FOCUS, self.OnChildFocus) -# self.loadingAnim = wx.animate.Animation(os.path.join(config.path,"icons/fit_loading.gif")) +# self.loadingAnim = wx.animate.Animation(os.path.join(config.pyfaPath,"icons/fit_loading.gif")) # self.animCtrl = wx.animate.AnimationCtrl(self, -1, self.loadingAnim) # self.animCtrl.SetUseWindowBackgroundColour() # self.animCtrl.Hide() diff --git a/run.py b/run.py index 43d308908..b1273e71c 100755 --- a/run.py +++ b/run.py @@ -50,8 +50,8 @@ import eos.db if __name__ == "__main__": #Make sure the saveddata db exists - if not os.path.exists(config.homePath): - os.mkdir(config.homePath) + if not os.path.exists(config.savePath): + os.mkdir(config.savePath) eos.db.saveddata_meta.create_all() diff --git a/service/settings.py b/service/settings.py index e75d10bbe..e6f581ed0 100644 --- a/service/settings.py +++ b/service/settings.py @@ -22,7 +22,7 @@ import os.path import config class SettingsProvider(): - BASE_PATH = os.path.join(config.homePath, "settings") + BASE_PATH = os.path.join(config.savePath, "settings") settings = {} _instance = None @classmethod