From 163124089bd31f7c4b603ee13d18db202953b128 Mon Sep 17 00:00:00 2001 From: Rob Weber Date: Mon, 20 Jan 2014 11:40:00 -0600 Subject: [PATCH 01/14] version increment for Gotham --- addon.xml | 2 +- changelog.txt | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/addon.xml b/addon.xml index c3e7668..a3cc899 100644 --- a/addon.xml +++ b/addon.xml @@ -1,6 +1,6 @@  + name="XBMC Backup" version="0.5.0" provider-name="robweber"> diff --git a/changelog.txt b/changelog.txt index f334767..38ff1a7 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,7 @@ +Version 0.5.0 + +New Version for Gotham + Version 0.4.4 modified the check for invalid file types From 987d90de1244d13915da732667feaf8fe47190e7 Mon Sep 17 00:00:00 2001 From: Rob Weber Date: Mon, 20 Jan 2014 12:42:49 -0600 Subject: [PATCH 02/14] added options for background progress bar. part of #36 --- resources/language/English/strings.xml | 5 ++++- resources/lib/backup.py | 15 ++++++++++----- resources/settings.xml | 2 +- scheduler.py | 11 ++++++++--- 4 files changed, 23 insertions(+), 10 deletions(-) diff --git a/resources/language/English/strings.xml b/resources/language/English/strings.xml index 4f04fa7..979df3c 100644 --- a/resources/language/English/strings.xml +++ b/resources/language/English/strings.xml @@ -14,7 +14,7 @@ Type Path Browse Remote Path Backup Folder Name - Run Silent + Progress Display Mode Type Remote Path Remote Path Type @@ -73,4 +73,7 @@ Just Today Profiles Scheduler will run again on + Progress Bar + Background Progress Bar + None (Silent) diff --git a/resources/lib/backup.py b/resources/lib/backup.py index 1e3d45e..28ef76a 100644 --- a/resources/lib/backup.py +++ b/resources/lib/backup.py @@ -70,7 +70,7 @@ class XbmcBackup: def skipAdvanced(self): self.skip_advanced = True - def run(self,mode=-1,runSilent=False): + def run(self,mode=-1,progressOverride=False): #append backup folder name progressBarTitle = utils.getString(30010) + " - " if(mode == self.Backup and self.remote_vfs.root_path != ''): @@ -88,8 +88,13 @@ class XbmcBackup: utils.log(utils.getString(30048) + ": " + self.remote_vfs.root_path) #check if we should use the progress bar - if(utils.getSetting('run_silent') == 'false' and not runSilent): - self.progressBar = xbmcgui.DialogProgress() + if(int(utils.getSetting('progress_mode')) != 2): + #check if background or normal + if(int(utils.getSetting('progress_mode')) == 0 and not progressOverride): + self.progressBar = xbmcgui.DialogProgress() + else: + self.progressBar = xbmcgui.DialogProgressBG() + self.progressBar.create(progressBarTitle,utils.getString(30049) + "......") if(mode == self.Backup): @@ -296,7 +301,7 @@ class XbmcBackup: #call update addons to refresh everything xbmc.executebuiltin('UpdateLocalAddons') - if(utils.getSetting('run_silent') == 'false' and not runSilent): + if(self.progressBar != None): self.progressBar.close() def backupFiles(self,fileList,source,dest): @@ -342,7 +347,7 @@ class XbmcBackup: def _checkCancel(self): result = False - if(self.progressBar != None): + if(self.progressBar != None and type(self.progressBar) is xbmcgui.DialogProgress): result = self.progressBar.iscanceled() return result diff --git a/resources/settings.xml b/resources/settings.xml index e14e466..21d98d1 100644 --- a/resources/settings.xml +++ b/resources/settings.xml @@ -7,7 +7,7 @@ - + diff --git a/scheduler.py b/scheduler.py index d2df48e..39b23b9 100644 --- a/scheduler.py +++ b/scheduler.py @@ -46,13 +46,18 @@ class BackupScheduler: now = time.time() if(self.next_run <= now): - if(utils.getSetting('run_silent') == 'false'): + progress_mode = int(utils.getSetting('progress_mode')) + if(progress_mode != 2): utils.showNotification(utils.getString(30053)) - #run the job in backup mode, hiding the dialog box + backup = XbmcBackup() if(backup.remoteConfigured()): - backup.run(XbmcBackup.Backup,True) + + if(int(utils.getSetting('progress_mode')) in [0,1]): + backup.run(XbmcBackup.Backup,True) + else: + backup.run(XbmcBackup.Backup,False) #check if this is a "one-off" if(int(utils.getSetting("schedule_interval")) == 0): From e3be458a28985a575e4d4abee7ed029e9c64b5ac Mon Sep 17 00:00:00 2001 From: Rob Weber Date: Mon, 20 Jan 2014 12:48:23 -0600 Subject: [PATCH 03/14] use xbmcgui.notification() part of #36 --- resources/lib/utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/resources/lib/utils.py b/resources/lib/utils.py index bc1814a..3f317a9 100644 --- a/resources/lib/utils.py +++ b/resources/lib/utils.py @@ -1,4 +1,5 @@ import xbmc +import xbmcgui import xbmcaddon __addon_id__= 'script.xbmcbackup' @@ -17,7 +18,7 @@ def log(message,loglevel=xbmc.LOGNOTICE): xbmc.log(encode(__addon_id__ + ": " + message),level=loglevel) def showNotification(message): - xbmc.executebuiltin("Notification(" + encode(getString(30010)) + "," + encode(message) + ",4000," + xbmc.translatePath(__Addon.getAddonInfo('path') + "/icon.png") + ")") + xbmcgui.Dialog().notification(encode(getString(30010)),encode(message),time=4000,icon=xbmc.translatePath(__Addon.getAddonInfo('path') + "/icon.png")) def getSetting(name): return __Addon.getSetting(name) From 77dbd69ce20b3d9667a8c459b6b7b76847edde77 Mon Sep 17 00:00:00 2001 From: Rob Weber Date: Mon, 20 Jan 2014 12:53:27 -0600 Subject: [PATCH 04/14] version bump, closes #36 --- addon.xml | 2 +- changelog.txt | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/addon.xml b/addon.xml index a3cc899..5125569 100644 --- a/addon.xml +++ b/addon.xml @@ -1,6 +1,6 @@  + name="XBMC Backup" version="0.5.1" provider-name="robweber"> diff --git a/changelog.txt b/changelog.txt index 38ff1a7..3ed5904 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,7 @@ +Version 0.5.1 + +updated for new Gotham xbmc python updates + Version 0.5.0 New Version for Gotham From b0b611b5c991db83aff59a416c873e0fbc8c8b1e Mon Sep 17 00:00:00 2001 From: Rob Weber Date: Mon, 20 Jan 2014 13:04:50 -0600 Subject: [PATCH 05/14] added version info to logs --- resources/lib/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/lib/utils.py b/resources/lib/utils.py index 3f317a9..d351800 100644 --- a/resources/lib/utils.py +++ b/resources/lib/utils.py @@ -15,7 +15,7 @@ def openSettings(): __Addon.openSettings() def log(message,loglevel=xbmc.LOGNOTICE): - xbmc.log(encode(__addon_id__ + ": " + message),level=loglevel) + xbmc.log(encode(__addon_id__ + "-" + __Addon.getAddonInfo('version') + ": " + message),level=loglevel) def showNotification(message): xbmcgui.Dialog().notification(encode(getString(30010)),encode(message),time=4000,icon=xbmc.translatePath(__Addon.getAddonInfo('path') + "/icon.png")) From aec7d19b0099cad10d995b911e834cfa4788f5df Mon Sep 17 00:00:00 2001 From: Rob Weber Date: Mon, 20 Jan 2014 13:05:09 -0600 Subject: [PATCH 06/14] changelog update --- changelog.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/changelog.txt b/changelog.txt index 3ed5904..0d3111c 100644 --- a/changelog.txt +++ b/changelog.txt @@ -2,6 +2,8 @@ Version 0.5.1 updated for new Gotham xbmc python updates +added version info to logs + Version 0.5.0 New Version for Gotham From 542bc692d9fa05aa9a75679c0ac0c52573864dae Mon Sep 17 00:00:00 2001 From: Rob Weber Date: Sun, 9 Feb 2014 14:03:51 -0600 Subject: [PATCH 07/14] bump xbmc python version --- addon.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addon.xml b/addon.xml index 5125569..a49884d 100644 --- a/addon.xml +++ b/addon.xml @@ -2,7 +2,7 @@ - + executable From 43126250038e037de2809a630bfb4405fa87d74e Mon Sep 17 00:00:00 2001 From: "robweberjr@gmail.com" Date: Mon, 17 Mar 2014 13:11:49 -0500 Subject: [PATCH 08/14] updated README.txt --- README.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.txt b/README.txt index 4b345e3..ad5ec8b 100644 --- a/README.txt +++ b/README.txt @@ -6,7 +6,7 @@ I've had to recover my database, thumbnails, and source configuration enough tim Remote Destination/File Selection: -In the addon settings you can define a remote path for the destination of your xbmc files. Each backup will create a folder named in a YYYYMMDD format so you can create multiple backups. You can keep a set number of backups by setting the integer value of the Backups to Keep setting greater than 0. +In the addon settings you can define a remote path for the destination of your xbmc files. Each backup will create a folder named in a YYYYMMDDHHmm format so you can create multiple backups. You can keep a set number of backups by setting the integer value of the Backups to Keep setting greater than 0. On the Backup Selection page you can select which items from your user profile folder will be sent to the backup location. By default all are turned on except the Addon Data directory. From 7f42129606734bd6a94454700d33cfae81741d76 Mon Sep 17 00:00:00 2001 From: "robweberjr@gmail.com" Date: Tue, 18 Mar 2014 13:48:53 -0500 Subject: [PATCH 09/14] added home window properties --- resources/lib/backup.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/resources/lib/backup.py b/resources/lib/backup.py index 771c9c8..374ce49 100644 --- a/resources/lib/backup.py +++ b/resources/lib/backup.py @@ -90,6 +90,10 @@ class XbmcBackup: self.skip_advanced = True def run(self,mode=-1,progressOverride=False): + #set windows setting to true + window = xbmcgui.Window(10000) + window.setProperty(utils.__addon_id__ + ".running","true") + #append backup folder name progressBarTitle = utils.getString(30010) + " - " if(mode == self.Backup and self.remote_vfs.root_path != ''): @@ -323,6 +327,9 @@ class XbmcBackup: if(self.progressBar != None): self.progressBar.close() + #reset the window setting + window.setProperty(utils.__addon_id__ + ".running","") + def backupFiles(self,fileList,source,dest): utils.log("Writing files to: " + dest.root_path) utils.log("Source: " + source.root_path) From 450687ba5dc8b22d666625c9798935a29527e958 Mon Sep 17 00:00:00 2001 From: NEOhidra Date: Sun, 23 Mar 2014 10:28:32 +0200 Subject: [PATCH 10/14] updated Bulgarian translation --- addon.xml | 2 + resources/language/Bulgarian/strings.xml | 67 ++++++++++++++++++++++-- 2 files changed, 66 insertions(+), 3 deletions(-) diff --git a/addon.xml b/addon.xml index a49884d..99650cf 100644 --- a/addon.xml +++ b/addon.xml @@ -11,6 +11,7 @@ قم بنسخ احتياطي و استعد قاعدة بيانات XBMC الخاص بك و ملفات التكوين في حال وقوع حادث أو تلف الملفات. Backup and restore your XBMC database and configuration files in the event of a crash or file corruption. + Добавката може да създава резервно копие на XBMC и възстановява (след това) Вашата база от данни и настройки, в случай на необходимост. Copiau i restaurau la vostra base de dades d'XBMC i els fitxers de configuració en cas de caiguda o corrupció de fitxers. Sikkerhedskopiér og genskab din XBMC database og konfigurationsfiler i tilfælde af et nedbrud eller en ødelagt fil. Die XBMC Datenbank sichern und bei Dateiverlust oder Beschädigung wiederherstellen. @@ -36,6 +37,7 @@ Ta backupp av eller återställ din XBMC-databas och konfigurationsfiler i händelse av en krash eller filkorruption. 备份和恢复XBMC数据库和配置文件,以防范系统崩溃或文件损坏问题。 Ever hosed your XBMC configuration and wished you'd had a backup? Now you can with one easy click. You can export your database, playlist, thumbnails, addons and other configuration details to any source writeable by XBMC or directly to Dropbox cloud storage. Backups can be run on demand or via a scheduler. + Някога да сте губили всички настройки, които сте правили по XBMC? А разполагахте ли с резервно копие? Е сега можете да създавате резервни копия само с едно кликване. Можете да изнасяте базата от данни, плейлистите, миниатюрите, добавките и други, на всяко място до което XBMC има права за писане или директно в Dropbox. Можете да настроите и автоматично създаване на копия през определен интервал от време. Sempre canvia la configuració XBMC i ha desitjat tinir una còpia de seguretat? Ara pot fer-ho amb un simple clic. Podeu exportar la seva base de dades, llista de reproducció, miniatures, complements i altres detalls de la configuració per a qualsevol complement de XBMC o directament emmagatzemar-ho al Dropbox en el núvol. Les còpies de seguretat es poden executar a la demanda o per mitjà d'un planificador. Har du prøvet at slette din XBMC opsætning, og ønsket at du havde haft sikkerhedskopi? Nu kan du få det med et enkelt klik. Du kan eksportere din database, afspilninglister, miniaturebilleder, addons og andre opsætningsdetaljer til enhver kilde, som er skrivbar for XBMC eller direkt til Dropbox cloud lager. Sikkerhedskopier kan køres manuelt eller via en tidsplan. Jemals deine XBMC Konfiguration zerschossen und dir dann gewünscht, dass ein Backup existiert? Jetzt kannst du eine Sicherung mit nur einem Klick erzeugen. Du kannst deine Datenbanen, Playlisten, Thumbnails, Addons und andere Details zu einem Ort deiner Wahl sichern. diff --git a/resources/language/Bulgarian/strings.xml b/resources/language/Bulgarian/strings.xml index fd27425..fd23b73 100644 --- a/resources/language/Bulgarian/strings.xml +++ b/resources/language/Bulgarian/strings.xml @@ -4,10 +4,58 @@ - General + XBMC Backup + Основи + Избор на файлове + Планиране + Резервно копие + Възстанови + Преглеждане за път + Въвеждане на път + Прегледайте + Име на папката за резервните копия + Известяване за напредъка Режим - База от данни - Плейлист + Въведете отдалечения път + Окажете пътя до папката с резервни копия + Колко резервни копия да бъдат съхранявани (0 за всички) + Dropbox + Dropbox ключ + Dropbox секретен ключ + Добавки + Данните на добавките + Базата данни + Плейлисти + Миниатюри/Фанарт + Файловете с настройки + Персонална директория №1 + Персонална директория №2 + Засечени са допълнителни настройки + Необходимо е първо възстановяване на файла "advancedsettings.xml" + Изберете "Да" за възстановяване от файла и рестартиране на XBMC + Изберете "Не" за да продължите + Възобнови + XBMC Backup засече незавършено възстановяване + Искате ли да продължите? + Грешка: Отдалеченият път не съществува + Стартиране + Локална папка + Отдалечена папка + Изграждане на списък с файлове + Отдалеченият път съществува. Вероятно съдържа стари файлове! + Създаване на списъка с файлове + Записване на файла + Създаване на резервно копие (по план) + Премахване на резервно копие + За оторизационния URL адрес за Dropbox проверете дневника + След оторизирането натиснете "Добре" + Необходим е код за разработчик за Dropbox + Посетете https://www.dropbox.com/developers + Активирай планировчика + Планиране + Час + Ден + Cron планиране неделя понеделник вторник @@ -15,4 +63,17 @@ четвъртък петък събота + Всеки ден + Всяка седмица + Първия ден на месеца + Персонално планиране + Изключвай XBMC след създаването на резервно копиране + Рестартиране на XBMC + Необходимо е да рестартирате XBMC за да продължите + Само днес + Профили + Планировчика ще стартира отново на + Лента за напредъка + Лента за напредъка на заден план + Без (тих режим) From a09677930f069b3397f14bd3eb7f0339775f28f7 Mon Sep 17 00:00:00 2001 From: "robweberjr@gmail.com" Date: Mon, 31 Mar 2014 09:14:28 -0500 Subject: [PATCH 11/14] removed redundant log message --- scheduler.py | 1 - 1 file changed, 1 deletion(-) diff --git a/scheduler.py b/scheduler.py index 39b23b9..4b978b5 100644 --- a/scheduler.py +++ b/scheduler.py @@ -25,7 +25,6 @@ class BackupScheduler: #scheduler was turned on, find next run time utils.log("scheduler enabled, finding next run time") self.findNextRun(time.time()) - utils.log("scheduler will run again on " + datetime.datetime.fromtimestamp(self.next_run).strftime('%m-%d-%Y %H:%M')) def start(self): From 37fb30d7ab30ece842b733ac8f0482b46f5446df Mon Sep 17 00:00:00 2001 From: "robweberjr@gmail.com" Date: Mon, 31 Mar 2014 11:54:11 -0500 Subject: [PATCH 12/14] allow sending of "archive" parameter for restores --- default.py | 47 +++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 39 insertions(+), 8 deletions(-) diff --git a/default.py b/default.py index b2bd2ad..a682c8a 100644 --- a/default.py +++ b/default.py @@ -1,21 +1,37 @@ +import urlparse import xbmcgui import resources.lib.utils as utils from resources.lib.backup import XbmcBackup +def get_params(): + param = {} + + if(len(sys.argv) > 1): + for i in sys.argv: + args = i + if(args.startswith('?')): + args = args[1:] + param.update(dict(urlparse.parse_qsl(args))) + + return param + #the program mode mode = -1 +params = get_params() -#check if mode was passed in as an argument -if(len(sys.argv) > 1): - if(sys.argv[1].lower() == 'backup'): + +if("mode" in params): + if(params['mode'] == 'backup'): mode = 0 - elif(sys.argv[1].lower() == 'restore'): + elif(params['mode'] == 'restore'): mode = 1 +#if mode wasn't passed in as arg, get from user if(mode == -1): #figure out if this is a backup or a restore from the user mode = xbmcgui.Dialog().select(utils.getString(30010) + " - " + utils.getString(30023),[utils.getString(30016),utils.getString(30017)]) +#check if program should be run if(mode != -1): #run the profile backup backup = XbmcBackup() @@ -23,14 +39,29 @@ if(mode != -1): if(backup.remoteConfigured()): if(mode == backup.Restore): - #allow user to select the backup to restore from + #get list of valid restore points restorePoints = backup.listBackups() pointNames = [] - + folderNames = [] + for aDir in restorePoints: pointNames.append(aDir[1]) - - selectedRestore = xbmcgui.Dialog().select(utils.getString(30010) + " - " + utils.getString(30021),pointNames) + folderNames.append(aDir[0]) + + selectedRestore = -1 + + if("archive" in params): + #check that the user give archive exists + if(params['archive'] in folderNames): + #set the index + selectedRestore = folderNames.index(params['archive']) + utils.log(str(selectedRestore) + " : " + params['archive']) + else: + utils.showNotification(utils.getString(30045)) + utils.log(params['archive'] + ' is not a valid restore point') + else: + #allow user to select the backup to restore from + selectedRestore = xbmcgui.Dialog().select(utils.getString(30010) + " - " + utils.getString(30021),pointNames) if(selectedRestore != -1): backup.selectRestore(restorePoints[selectedRestore][0]) From 35c17176998308d3a13a15e9e418894e6a910e36 Mon Sep 17 00:00:00 2001 From: "robweberjr@gmail.com" Date: Mon, 31 Mar 2014 12:05:44 -0500 Subject: [PATCH 13/14] Version bump and README.txt --- README.txt | 31 +++++++++++++++++++++++++++++-- addon.xml | 2 +- changelog.txt | 4 ++++ 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/README.txt b/README.txt index ad5ec8b..9d57199 100644 --- a/README.txt +++ b/README.txt @@ -37,11 +37,38 @@ Once you have your app key and secret add them to the settings. XBMC Backup now Scripting XBMC Backup: -If you wish to script this addon using an outside scheduler or script it can be given parameters via the Xbmc.RunScript() or JsonRPC.Addons.ExecuteAddon() methods. Parameters given are either "backup" or "restore" to launch the correct program mode. An example would be: +If you wish to script this addon using an outside scheduler or script it can be given parameters via the Xbmc.RunScript() or JsonRPC.Addons.ExecuteAddon() methods. Parameters given are either "backup" or "restore" to launch the correct program mode. If mode is "restore", an additional "archive" parameter can be given to set the restore point to be used instead of prompting via the GUI. An example would be: -RunScript(script.xbmcbackup,backup) +Python code: +------------------------------------------- +RunScript(script.xbmcbackup,mode=backup) +------------------------------------------- +or +JSON Request: +------------------------------------------- +{ "jsonrpc": "2.0", "method": "Addons.ExecuteAddon","params":{"addonid":"script.xbmcbackup","params":{"mode":"restore","archive":"000000000000"}}, "id": 1 } +------------------------------------------- + +There is also a windows parameter that can be used to check if XBMC Backup is running within a skin or from another program. It is attached to the home window, an example of using it would be the following: + +Python code: +------------------------------------------- +#kick off the xbmc backup +xbmc.executeJSONRPC('{ "jsonrpc": "2.0", "method": "Addons.ExecuteAddon","params":{"addonid":"script.xbmcbackup","params":{"mode":"backup"}}, "id": 1 }') + +#sleep for a few seconds to give it time to kick off +xbmc.sleep(10000) + +window = xbmcgui.Window(10000) + +while (window.getProperty('script.xbmcbackup.running') == 'true'): + #do something here, probably just sleep for a few seconds + xbmc.sleep(5000) + +#backup is now done, continue with script +------------------------------------------- FAQ: I can't see any restore points when choosing "Restore", what is the problem? diff --git a/addon.xml b/addon.xml index 99650cf..9a80d74 100644 --- a/addon.xml +++ b/addon.xml @@ -1,6 +1,6 @@  + name="XBMC Backup" version="0.5.2" provider-name="robweber"> diff --git a/changelog.txt b/changelog.txt index b18e08b..0df5a9e 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,7 @@ +Version 0.5.2 + +added additional script and window parameters, thanks Samu-rai + Version 0.5.1 updated for new Gotham xbmc python updates From 290446c3a8e9cbf6ee4f3e067b534af97623a685 Mon Sep 17 00:00:00 2001 From: "robweberjr@gmail.com" Date: Mon, 31 Mar 2014 12:37:11 -0500 Subject: [PATCH 14/14] fixed error in backup rotation --- changelog.txt | 2 ++ resources/lib/backup.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/changelog.txt b/changelog.txt index 0df5a9e..5cf53f4 100644 --- a/changelog.txt +++ b/changelog.txt @@ -2,6 +2,8 @@ Version 0.5.2 added additional script and window parameters, thanks Samu-rai +critical error in backup rotation + Version 0.5.1 updated for new Gotham xbmc python updates diff --git a/resources/lib/backup.py b/resources/lib/backup.py index 374ce49..061fcef 100644 --- a/resources/lib/backup.py +++ b/resources/lib/backup.py @@ -390,7 +390,7 @@ class XbmcBackup: self.filesTotal = self.filesTotal + remove_num + 1 #update the progress bar if it is available - while(remove_num < total_backups and not self._checkCancel()): + while(remove_num < (len(dirs) - total_backups) and not self._checkCancel()): self._updateProgress(utils.getString(30054) + " " + dirs[remove_num][1]) utils.log("Removing backup " + dirs[remove_num][0]) self.remote_vfs.rmdir(self.remote_base_path + dirs[remove_num][0] + "/")