Remove unicode path fixes for now to better test original problems
This commit is contained in:
37
config.py
37
config.py
@@ -58,6 +58,13 @@ def __createDirs(path):
|
||||
os.makedirs(path)
|
||||
|
||||
|
||||
def getPyfaRoot():
|
||||
base = getattr(sys.modules['__main__'], "__file__", sys.executable) if isFrozen() else sys.argv[0]
|
||||
root = os.path.dirname(os.path.realpath(os.path.abspath(base)))
|
||||
root = unicode(root, sys.getfilesystemencoding())
|
||||
return root
|
||||
|
||||
|
||||
def defPaths(customSavePath):
|
||||
global debug
|
||||
global pyfaPath
|
||||
@@ -75,32 +82,33 @@ def defPaths(customSavePath):
|
||||
# Python 2.X uses ANSI by default, so we need to convert the character encoding
|
||||
pyfaPath = getattr(configforced, "pyfaPath", pyfaPath)
|
||||
if pyfaPath is None:
|
||||
pyfaPath = getPyfaPath()
|
||||
pyfaPath = getPyfaRoot()
|
||||
|
||||
# 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 = getPyfaPath("saveddata")
|
||||
savePath = os.path.join(pyfaPath, "saveddata")
|
||||
else:
|
||||
savePath = getattr(configforced, "savePath", None)
|
||||
if savePath is None:
|
||||
if customSavePath is None: # customSavePath is not overriden
|
||||
savePath = os.path.expanduser(os.path.join("~", ".pyfa"))
|
||||
savePath = unicode(os.path.expanduser(os.path.join("~", ".pyfa")),
|
||||
sys.getfilesystemencoding())
|
||||
else:
|
||||
savePath = customSavePath
|
||||
|
||||
__createDirs(savePath)
|
||||
|
||||
if isFrozen():
|
||||
certName = "cacert.pem"
|
||||
os.environ["REQUESTS_CA_BUNDLE"] = getPyfaPath(certName).encode('utf8')
|
||||
os.environ["SSL_CERT_FILE"] = getPyfaPath(certName).encode('utf8')
|
||||
os.environ["REQUESTS_CA_BUNDLE"] = os.path.join(pyfaPath, "cacert.pem")
|
||||
os.environ["SSL_CERT_FILE"] = os.path.join(pyfaPath, "cacert.pem")
|
||||
|
||||
loggingFormat = '%(asctime)s %(name)-24s %(levelname)-8s %(message)s'
|
||||
logging.basicConfig(format=loggingFormat, level=logLevel)
|
||||
handler = logging.handlers.RotatingFileHandler(getSavePath("log.txt"), maxBytes=1000000, backupCount=3)
|
||||
formatter = logging.Formatter(loggingFormat)
|
||||
_format = '%(asctime)s %(name)-24s %(levelname)-8s %(message)s'
|
||||
logging.basicConfig(format=_format, level=logLevel)
|
||||
handler = logging.handlers.RotatingFileHandler(os.path.join(savePath, "log.txt"), maxBytes=1000000,
|
||||
backupCount=3)
|
||||
formatter = logging.Formatter(_format)
|
||||
handler.setFormatter(formatter)
|
||||
logging.getLogger('').addHandler(handler)
|
||||
|
||||
@@ -117,14 +125,14 @@ def defPaths(customSavePath):
|
||||
# sys.stderr = sl
|
||||
|
||||
# The database where we store all the fits etc
|
||||
saveDB = getSavePath("saveddata.db")
|
||||
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 = getPyfaPath("eve.db")
|
||||
gameDB = os.path.join(pyfaPath, "eve.db")
|
||||
|
||||
# DON'T MODIFY ANYTHING BELOW!
|
||||
## DON'T MODIFY ANYTHING BELOW ##
|
||||
import eos.config
|
||||
|
||||
# Caching modifiers, disable all gamedata caching, its unneeded.
|
||||
@@ -133,7 +141,7 @@ def defPaths(customSavePath):
|
||||
eos.config.saveddata_connectionstring = "sqlite:///" + saveDB + "?check_same_thread=False"
|
||||
eos.config.gamedata_connectionstring = "sqlite:///" + gameDB + "?check_same_thread=False"
|
||||
|
||||
|
||||
'''
|
||||
def getPyfaPath(Append=None):
|
||||
base = getattr(sys.modules['__main__'], "__file__", sys.executable) if isFrozen() else sys.argv[0]
|
||||
root = os.path.dirname(os.path.realpath(os.path.abspath(base)))
|
||||
@@ -170,3 +178,4 @@ def parsePath(root, Append=None):
|
||||
path = path.decode('windows-1252')
|
||||
|
||||
return path
|
||||
'''
|
||||
@@ -20,7 +20,6 @@
|
||||
import cStringIO
|
||||
import os.path
|
||||
import zipfile
|
||||
from config import parsePath
|
||||
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
@@ -35,7 +34,7 @@ except ImportError:
|
||||
|
||||
class BitmapLoader(object):
|
||||
try:
|
||||
archive = zipfile.ZipFile(config.getPyfaPath('imgs.zip'), 'r')
|
||||
archive = zipfile.ZipFile(os.path.join(config.pyfaPath, 'imgs.zip', 'r'))
|
||||
except IOError:
|
||||
archive = None
|
||||
|
||||
@@ -78,7 +77,7 @@ class BitmapLoader(object):
|
||||
filename = "{0}.png".format(name)
|
||||
|
||||
if cls.archive:
|
||||
path = parsePath(location, filename)
|
||||
path = os.path.join(location, filename)
|
||||
if os.sep != "/" and os.sep in path:
|
||||
path = path.replace(os.sep, "/")
|
||||
|
||||
@@ -89,7 +88,7 @@ class BitmapLoader(object):
|
||||
except KeyError:
|
||||
print("Missing icon file from zip: {0}".format(path))
|
||||
else:
|
||||
path = config.getPyfaPath('imgs' + os.sep + location + os.sep + filename)
|
||||
path = os.path.join(config.pyfaPath, 'imgs' + os.sep + location + os.sep + filename)
|
||||
|
||||
if os.path.exists(path):
|
||||
return wx.Image(path)
|
||||
|
||||
@@ -29,7 +29,6 @@ import gui.mainFrame
|
||||
import gui.globalEvents as GE
|
||||
from gui.graph import Graph
|
||||
from gui.bitmapLoader import BitmapLoader
|
||||
from config import parsePath
|
||||
|
||||
try:
|
||||
import matplotlib as mpl
|
||||
@@ -74,7 +73,7 @@ class GraphFrame(wx.Frame):
|
||||
except:
|
||||
cache_dir = os.path.expanduser(os.path.join("~", ".matplotlib"))
|
||||
|
||||
cache_file = parsePath(cache_dir, 'fontList.cache')
|
||||
cache_file = path = os.path.join(cache_dir, 'fontList.cache')
|
||||
|
||||
if os.access(cache_dir, os.W_OK | os.X_OK) and os.path.isfile(cache_file):
|
||||
# remove matplotlib font cache, see #234
|
||||
|
||||
@@ -849,7 +849,7 @@ class ItemEffects(wx.Panel):
|
||||
If effect file does not exist, create it
|
||||
"""
|
||||
|
||||
file_ = config.getPyfaPath(os.path.join("eos", "effects", "%s.py" % event.GetText().lower()))
|
||||
file_ = os.path.join(config.pyfaPath, "eos", "effects", "%s.py" % event.GetText().lower())
|
||||
|
||||
if not os.path.isfile(file_):
|
||||
open(file_, 'a').close()
|
||||
|
||||
@@ -43,7 +43,7 @@ class FileCache(APICache):
|
||||
os.mkdir(self.path, 0o700)
|
||||
|
||||
def _getpath(self, key):
|
||||
return config.parsePath(self.path, str(hash(key)) + '.cache')
|
||||
return os.path.join(self.path, str(hash(key)) + '.cache')
|
||||
|
||||
def put(self, key, value):
|
||||
with open(self._getpath(key), 'wb') as f:
|
||||
|
||||
@@ -25,7 +25,7 @@ import config
|
||||
|
||||
|
||||
class SettingsProvider(object):
|
||||
BASE_PATH = config.getSavePath("settings")
|
||||
BASE_PATH = os.path.join(config.savePath, 'settings')
|
||||
settings = {}
|
||||
_instance = None
|
||||
|
||||
@@ -44,7 +44,7 @@ class SettingsProvider(object):
|
||||
|
||||
s = self.settings.get(area)
|
||||
if s is None:
|
||||
p = config.parsePath(self.BASE_PATH, area)
|
||||
p = os.path.join(self.BASE_PATH, area)
|
||||
|
||||
if not os.path.exists(p):
|
||||
info = {}
|
||||
|
||||
Reference in New Issue
Block a user