mirror of
https://github.com/robweber/xbmcbackup.git
synced 2024-11-15 04:45:49 +01:00
Launcher (#189)
* move launcher code to default.py, modify RunScript in settings
This commit is contained in:
parent
d71c923e78
commit
4b066432be
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
<addon id="script.xbmcbackup"
|
<addon id="script.xbmcbackup"
|
||||||
name="Backup" version="1.6.6" provider-name="robweber">
|
name="Backup" version="1.6.7~beta1" provider-name="robweber">
|
||||||
<requires>
|
<requires>
|
||||||
<import addon="xbmc.python" version="3.0.0"/>
|
<import addon="xbmc.python" version="3.0.0"/>
|
||||||
<import addon="script.module.dateutil" version="2.8.0" />
|
<import addon="script.module.dateutil" version="2.8.0" />
|
||||||
@ -89,8 +89,8 @@
|
|||||||
<screenshot>resources/images/screenshot3.jpg</screenshot>
|
<screenshot>resources/images/screenshot3.jpg</screenshot>
|
||||||
<screenshot>resources/images/screenshot4.jpg</screenshot>
|
<screenshot>resources/images/screenshot4.jpg</screenshot>
|
||||||
</assets>
|
</assets>
|
||||||
<news>Version 1.6.6
|
<news>Version 1.6.7
|
||||||
- fixed issue with backup rotations not working properly
|
- fixed issue with RunScript not launching Advanced Editor in some cases
|
||||||
</news>
|
</news>
|
||||||
</extension>
|
</extension>
|
||||||
</addon>
|
</addon>
|
||||||
|
@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
|
|||||||
|
|
||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
||||||
|
|
||||||
|
## [Unreleased](https://github.com/robweber/xbmcbackup/compare/matrix-1.6.5...robweber:matrix)
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- fixed issue when using ```RunScript()``` within settings to launch Advanced Editor
|
||||||
|
|
||||||
## [Version 1.6.6](https://github.com/robweber/xbmcbackup/compare/matrix-1.6.5...robweber:matrix-1.6.6) - 2020-03-15
|
## [Version 1.6.6](https://github.com/robweber/xbmcbackup/compare/matrix-1.6.5...robweber:matrix-1.6.6) - 2020-03-15
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
66
default.py
66
default.py
@ -1,7 +1,37 @@
|
|||||||
import xbmc
|
|
||||||
import xbmcgui
|
import xbmcgui
|
||||||
|
import xbmcvfs
|
||||||
import resources.lib.utils as utils
|
import resources.lib.utils as utils
|
||||||
from resources.lib.backup import XbmcBackup
|
from resources.lib.backup import XbmcBackup
|
||||||
|
from resources.lib.authorizers import DropboxAuthorizer
|
||||||
|
from resources.lib.advanced_editor import AdvancedBackupEditor
|
||||||
|
|
||||||
|
# mode constants
|
||||||
|
BACKUP = 0
|
||||||
|
RESTORE = 1
|
||||||
|
SETTINGS = 2
|
||||||
|
ADVANCED_EDITOR = 3
|
||||||
|
LAUNCHER = 4
|
||||||
|
|
||||||
|
|
||||||
|
def authorize_cloud(cloudProvider):
|
||||||
|
# drobpox
|
||||||
|
if(cloudProvider == 'dropbox'):
|
||||||
|
authorizer = DropboxAuthorizer()
|
||||||
|
|
||||||
|
if(authorizer.authorize()):
|
||||||
|
xbmcgui.Dialog().ok(utils.getString(30010), '%s %s' % (utils.getString(30027), utils.getString(30106)))
|
||||||
|
else:
|
||||||
|
xbmcgui.Dialog().ok(utils.getString(30010), '%s %s' % (utils.getString(30107), utils.getString(30027)))
|
||||||
|
|
||||||
|
|
||||||
|
def remove_auth():
|
||||||
|
# triggered from settings.xml - asks if user wants to delete OAuth token information
|
||||||
|
shouldDelete = xbmcgui.Dialog().yesno(utils.getString(30093), utils.getString(30094), utils.getString(30095), autoclose=7000)
|
||||||
|
|
||||||
|
if(shouldDelete):
|
||||||
|
# delete any of the known token file types
|
||||||
|
xbmcvfs.delete(xbmcvfs.translatePath(utils.data_dir() + "tokens.txt")) # dropbox
|
||||||
|
xbmcvfs.delete(xbmcvfs.translatePath(utils.data_dir() + "google_drive.dat")) # google drive
|
||||||
|
|
||||||
|
|
||||||
def get_params():
|
def get_params():
|
||||||
@ -13,6 +43,7 @@ def get_params():
|
|||||||
if(args.startswith('?')):
|
if(args.startswith('?')):
|
||||||
args = args[1:] # legacy in case of url params
|
args = args[1:] # legacy in case of url params
|
||||||
splitString = args.split('=')
|
splitString = args.split('=')
|
||||||
|
utils.log(splitString[1])
|
||||||
param[splitString[0]] = splitString[1]
|
param[splitString[0]] = splitString[1]
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
@ -24,12 +55,13 @@ def get_params():
|
|||||||
mode = -1
|
mode = -1
|
||||||
params = get_params()
|
params = get_params()
|
||||||
|
|
||||||
|
|
||||||
if("mode" in params):
|
if("mode" in params):
|
||||||
if(params['mode'] == 'backup'):
|
if(params['mode'] == 'backup'):
|
||||||
mode = 0
|
mode = BACKUP
|
||||||
elif(params['mode'] == 'restore'):
|
elif(params['mode'] == 'restore'):
|
||||||
mode = 1
|
mode = RESTORE
|
||||||
|
elif(params['mode'] == 'launcher'):
|
||||||
|
mode = LAUNCHER
|
||||||
|
|
||||||
|
|
||||||
# if mode wasn't passed in as arg, get from user
|
# if mode wasn't passed in as arg, get from user
|
||||||
@ -49,15 +81,30 @@ if(mode != -1):
|
|||||||
# run the profile backup
|
# run the profile backup
|
||||||
backup = XbmcBackup()
|
backup = XbmcBackup()
|
||||||
|
|
||||||
if(mode == 2):
|
if(mode == SETTINGS):
|
||||||
# open the settings dialog
|
# open the settings dialog
|
||||||
utils.openSettings()
|
utils.openSettings()
|
||||||
elif(mode == 3 and utils.getSettingInt('backup_selection_type') == 1):
|
elif(mode == ADVANCED_EDITOR and utils.getSettingInt('backup_selection_type') == 1):
|
||||||
# open the advanced editor
|
# open the advanced editor but only if in advanced mode
|
||||||
xbmc.executebuiltin('RunScript(special://home/addons/script.xbmcbackup/launcher.py, action=advanced_editor)')
|
editor = AdvancedBackupEditor()
|
||||||
|
editor.showMainScreen()
|
||||||
|
elif(mode == LAUNCHER):
|
||||||
|
# copied from old launcher.py
|
||||||
|
if(params['action'] == 'authorize_cloud'):
|
||||||
|
authorize_cloud(params['provider'])
|
||||||
|
elif(params['action'] == 'remove_auth'):
|
||||||
|
remove_auth()
|
||||||
|
elif(params['action'] == 'advanced_editor'):
|
||||||
|
editor = AdvancedBackupEditor()
|
||||||
|
editor.showMainScreen()
|
||||||
|
elif(params['action'] == 'advanced_copy_config'):
|
||||||
|
editor = AdvancedBackupEditor()
|
||||||
|
editor.copySimpleConfig()
|
||||||
|
|
||||||
elif(backup.remoteConfigured()):
|
elif(backup.remoteConfigured()):
|
||||||
|
|
||||||
if(mode == backup.Restore):
|
# if mode was RESTORE
|
||||||
|
if(mode == RESTORE):
|
||||||
# get list of valid restore points
|
# get list of valid restore points
|
||||||
restorePoints = backup.listBackups()
|
restorePoints = backup.listBackups()
|
||||||
pointNames = []
|
pointNames = []
|
||||||
@ -90,6 +137,7 @@ if(mode != -1):
|
|||||||
else:
|
else:
|
||||||
backup.restore()
|
backup.restore()
|
||||||
else:
|
else:
|
||||||
|
# mode was BACKUP
|
||||||
backup.backup()
|
backup.backup()
|
||||||
else:
|
else:
|
||||||
# can't go any further
|
# can't go any further
|
||||||
|
58
launcher.py
58
launcher.py
@ -1,58 +0,0 @@
|
|||||||
# launcher for various helpful functions found in the settings.xml area
|
|
||||||
import sys
|
|
||||||
import xbmcgui
|
|
||||||
import xbmcvfs
|
|
||||||
import resources.lib.utils as utils
|
|
||||||
from resources.lib.authorizers import DropboxAuthorizer
|
|
||||||
from resources.lib.advanced_editor import AdvancedBackupEditor
|
|
||||||
|
|
||||||
|
|
||||||
def authorize_cloud(cloudProvider):
|
|
||||||
# drobpox
|
|
||||||
if(cloudProvider == 'dropbox'):
|
|
||||||
authorizer = DropboxAuthorizer()
|
|
||||||
|
|
||||||
if(authorizer.authorize()):
|
|
||||||
xbmcgui.Dialog().ok(utils.getString(30010), '%s %s' % (utils.getString(30027), utils.getString(30106)))
|
|
||||||
else:
|
|
||||||
xbmcgui.Dialog().ok(utils.getString(30010), '%s %s' % (utils.getString(30107), utils.getString(30027)))
|
|
||||||
|
|
||||||
|
|
||||||
def remove_auth():
|
|
||||||
# triggered from settings.xml - asks if user wants to delete OAuth token information
|
|
||||||
shouldDelete = xbmcgui.Dialog().yesno(utils.getString(30093), utils.getString(30094), utils.getString(30095), autoclose=7000)
|
|
||||||
|
|
||||||
if(shouldDelete):
|
|
||||||
# delete any of the known token file types
|
|
||||||
xbmcvfs.delete(xbmcvfs.translatePath(utils.data_dir() + "tokens.txt")) # dropbox
|
|
||||||
xbmcvfs.delete(xbmcvfs.translatePath(utils.data_dir() + "google_drive.dat")) # google drive
|
|
||||||
|
|
||||||
|
|
||||||
def get_params():
|
|
||||||
param = {}
|
|
||||||
try:
|
|
||||||
for i in sys.argv:
|
|
||||||
args = i
|
|
||||||
if('=' in args):
|
|
||||||
if(args.startswith('?')):
|
|
||||||
args = args[1:] # legacy in case of url params
|
|
||||||
splitString = args.split('=')
|
|
||||||
param[splitString[0]] = splitString[1]
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
return param
|
|
||||||
|
|
||||||
|
|
||||||
params = get_params()
|
|
||||||
|
|
||||||
if(params['action'] == 'authorize_cloud'):
|
|
||||||
authorize_cloud(params['provider'])
|
|
||||||
elif(params['action'] == 'remove_auth'):
|
|
||||||
remove_auth()
|
|
||||||
elif(params['action'] == 'advanced_editor'):
|
|
||||||
editor = AdvancedBackupEditor()
|
|
||||||
editor.showMainScreen()
|
|
||||||
elif(params['action'] == 'advanced_copy_config'):
|
|
||||||
editor = AdvancedBackupEditor()
|
|
||||||
editor.copySimpleConfig()
|
|
@ -147,7 +147,7 @@
|
|||||||
<dependency type="visible" setting="remote_selection">2</dependency>
|
<dependency type="visible" setting="remote_selection">2</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<control type="button" format="action">
|
<control type="button" format="action">
|
||||||
<data>RunScript(special://home/addons/script.xbmcbackup/launcher.py,action=authorize_cloud,provider=dropbox)</data>
|
<data>RunScript(script.xbmcbackup,mode=launcher,action=authorize_cloud,provider=dropbox)</data>
|
||||||
</control>
|
</control>
|
||||||
</setting>
|
</setting>
|
||||||
</group>
|
</group>
|
||||||
@ -160,7 +160,7 @@
|
|||||||
<dependency type="visible" setting="remote_selection">2</dependency>
|
<dependency type="visible" setting="remote_selection">2</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<control type="button" format="action">
|
<control type="button" format="action">
|
||||||
<data>RunScript(special://home/addons/script.xbmcbackup/launcher.py,action=remove_auth)</data>
|
<data>RunScript(script.xbmcbackup,mode=launcher,action=remove_auth)</data>
|
||||||
</control>
|
</control>
|
||||||
</setting>
|
</setting>
|
||||||
</group>
|
</group>
|
||||||
@ -252,7 +252,7 @@
|
|||||||
<dependency type="visible" setting="backup_selection_type">1</dependency>
|
<dependency type="visible" setting="backup_selection_type">1</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<control type="button" format="action">
|
<control type="button" format="action">
|
||||||
<data>RunScript(special://home/addons/script.xbmcbackup/launcher.py,action=advanced_editor)</data>
|
<data>RunScript(script.xbmcbackup,mode=launcher,action=advanced_editor)</data>
|
||||||
</control>
|
</control>
|
||||||
</setting>
|
</setting>
|
||||||
<setting id="advanced_defaults" type="action" label="30139" help="">
|
<setting id="advanced_defaults" type="action" label="30139" help="">
|
||||||
@ -262,7 +262,7 @@
|
|||||||
<dependency type="visible" setting="backup_selection_type">1</dependency>
|
<dependency type="visible" setting="backup_selection_type">1</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<control type="button" format="action">
|
<control type="button" format="action">
|
||||||
<data>RunScript(special://home/addons/script.xbmcbackup/launcher.py,action=advanced_copy_config)</data>
|
<data>RunScript(script.xbmcbackup,mode=launcher,action=advanced_copy_config)</data>
|
||||||
</control>
|
</control>
|
||||||
</setting>
|
</setting>
|
||||||
</group>
|
</group>
|
||||||
|
Loading…
Reference in New Issue
Block a user