diff --git a/script.xbmcbackup/addon.xml b/script.xbmcbackup/addon.xml index b5f70fab5..14b6c1e03 100644 --- a/script.xbmcbackup/addon.xml +++ b/script.xbmcbackup/addon.xml @@ -1,6 +1,6 @@  + name="Backup" version="1.7.3" provider-name="robweber"> @@ -24,9 +24,8 @@ resources/images/screenshot3.jpg resources/images/screenshot4.jpg - Version 1.7.2 -Fix bug with gui settings restore -strptime Python bugfix + Version 1.7.3 +additional strptime modifications to fix scheduler behavior إنسخ إحتياطياً قاعده بيانات إكس بى إم سى وملفات اﻹعدادات فى حاله وقوع إنهيار مع إمكانيه اﻹسترجاع Добавката може да създава резервни копия и възстановява базата данни и настройките на Kodi, в случай на срив или повреда на файловете. diff --git a/script.xbmcbackup/resources/lib/authorizers.py b/script.xbmcbackup/resources/lib/authorizers.py index 27203dffc..2d943c043 100644 --- a/script.xbmcbackup/resources/lib/authorizers.py +++ b/script.xbmcbackup/resources/lib/authorizers.py @@ -15,13 +15,9 @@ pass # fix for datetime.strptime bug https://kodi.wiki/view/Python_Problems#datetime.strptime -class proxydt(datetime.datetime): +def patch_strptime(date_string, format): + return datetime.datetime(*(time.strptime(date_string, format)[:6])) - @classmethod - def strptime(cls, date_string, format): - return datetime.datetime(*(time.strptime(date_string, format)[:6])) - -datetime.datetime = proxydt class QRCode(xbmcgui.WindowXMLDialog): def __init__(self, *args, **kwargs): @@ -139,24 +135,21 @@ def getClient(self): def _setToken(self, token): # write the token files - token_file = open(xbmcvfs.translatePath(utils.data_dir() + self.TOKEN_FILE), 'w') - - token_file.write(json.dumps({"access_token": token.access_token, "refresh_token": token.refresh_token, "expiration": str(token.expires_at)})) - token_file.close() + with open(xbmcvfs.translatePath(utils.data_dir() + self.TOKEN_FILE), 'w') as token_file: + token_file.write(json.dumps({"access_token": token.access_token, "refresh_token": token.refresh_token, "expiration": str(token.expires_at)})) def _getToken(self): result = {} # get token, if it exists if(xbmcvfs.exists(xbmcvfs.translatePath(utils.data_dir() + self.TOKEN_FILE))): - token_file = open(xbmcvfs.translatePath(utils.data_dir() + self.TOKEN_FILE)) - token = token_file.read() + token = "" + with open(xbmcvfs.translatePath(utils.data_dir() + self.TOKEN_FILE), 'r') as token_file: + token = token_file.read() if(token.strip() != ""): result = json.loads(token) # convert expiration back to a datetime object - result['expiration'] = datetime.datetime.strptime(result['expiration'], "%Y-%m-%d %H:%M:%S.%f") - - token_file.close() + result['expiration'] = patch_strptime(result['expiration'], "%Y-%m-%d %H:%M:%S.%f") return result