2014-03-31 18:54:11 +02:00
|
|
|
import urlparse
|
2012-11-28 15:54:23 +01:00
|
|
|
import xbmcgui
|
|
|
|
import resources.lib.utils as utils
|
2012-09-05 21:28:43 +02:00
|
|
|
from resources.lib.backup import XbmcBackup
|
2012-08-17 21:18:08 +02:00
|
|
|
|
2014-03-31 18:54:11 +02:00
|
|
|
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
|
|
|
|
|
2013-01-04 17:29:00 +01:00
|
|
|
#the program mode
|
|
|
|
mode = -1
|
2014-03-31 18:54:11 +02:00
|
|
|
params = get_params()
|
|
|
|
|
2013-01-04 17:29:00 +01:00
|
|
|
|
2014-03-31 18:54:11 +02:00
|
|
|
if("mode" in params):
|
|
|
|
if(params['mode'] == 'backup'):
|
2013-01-04 17:29:00 +01:00
|
|
|
mode = 0
|
2014-03-31 18:54:11 +02:00
|
|
|
elif(params['mode'] == 'restore'):
|
2013-01-04 17:29:00 +01:00
|
|
|
mode = 1
|
|
|
|
|
2014-03-31 18:54:11 +02:00
|
|
|
#if mode wasn't passed in as arg, get from user
|
2013-01-04 17:29:00 +01:00
|
|
|
if(mode == -1):
|
|
|
|
#figure out if this is a backup or a restore from the user
|
2015-05-09 02:40:28 +02:00
|
|
|
mode = xbmcgui.Dialog().select(utils.getString(30010) + " - " + utils.getString(30023),[utils.getString(30016),utils.getString(30017),utils.getString(30099)])
|
2012-04-19 23:13:50 +02:00
|
|
|
|
2014-03-31 18:54:11 +02:00
|
|
|
#check if program should be run
|
2012-11-28 15:54:23 +01:00
|
|
|
if(mode != -1):
|
|
|
|
#run the profile backup
|
|
|
|
backup = XbmcBackup()
|
2012-11-28 17:19:03 +01:00
|
|
|
|
2015-05-09 02:40:28 +02:00
|
|
|
if(mode == 2):
|
|
|
|
#open the settings dialog
|
|
|
|
utils.openSettings()
|
|
|
|
|
|
|
|
elif(backup.remoteConfigured()):
|
2012-11-28 17:19:03 +01:00
|
|
|
|
2013-12-05 21:26:35 +01:00
|
|
|
if(mode == backup.Restore):
|
2014-03-31 18:54:11 +02:00
|
|
|
#get list of valid restore points
|
2013-12-05 21:26:35 +01:00
|
|
|
restorePoints = backup.listBackups()
|
2014-02-09 20:56:25 +01:00
|
|
|
pointNames = []
|
2014-03-31 18:54:11 +02:00
|
|
|
folderNames = []
|
|
|
|
|
2014-02-09 20:56:25 +01:00
|
|
|
for aDir in restorePoints:
|
|
|
|
pointNames.append(aDir[1])
|
2014-03-31 18:54:11 +02:00
|
|
|
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)
|
2013-12-05 21:26:35 +01:00
|
|
|
|
|
|
|
if(selectedRestore != -1):
|
2014-02-09 20:56:25 +01:00
|
|
|
backup.selectRestore(restorePoints[selectedRestore][0])
|
2012-11-28 17:19:03 +01:00
|
|
|
|
2013-12-05 21:26:35 +01:00
|
|
|
backup.run(mode)
|
|
|
|
else:
|
|
|
|
#can't go any further
|
|
|
|
xbmcgui.Dialog().ok(utils.getString(30010),utils.getString(30045))
|
|
|
|
utils.openSettings()
|