Handle unicode, utf8, and windows-1252
(cherry picked from commit 0d4f24a)
This commit is contained in:
@@ -45,7 +45,13 @@ class FileCache(APICache):
|
||||
os.mkdir(self.path, 0o700)
|
||||
|
||||
def _getpath(self, key):
|
||||
return os.path.join(self.path, str(hash(key)) + '.cache')
|
||||
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')
|
||||
return path
|
||||
|
||||
def put(self, key, value):
|
||||
with open(self._getpath(key), 'wb') as f:
|
||||
|
||||
@@ -45,6 +45,11 @@ class SettingsProvider(object):
|
||||
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')
|
||||
|
||||
if not os.path.exists(p):
|
||||
info = {}
|
||||
@@ -188,10 +193,10 @@ class NetworkSettings(object):
|
||||
def setAccess(self, access):
|
||||
self.serviceNetworkSettings["access"] = access
|
||||
|
||||
def autodetect(self):
|
||||
@staticmethod
|
||||
def autodetect():
|
||||
|
||||
proxy = None
|
||||
proxAddr = proxPort = ""
|
||||
proxydict = urllib2.ProxyHandler().proxies
|
||||
|
||||
validPrefixes = ("http", "https")
|
||||
|
||||
Reference in New Issue
Block a user