mirror of
https://github.com/robweber/xbmcbackup.git
synced 2024-11-14 20:35:48 +01:00
allow sending of "archive" parameter for restores
This commit is contained in:
parent
7f42129606
commit
37fb30d7ab
47
default.py
47
default.py
@ -1,21 +1,37 @@
|
|||||||
|
import urlparse
|
||||||
import xbmcgui
|
import xbmcgui
|
||||||
import resources.lib.utils as utils
|
import resources.lib.utils as utils
|
||||||
from resources.lib.backup import XbmcBackup
|
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
|
#the program mode
|
||||||
mode = -1
|
mode = -1
|
||||||
|
params = get_params()
|
||||||
|
|
||||||
#check if mode was passed in as an argument
|
|
||||||
if(len(sys.argv) > 1):
|
if("mode" in params):
|
||||||
if(sys.argv[1].lower() == 'backup'):
|
if(params['mode'] == 'backup'):
|
||||||
mode = 0
|
mode = 0
|
||||||
elif(sys.argv[1].lower() == 'restore'):
|
elif(params['mode'] == 'restore'):
|
||||||
mode = 1
|
mode = 1
|
||||||
|
|
||||||
|
#if mode wasn't passed in as arg, get from user
|
||||||
if(mode == -1):
|
if(mode == -1):
|
||||||
#figure out if this is a backup or a restore from the user
|
#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)])
|
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):
|
if(mode != -1):
|
||||||
#run the profile backup
|
#run the profile backup
|
||||||
backup = XbmcBackup()
|
backup = XbmcBackup()
|
||||||
@ -23,14 +39,29 @@ if(mode != -1):
|
|||||||
if(backup.remoteConfigured()):
|
if(backup.remoteConfigured()):
|
||||||
|
|
||||||
if(mode == backup.Restore):
|
if(mode == backup.Restore):
|
||||||
#allow user to select the backup to restore from
|
#get list of valid restore points
|
||||||
restorePoints = backup.listBackups()
|
restorePoints = backup.listBackups()
|
||||||
pointNames = []
|
pointNames = []
|
||||||
|
folderNames = []
|
||||||
|
|
||||||
for aDir in restorePoints:
|
for aDir in restorePoints:
|
||||||
pointNames.append(aDir[1])
|
pointNames.append(aDir[1])
|
||||||
|
folderNames.append(aDir[0])
|
||||||
selectedRestore = xbmcgui.Dialog().select(utils.getString(30010) + " - " + utils.getString(30021),pointNames)
|
|
||||||
|
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):
|
if(selectedRestore != -1):
|
||||||
backup.selectRestore(restorePoints[selectedRestore][0])
|
backup.selectRestore(restorePoints[selectedRestore][0])
|
||||||
|
Loading…
Reference in New Issue
Block a user