From bef17e53c65c4305c6ab119a7faffebc73c68295 Mon Sep 17 00:00:00 2001 From: Ebag333 Date: Mon, 19 Dec 2016 00:11:55 -0800 Subject: [PATCH] Recreating wheels --- config.py | 53 ++++++++++++++++++------------------------ gui/bitmapLoader.py | 3 ++- gui/graphFrame.py | 13 ++--------- service/pycrest/eve.py | 7 +----- service/settings.py | 7 +----- 5 files changed, 29 insertions(+), 54 deletions(-) diff --git a/config.py b/config.py index 4ce6a1059..b6bc5a74c 100644 --- a/config.py +++ b/config.py @@ -94,8 +94,8 @@ def defPaths(customSavePath): if isFrozen(): certName = "cacert.pem" - os.environ["REQUESTS_CA_BUNDLE"] = getPyfaPath(certName) - os.environ["SSL_CERT_FILE"] = getPyfaPath(certName) + os.environ["REQUESTS_CA_BUNDLE"] = getPyfaPath(certName).encode('utf8') + os.environ["SSL_CERT_FILE"] = getPyfaPath(certName).encode('utf8') loggingFormat = '%(asctime)s %(name)-24s %(levelname)-8s %(message)s' logging.basicConfig(format=loggingFormat, level=logLevel) @@ -137,43 +137,36 @@ def defPaths(customSavePath): 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))) - if type(root) == str: # leave unicode ones alone - try: - root = root.decode('utf8') - except UnicodeDecodeError: - root = root.decode('windows-1252') - if not Append: - return root - - if type(root) == str: # leave unicode ones alone - try: - path = os.path.abspath(os.path.join(root, Append)).decode('utf8') - except UnicodeDecodeError: - path = os.path.abspath(os.path.join(root, Append)).decode('windows-1252') + if Append: + path = parsePath(root, Append) else: - path = os.path.abspath(os.path.join(root, Append)) + path = parsePath(root) return path def getSavePath(Append=None): root = os.path.expanduser(os.path.join("~", ".pyfa")) - if type(root) == str: # leave unicode ones alone - try: - root = root.decode('utf8') - except UnicodeDecodeError: - root = root.decode('windows-1252') - if not Append: - return root - - if type(root) == str: # leave unicode ones alone - try: - path = os.path.abspath(os.path.join(root, Append)).decode('utf8') - except UnicodeDecodeError: - path = os.path.abspath(os.path.join(root, Append)).decode('windows-1252') + if Append: + path = parsePath(root, Append) else: - path = os.path.abspath(os.path.join(root, Append)) + path = parsePath(root) + + return path + + +def parsePath(root, Append=None): + if Append: + path = os.path.join(root, Append) + else: + path = root + + if type(path) == str: # leave unicode ones alone + try: + path = path.decode('utf8') + except UnicodeDecodeError: + path = path.decode('windows-1252') return path diff --git a/gui/bitmapLoader.py b/gui/bitmapLoader.py index 2b991a818..4b2fc7c6c 100644 --- a/gui/bitmapLoader.py +++ b/gui/bitmapLoader.py @@ -20,6 +20,7 @@ import cStringIO import os.path import zipfile +from config import parsePath import wx @@ -76,7 +77,7 @@ class BitmapLoader(): filename = "{0}.png".format(name) if cls.archive: - path = os.path.join(location, filename) + path = parsePath(location, filename) if os.sep != "/" and os.sep in path: path = path.replace(os.sep, "/") diff --git a/gui/graphFrame.py b/gui/graphFrame.py index 4efac6b14..a8c10d104 100644 --- a/gui/graphFrame.py +++ b/gui/graphFrame.py @@ -27,6 +27,7 @@ import gui.mainFrame import service from gui.bitmapLoader import BitmapLoader from gui.graph import Graph +from config import parsePath enabled = True mplImported = False @@ -49,18 +50,8 @@ class GraphFrame(wx.Frame): cache_dir = mpl._get_cachedir() except: cache_dir = os.path.expanduser(os.path.join("~", ".matplotlib")) - if type(cache_dir) == str: # leave unicode ones alone - try: - cache_dir = cache_dir.decode('utf8') - except UnicodeDecodeError: - cache_dir = cache_dir.decode('windows-1252') - cache_file = os.path.join(cache_dir, 'fontList.cache') - if type(cache_file) == str: # leave unicode ones alone - try: - cache_file = cache_file.decode('utf8') - except UnicodeDecodeError: - cache_file = cache_file.decode('windows-1252') + cache_file = parsePath(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 diff --git a/service/pycrest/eve.py b/service/pycrest/eve.py index 8218f2bc5..727b2b66a 100644 --- a/service/pycrest/eve.py +++ b/service/pycrest/eve.py @@ -52,12 +52,7 @@ class FileCache(APICache): os.mkdir(self.path, 0o700) def _getpath(self, key): - path = os.path.join(self.path, str(hash(key)) + '.cache') - if type(path) == str: # leave unicode ones alone - try: - path = path.decode('utf8') - except UnicodeDecodeError: - path = path.decode('windows-1252') + path = config.parsePath(self.path, str(hash(key)) + '.cache') return path def put(self, key, value): diff --git a/service/settings.py b/service/settings.py index 71dbc9977..e1ab89bcc 100644 --- a/service/settings.py +++ b/service/settings.py @@ -44,12 +44,7 @@ class SettingsProvider(): s = self.settings.get(area) if s is None: - p = os.path.join(self.BASE_PATH, area) - if type(p) == str: # leave unicode ones alone - try: - p = p.decode('utf8') - except UnicodeDecodeError: - p = p.decode('windows-1252') + p = config.parsePath(self.BASE_PATH, area) if not os.path.exists(p): info = {}