Fix deviceId not generating

Change the logic around xbmcvfs.File() since it doesn't causes an error
but instead returns an empty string.
This commit is contained in:
angelblue05 2016-01-29 18:13:13 -06:00
parent d3dfef4991
commit c37a9efdf3

View file

@ -81,19 +81,14 @@ class ClientInfo():
else: else:
GUID_file = xbmc.translatePath(os.path.join(addon_path.encode("utf-8"), "machine_guid")).decode('utf-8') GUID_file = xbmc.translatePath(os.path.join(addon_path.encode("utf-8"), "machine_guid")).decode('utf-8')
try:
GUID = xbmcvfs.File(GUID_file) GUID = xbmcvfs.File(GUID_file)
clientId = GUID.read()
except Exception as e: # machine_guid does not exists. if not clientId:
self.logMsg("Generating a new deviceid: %s" % e, 1) self.logMsg("Generating a new deviceid...", 1)
clientId = str("%012X" % uuid4()) clientId = str("%012X" % uuid4())
GUID = xbmcvfs.File(GUID_file, 'w') GUID = xbmcvfs.File(GUID_file, 'w')
GUID.write(clientId) GUID.write(clientId)
else: # machine_guid already exists. Get guid.
clientId = GUID.read()
finally:
GUID.close() GUID.close()
self.logMsg("DeviceId loaded: %s" % clientId, 1) self.logMsg("DeviceId loaded: %s" % clientId, 1)