genPOI: hopefully fix binary string nonsense
Somebody reported that genPOI was throwing an exception in two different places related to trying to read bytes as a string. I personally could not reproduce (possibly needs some special player names or something?) but I think this change should fix it either way.
This commit is contained in:
@@ -230,7 +230,7 @@ class PlayerDict(dict):
|
|||||||
if os.path.exists(cache_file):
|
if os.path.exists(cache_file):
|
||||||
try:
|
try:
|
||||||
with closing(gzip.GzipFile(cache_file)) as gz:
|
with closing(gzip.GzipFile(cache_file)) as gz:
|
||||||
cls.uuid_cache = json.load(gz)
|
cls.uuid_cache = json.loads(gz.read().decode("utf-8"))
|
||||||
logging.info("Loaded UUID cache from %r with %d entries.",
|
logging.info("Loaded UUID cache from %r with %d entries.",
|
||||||
cache_file, len(cls.uuid_cache.keys()))
|
cache_file, len(cls.uuid_cache.keys()))
|
||||||
except (ValueError, IOError):
|
except (ValueError, IOError):
|
||||||
@@ -279,7 +279,7 @@ class PlayerDict(dict):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
try:
|
try:
|
||||||
profile = json.loads(urllib.request.urlopen(UUID_LOOKUP_URL + sname).read())
|
profile = json.loads(urllib.request.urlopen(UUID_LOOKUP_URL + sname).read().decode("utf-8"))
|
||||||
if 'name' in profile:
|
if 'name' in profile:
|
||||||
profile['retrievedAt'] = time.mktime(time.localtime())
|
profile['retrievedAt'] = time.mktime(time.localtime())
|
||||||
PlayerDict.uuid_cache[sname] = profile
|
PlayerDict.uuid_cache[sname] = profile
|
||||||
|
|||||||
Reference in New Issue
Block a user