From 5e2d0994480a52700855ab4da6e3e90378f5a7ee Mon Sep 17 00:00:00 2001 From: Rob Weber Date: Wed, 4 Dec 2019 11:31:00 -0600 Subject: [PATCH 1/2] fixes per enen92 --- addon.xml | 13 ++++++------- default.py | 1 - resources/__init__.py | 0 resources/lib/__init__.py | 0 resources/lib/advanced_editor.py | 9 +++++---- resources/lib/backup.py | 10 ++++------ resources/lib/tinyurl.py | 2 +- 7 files changed, 16 insertions(+), 19 deletions(-) delete mode 100644 resources/__init__.py delete mode 100644 resources/lib/__init__.py diff --git a/addon.xml b/addon.xml index e879414..10093e4 100644 --- a/addon.xml +++ b/addon.xml @@ -80,12 +80,10 @@ Už ste niekedy poškodili konfiguráciu Kodi a priali si mať zálohu? Teraz môžete - na jeden klik. Môžete exportovať Vašu databázu, playlist, náhľady, doplnky a konfigurácie na ktorýkoľvek zdroj zapisovateľný Kodi. Zálohy môžu byť púšťané na požiadanie alebo plánovačom. Har du någonsin tappat bort din Kodi konfiguration och önskat att du hade en backup? Nu kan du enkelt med ett klick. Du kan exportera din databas, spellista, minityrer, tillägg och andra konfigurationsdetaljer till valfri källa som är skrivbar för Kodi. Backupper kan köras på begäran eller via scheman. 你是否经常折腾你的 Kodi,因而希望能够有个备份?你可以把资料库、播放列表、缩略图、插件和其他配置细节导出到 Kodi 可以写入的任意位置。备份可以按需运行或通过计划任务执行。 - all - The MIT License + MIT https://forum.kodi.tv/showthread.php?tid=129499 https://github.com/robweber/xbmcbackup - resources/images/icon.png resources/images/screenshot1.png @@ -93,10 +91,11 @@ resources/images/screenshot3.png resources/images/screenshot4.png - Version 1.5.2 -- Added script.module.dropbox import as a dependency for Dropbox filesystem -- Fixed issue getting xbmcbackup.val file from non-zipped remote directories. Was being copied as though it was a local file so it was failing. -- Use linux path separator (/) all the time, Kodi will interpret this correctly on windows. Was causing issues with remote file systems since os.path.sep + Version 1.6.0 +- Backups/Restores now use the concept of a Set to define groups of related files. Restores can restore one set or all sets within a backup archive (no more all or nothing restores) +- Added a new Advanced Editor script for more dynamic included/excluded directories based on a JSON formatted file +- Fixed guisettings restores +- Removed GoogleDrive support - Python 3 compatibility was an issue diff --git a/default.py b/default.py index 7c6c190..40b4422 100644 --- a/default.py +++ b/default.py @@ -1,4 +1,3 @@ -import sys import xbmc import xbmcgui import resources.lib.utils as utils diff --git a/resources/__init__.py b/resources/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/resources/lib/__init__.py b/resources/lib/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/resources/lib/advanced_editor.py b/resources/lib/advanced_editor.py index 6332278..23a0885 100644 --- a/resources/lib/advanced_editor.py +++ b/resources/lib/advanced_editor.py @@ -2,6 +2,7 @@ import json import xbmc import xbmcgui import xbmcvfs +import os.path from . import utils as utils @@ -180,14 +181,14 @@ class AdvancedBackupEditor: while(exitCondition != -1): # load the custom paths listItem = xbmcgui.ListItem(utils.getString(30126), '') - listItem.setArt({'icon': utils.addon_dir() + 'resources/images/plus-icon.png'}) + listItem.setArt({'icon': os.path.join(utils.addon_dir(),'resources','images','plus-icon.png')}) options = [listItem] for index in range(0, len(customPaths.getSets())): aSet = customPaths.getSet(index) listItem = xbmcgui.ListItem(aSet['name'], utils.getString(30121) + ': ' + aSet['set']['root']) - listItem.setArt({'icon': utils.addon_dir() + 'resources/images/folder-icon.png'}) + listItem.setArt({'icon': os.path.join(utils.addon_dir(),'resources','images','folder-icon.png')}) options.append(listItem) # show the gui @@ -226,7 +227,7 @@ class AdvancedBackupEditor: shouldContinue = self.dialog.yesno(utils.getString(30139), utils.getString(30140), utils.getString(30141)) if(shouldContinue): - source = xbmc.translatePath(utils.addon_dir() + "/resources/data/default_files.json") - dest = xbmc.translatePath(utils.data_dir() + "/custom_paths.json") + source = xbmc.translatePath(os.path.join(utils.addon_dir(),'resources','data','default_files.json')) + dest = xbmc.translatePath(os.path.join(utils.data_dir(),'custom_paths.json')) xbmcvfs.copy(source, dest) diff --git a/resources/lib/backup.py b/resources/lib/backup.py index a040885..a8b9f46 100644 --- a/resources/lib/backup.py +++ b/resources/lib/backup.py @@ -522,14 +522,12 @@ class XbmcBackup: return result def _createResumeBackupFile(self): - rFile = xbmcvfs.File(xbmc.translatePath(utils.data_dir() + "resume.txt"), 'w') - rFile.write(self.restore_point) - rFile.close() + with xbmcvfs.File(xbmc.translatePath(utils.data_dir() + "resume.txt"), 'w') as f: + f.write(self.restore_point) def _readBackupConfig(self, aFile): - jFile = xbmcvfs.File(xbmc.translatePath(aFile), 'r') - jsonString = jFile.read() - jFile.close() + with xbmcvfs.File(xbmc.translatePath(aFile), 'r') as f: + jsonString = f.read() return json.loads(jsonString) diff --git a/resources/lib/tinyurl.py b/resources/lib/tinyurl.py index 7f82053..efb769d 100644 --- a/resources/lib/tinyurl.py +++ b/resources/lib/tinyurl.py @@ -9,4 +9,4 @@ def shorten(aUrl): data = req.read() # should be a tiny url - return str(data) + return data From 710bcd08f874037aae89351a158136e15e1b0c40 Mon Sep 17 00:00:00 2001 From: Rob Weber Date: Wed, 4 Dec 2019 11:38:25 -0600 Subject: [PATCH 2/2] pep8 fixes --- .travis.yml | 2 +- resources/lib/advanced_editor.py | 8 ++++---- resources/lib/backup.py | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7651c98..7484677 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,5 +10,5 @@ before_script: # command to run our tests script: - - flake8 ./ --statistics --show-source --ignore=E501,E722 --exclude=croniter.py,relativedelta.py,*/dropbox/* # check python structure against flake8 tests, ignore long lines + - flake8 ./ --statistics --show-source --builtins=sys --ignore=E501,E722 --exclude=croniter.py,relativedelta.py,*/dropbox/* # check python structure against flake8 tests, ignore long lines - kodi-addon-checker --branch=matrix --allow-folder-id-mismatch \ No newline at end of file diff --git a/resources/lib/advanced_editor.py b/resources/lib/advanced_editor.py index 23a0885..31acc7a 100644 --- a/resources/lib/advanced_editor.py +++ b/resources/lib/advanced_editor.py @@ -181,14 +181,14 @@ class AdvancedBackupEditor: while(exitCondition != -1): # load the custom paths listItem = xbmcgui.ListItem(utils.getString(30126), '') - listItem.setArt({'icon': os.path.join(utils.addon_dir(),'resources','images','plus-icon.png')}) + listItem.setArt({'icon': os.path.join(utils.addon_dir(), 'resources', 'images', 'plus-icon.png')}) options = [listItem] for index in range(0, len(customPaths.getSets())): aSet = customPaths.getSet(index) listItem = xbmcgui.ListItem(aSet['name'], utils.getString(30121) + ': ' + aSet['set']['root']) - listItem.setArt({'icon': os.path.join(utils.addon_dir(),'resources','images','folder-icon.png')}) + listItem.setArt({'icon': os.path.join(utils.addon_dir(), 'resources', 'images', 'folder-icon.png')}) options.append(listItem) # show the gui @@ -227,7 +227,7 @@ class AdvancedBackupEditor: shouldContinue = self.dialog.yesno(utils.getString(30139), utils.getString(30140), utils.getString(30141)) if(shouldContinue): - source = xbmc.translatePath(os.path.join(utils.addon_dir(),'resources','data','default_files.json')) - dest = xbmc.translatePath(os.path.join(utils.data_dir(),'custom_paths.json')) + source = xbmc.translatePath(os.path.join(utils.addon_dir(), 'resources', 'data', 'default_files.json')) + dest = xbmc.translatePath(os.path.join(utils.data_dir(), 'custom_paths.json')) xbmcvfs.copy(source, dest) diff --git a/resources/lib/backup.py b/resources/lib/backup.py index a8b9f46..58b5761 100644 --- a/resources/lib/backup.py +++ b/resources/lib/backup.py @@ -522,7 +522,7 @@ class XbmcBackup: return result def _createResumeBackupFile(self): - with xbmcvfs.File(xbmc.translatePath(utils.data_dir() + "resume.txt"), 'w') as f: + with xbmcvfs.File(xbmc.translatePath(utils.data_dir() + "resume.txt"), 'w') as f: f.write(self.restore_point) def _readBackupConfig(self, aFile):