From 3602bb5b6a2de61ec3b5d24e146d40f67ad28965 Mon Sep 17 00:00:00 2001 From: Rob Weber Date: Wed, 28 Nov 2012 11:22:02 -0600 Subject: [PATCH] added gui changes to be similar to Frodo branch --- addon.xml | 2 +- changelog.txt | 4 ++++ default.py | 22 ++++++++++++++++++---- resources/.gitignore | 2 ++ resources/lib/backup.py | 39 +++++++++++++++++++++++++++------------ resources/settings.xml | 2 -- 6 files changed, 52 insertions(+), 19 deletions(-) create mode 100644 resources/.gitignore diff --git a/addon.xml b/addon.xml index 616932a..a982a17 100644 --- a/addon.xml +++ b/addon.xml @@ -1,6 +1,6 @@  + name="XBMC Backup" version="0.1.9" provider-name="robweber"> diff --git a/changelog.txt b/changelog.txt index 49511c5..60e1955 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,7 @@ +Version 0.1.9 + +added GUI changes to emulate Frodo look + Version 0.1.8 moved eden to new branch, frodo is now master diff --git a/default.py b/default.py index 8676e8b..0c1e9cf 100644 --- a/default.py +++ b/default.py @@ -1,7 +1,21 @@ +import xbmcgui +import resources.lib.utils as utils from resources.lib.backup import XbmcBackup -#run the profile backup -backup = XbmcBackup() +#figure out if this is a backup or a restore +mode = xbmcgui.Dialog().select(utils.getString(30010) + " - " + utils.getString(30023),[utils.getString(30016),utils.getString(30017)]) -if(backup.isReady()): - backup.run() +if(mode != -1): + #run the profile backup + backup = XbmcBackup() + + if(mode == backup.Restore): + #allow user to select the backup to restore from + restorePoints = backup.listBackups() + + selectedRestore = xbmcgui.Dialog().select(utils.getString(30010) + " - " + utils.getString(30021),restorePoints) + + if(selectedRestore != -1): + backup.selectRestore(restorePoints[selectedRestore]) + + backup.run(mode) diff --git a/resources/.gitignore b/resources/.gitignore new file mode 100644 index 0000000..696f993 --- /dev/null +++ b/resources/.gitignore @@ -0,0 +1,2 @@ + +*.pyo \ No newline at end of file diff --git a/resources/lib/backup.py b/resources/lib/backup.py index 149904d..0d84ca9 100644 --- a/resources/lib/backup.py +++ b/resources/lib/backup.py @@ -87,6 +87,7 @@ class XbmcBackup: filesTotal = 1 fileManager = None + restore_point = None def __init__(self): self.local_path = xbmc.makeLegalFilename(xbmc.translatePath("special://home"),False); @@ -106,27 +107,43 @@ class XbmcBackup: utils.log(utils.getString(30046)) - def run(self,mode=-1,runSilent=False): - #check if we should use the progress bar - if(utils.getSetting('run_silent') == 'false' and not runSilent): - self.progressBar = xbmcgui.DialogProgress() - self.progressBar.create(utils.getString(30010),utils.getString(30049) + "......") + def listBackups(self): + result = list() - #determine backup mode - if(mode == -1): - mode = int(utils.getSetting('addon_mode')) + #get all the folders in the current root path + dirs = vfs.listdir(self.remote_path) + + for aDir in dirs: + result.append(aDir[len(self.remote_path):-1]) + + return result + + def selectRestore(self,restore_point): + self.restore_point = restore_point + + def run(self,mode=-1,runSilent=False): #append backup folder name + progressBarTitle = utils.getString(30010) + " - " if(mode == self.Backup and self.remote_path != ''): self.remote_path = self.remote_path + time.strftime("%Y%m%d") + "/" - elif(mode == self.Restore and utils.getSetting("backup_name") != '' and self.remote_path != ''): - self.remote_path = self.remote_path + utils.getSetting("backup_name") + "/" + progressBarTitle = progressBarTitle + utils.getString(30016) + elif(mode == self.Restore and self.restore_point != None and self.remote_path != ''): + self.remote_path = self.remote_path + self.restore_point + "/" + progressBarTitle = progressBarTitle + utils.getString(30017) else: + #kill the program here self.remote_path = "" + return utils.log(utils.getString(30047) + ": " + self.local_path) utils.log(utils.getString(30048) + ": " + self.remote_path) + #check if we should use the progress bar + if(utils.getSetting('run_silent') == 'false' and not runSilent): + self.progressBar = xbmcgui.DialogProgress() + self.progressBar.create(progressBarTitle,utils.getString(30049) + "......") + #run the correct mode if(mode == self.Backup): utils.log(utils.getString(30023) + " - " + utils.getString(30016)) @@ -206,5 +223,3 @@ class XbmcBackup: return result - def isReady(self): - return True if self.remote_path != '' else False diff --git a/resources/settings.xml b/resources/settings.xml index d32a629..a3b700b 100644 --- a/resources/settings.xml +++ b/resources/settings.xml @@ -1,11 +1,9 @@ - -