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
1 changed files with 5 additions and 10 deletions

View File

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