mirror of
https://github.com/robweber/xbmcbackup.git
synced 2024-12-22 14:05:23 +01:00
update getSetting calls to get ints and bools where needed
This commit is contained in:
parent
8c4465f552
commit
5ee610a586
@ -39,7 +39,7 @@ if(mode == -1):
|
||||
options = [utils.getString(30016), utils.getString(30017), utils.getString(30099)]
|
||||
|
||||
# find out if we're using the advanced editor
|
||||
if(int(utils.getSetting('backup_selection_type')) == 1):
|
||||
if(utils.getSettingInt('backup_selection_type') == 1):
|
||||
options.append(utils.getString(30125))
|
||||
|
||||
# figure out if this is a backup or a restore from the user
|
||||
@ -53,7 +53,7 @@ if(mode != -1):
|
||||
if(mode == 2):
|
||||
# open the settings dialog
|
||||
utils.openSettings()
|
||||
elif(mode == 3 and int(utils.getSetting('backup_selection_type')) == 1):
|
||||
elif(mode == 3 and utils.getSettingInt('backup_selection_type') == 1):
|
||||
# open the advanced editor
|
||||
xbmc.executebuiltin('RunScript(special://home/addons/script.xbmcbackup/launcher.py, action=advanced_editor)')
|
||||
elif(backup.remoteConfigured()):
|
||||
|
@ -124,14 +124,14 @@ class XbmcBackup:
|
||||
utils.log('File Selection Type: ' + str(utils.getSetting('backup_selection_type')))
|
||||
allFiles = []
|
||||
|
||||
if(int(utils.getSetting('backup_selection_type')) == 0):
|
||||
if(utils.getSettingInt('backup_selection_type') == 0):
|
||||
# read in a list of the directories to backup
|
||||
selectedDirs = self._readBackupConfig(utils.addon_dir() + "/resources/data/default_files.json")
|
||||
|
||||
# simple mode - get file listings for all enabled directories
|
||||
for aDir in self.simple_directory_list:
|
||||
# if this dir enabled
|
||||
if(utils.getSetting('backup_' + aDir) == 'true'):
|
||||
if(utils.getSettingBool('backup_' + aDir)):
|
||||
# get a file listing and append it to the allfiles array
|
||||
allFiles.append(self._addBackupDir(aDir, selectedDirs[aDir]['root'], selectedDirs[aDir]['dirs']))
|
||||
else:
|
||||
@ -176,7 +176,7 @@ class XbmcBackup:
|
||||
self.xbmc_vfs.set_root("special://home/")
|
||||
self.remote_vfs.set_root(orig_base_path)
|
||||
|
||||
if(utils.getSetting("compress_backups") == 'true'):
|
||||
if(utils.getSettingBool("compress_backups")):
|
||||
fileManager = FileManager(self.xbmc_vfs)
|
||||
|
||||
# send the zip file to the real remote vfs
|
||||
@ -333,7 +333,7 @@ class XbmcBackup:
|
||||
# append backup folder name
|
||||
progressBarTitle = utils.getString(30010) + " - "
|
||||
if(mode == self.Backup and self.remote_vfs.root_path != ''):
|
||||
if(utils.getSetting("compress_backups") == 'true'):
|
||||
if(utils.getSettingBool("compress_backups")):
|
||||
# delete old temp file
|
||||
if(self.xbmc_vfs.exists(xbmc.translatePath('special://temp/xbmc_backup_temp.zip'))):
|
||||
if(not self.xbmc_vfs.rmfile(xbmc.translatePath('special://temp/xbmc_backup_temp.zip'))):
|
||||
@ -438,7 +438,7 @@ class XbmcBackup:
|
||||
self.progressBar.updateProgress(int((float(self.filesTotal - self.filesLeft) / float(self.filesTotal)) * 100), message)
|
||||
|
||||
def _rotateBackups(self):
|
||||
total_backups = int(utils.getSetting('backup_rotation'))
|
||||
total_backups = utils.getSettingInt('backup_rotation')
|
||||
|
||||
if(total_backups > 0):
|
||||
# get a list of valid backup folders
|
||||
|
@ -15,9 +15,9 @@ class BackupProgressBar:
|
||||
self.override = progressOverride
|
||||
|
||||
# check if we should use the progress bar
|
||||
if(int(utils.getSetting('progress_mode')) != 2):
|
||||
if(utils.getSettingInt('progress_mode') != 2):
|
||||
# check if background or normal
|
||||
if(int(utils.getSetting('progress_mode')) == 0 and not self.override):
|
||||
if(utils.getSettingInt('progress_mode') == 0 and not self.override):
|
||||
self.mode = self.DIALOG
|
||||
self.progressBar = xbmcgui.DialogProgress()
|
||||
else:
|
||||
|
34
scheduler.py
34
scheduler.py
@ -19,10 +19,10 @@ class BackupScheduler:
|
||||
|
||||
def __init__(self):
|
||||
self.monitor = UpdateMonitor(update_method=self.settingsChanged)
|
||||
self.enabled = utils.getSetting("enable_scheduler")
|
||||
self.enabled = utils.getSettingBool("enable_scheduler")
|
||||
self.next_run_path = xbmc.translatePath(utils.data_dir()) + 'next_run.txt'
|
||||
|
||||
if(self.enabled == "true"):
|
||||
if(self.enabled):
|
||||
|
||||
# sleep for 2 minutes so Kodi can start and time can update correctly
|
||||
xbmc.Monitor().waitForAbort(120)
|
||||
@ -40,9 +40,9 @@ class BackupScheduler:
|
||||
fh.close()
|
||||
|
||||
# if we missed and the user wants to play catch-up
|
||||
if(0 < nr <= time.time() and utils.getSetting('schedule_miss') == 'true'):
|
||||
if(0 < nr <= time.time() and utils.getSettingBool('schedule_miss')):
|
||||
utils.log("scheduled backup was missed, doing it now...")
|
||||
progress_mode = int(utils.getSetting('progress_mode'))
|
||||
progress_mode = utils.getSettingInt('progress_mode')
|
||||
|
||||
if(progress_mode == 0):
|
||||
progress_mode = 1 # Kodi just started, don't block it with a foreground progress bar
|
||||
@ -59,7 +59,7 @@ class BackupScheduler:
|
||||
def start(self):
|
||||
|
||||
# display upgrade messages if they exist
|
||||
if(int(utils.getSetting('upgrade_notes')) < UPGRADE_INT):
|
||||
if(utils.getSettingInt('upgrade_notes') < UPGRADE_INT):
|
||||
xbmcgui.Dialog().ok(utils.getString(30010), utils.getString(30132))
|
||||
utils.setSetting('upgrade_notes', str(UPGRADE_INT))
|
||||
|
||||
@ -75,16 +75,16 @@ class BackupScheduler:
|
||||
|
||||
while(not self.monitor.abortRequested()):
|
||||
|
||||
if(self.enabled == "true"):
|
||||
if(self.enabled):
|
||||
# scheduler is still on
|
||||
now = time.time()
|
||||
|
||||
if(self.next_run <= now):
|
||||
progress_mode = int(utils.getSetting('progress_mode'))
|
||||
progress_mode = utils.getSettingInt('progress_mode')
|
||||
self.doScheduledBackup(progress_mode)
|
||||
|
||||
# check if we should shut the computer down
|
||||
if(utils.getSetting("cron_shutdown") == 'true'):
|
||||
if(utils.getSettingBool("cron_shutdown")):
|
||||
# wait 10 seconds to make sure all backup processes and files are completed
|
||||
time.sleep(10)
|
||||
xbmc.executebuiltin('ShutDown()')
|
||||
@ -105,21 +105,21 @@ class BackupScheduler:
|
||||
|
||||
if(backup.remoteConfigured()):
|
||||
|
||||
if(int(utils.getSetting('progress_mode')) in [0, 1]):
|
||||
if(utils.getSettingInt('progress_mode') in [0, 1]):
|
||||
backup.backup(True)
|
||||
else:
|
||||
backup.backup(False)
|
||||
|
||||
# check if this is a "one-off"
|
||||
if(int(utils.getSetting("schedule_interval")) == 0):
|
||||
if(utils.getSettingInt("schedule_interval") == 0):
|
||||
# disable the scheduler after this run
|
||||
self.enabled = "false"
|
||||
self.enabled = False
|
||||
utils.setSetting('enable_scheduler', 'false')
|
||||
else:
|
||||
utils.showNotification(utils.getString(30045))
|
||||
|
||||
def findNextRun(self, now):
|
||||
progress_mode = int(utils.getSetting('progress_mode'))
|
||||
progress_mode = utils.getSettingInt('progress_mode')
|
||||
|
||||
# find the cron expression and get the next run time
|
||||
cron_exp = self.parseSchedule()
|
||||
@ -141,22 +141,22 @@ class BackupScheduler:
|
||||
utils.showNotification(utils.getString(30081) + " " + utils.getRegionalTimestamp(datetime.fromtimestamp(self.next_run), ['dateshort', 'time']))
|
||||
|
||||
def settingsChanged(self):
|
||||
current_enabled = utils.getSetting("enable_scheduler")
|
||||
current_enabled = utils.getSettingBool("enable_scheduler")
|
||||
|
||||
if(current_enabled == "true" and self.enabled == "false"):
|
||||
if(current_enabled and not self.enabled):
|
||||
# scheduler was just turned on
|
||||
self.enabled = current_enabled
|
||||
self.setup()
|
||||
elif (current_enabled == "false" and self.enabled == "true"):
|
||||
elif (not current_enabled and self.enabled):
|
||||
# schedule was turn off
|
||||
self.enabled = current_enabled
|
||||
|
||||
if(self.enabled == "true"):
|
||||
if(self.enabled):
|
||||
# always recheck the next run time after an update
|
||||
self.findNextRun(time.time())
|
||||
|
||||
def parseSchedule(self):
|
||||
schedule_type = int(utils.getSetting("schedule_interval"))
|
||||
schedule_type = utils.getSettingInt("schedule_interval")
|
||||
cron_exp = utils.getSetting("cron_schedule")
|
||||
|
||||
hour_of_day = utils.getSetting("schedule_time")
|
||||
|
Loading…
Reference in New Issue
Block a user