update getSetting calls to get ints and bools where needed

This commit is contained in:
Rob Weber 2019-11-27 14:19:41 -06:00
parent 8c4465f552
commit 5ee610a586
4 changed files with 26 additions and 26 deletions

View File

@ -39,7 +39,7 @@ if(mode == -1):
options = [utils.getString(30016), utils.getString(30017), utils.getString(30099)] options = [utils.getString(30016), utils.getString(30017), utils.getString(30099)]
# find out if we're using the advanced editor # 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)) options.append(utils.getString(30125))
# 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
@ -53,7 +53,7 @@ if(mode != -1):
if(mode == 2): if(mode == 2):
# open the settings dialog # open the settings dialog
utils.openSettings() 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 # open the advanced editor
xbmc.executebuiltin('RunScript(special://home/addons/script.xbmcbackup/launcher.py, action=advanced_editor)') xbmc.executebuiltin('RunScript(special://home/addons/script.xbmcbackup/launcher.py, action=advanced_editor)')
elif(backup.remoteConfigured()): elif(backup.remoteConfigured()):

View File

@ -124,14 +124,14 @@ class XbmcBackup:
utils.log('File Selection Type: ' + str(utils.getSetting('backup_selection_type'))) utils.log('File Selection Type: ' + str(utils.getSetting('backup_selection_type')))
allFiles = [] 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 # read in a list of the directories to backup
selectedDirs = self._readBackupConfig(utils.addon_dir() + "/resources/data/default_files.json") selectedDirs = self._readBackupConfig(utils.addon_dir() + "/resources/data/default_files.json")
# simple mode - get file listings for all enabled directories # simple mode - get file listings for all enabled directories
for aDir in self.simple_directory_list: for aDir in self.simple_directory_list:
# if this dir enabled # 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 # get a file listing and append it to the allfiles array
allFiles.append(self._addBackupDir(aDir, selectedDirs[aDir]['root'], selectedDirs[aDir]['dirs'])) allFiles.append(self._addBackupDir(aDir, selectedDirs[aDir]['root'], selectedDirs[aDir]['dirs']))
else: else:
@ -176,7 +176,7 @@ class XbmcBackup:
self.xbmc_vfs.set_root("special://home/") self.xbmc_vfs.set_root("special://home/")
self.remote_vfs.set_root(orig_base_path) self.remote_vfs.set_root(orig_base_path)
if(utils.getSetting("compress_backups") == 'true'): if(utils.getSettingBool("compress_backups")):
fileManager = FileManager(self.xbmc_vfs) fileManager = FileManager(self.xbmc_vfs)
# send the zip file to the real remote vfs # send the zip file to the real remote vfs
@ -333,7 +333,7 @@ class XbmcBackup:
# append backup folder name # append backup folder name
progressBarTitle = utils.getString(30010) + " - " progressBarTitle = utils.getString(30010) + " - "
if(mode == self.Backup and self.remote_vfs.root_path != ''): 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 # delete old temp file
if(self.xbmc_vfs.exists(xbmc.translatePath('special://temp/xbmc_backup_temp.zip'))): 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'))): 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) self.progressBar.updateProgress(int((float(self.filesTotal - self.filesLeft) / float(self.filesTotal)) * 100), message)
def _rotateBackups(self): def _rotateBackups(self):
total_backups = int(utils.getSetting('backup_rotation')) total_backups = utils.getSettingInt('backup_rotation')
if(total_backups > 0): if(total_backups > 0):
# get a list of valid backup folders # get a list of valid backup folders

View File

@ -15,9 +15,9 @@ class BackupProgressBar:
self.override = progressOverride self.override = progressOverride
# check if we should use the progress bar # 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 # 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.mode = self.DIALOG
self.progressBar = xbmcgui.DialogProgress() self.progressBar = xbmcgui.DialogProgress()
else: else:

View File

@ -19,10 +19,10 @@ class BackupScheduler:
def __init__(self): def __init__(self):
self.monitor = UpdateMonitor(update_method=self.settingsChanged) 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' 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 # sleep for 2 minutes so Kodi can start and time can update correctly
xbmc.Monitor().waitForAbort(120) xbmc.Monitor().waitForAbort(120)
@ -40,9 +40,9 @@ class BackupScheduler:
fh.close() fh.close()
# if we missed and the user wants to play catch-up # 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...") 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): if(progress_mode == 0):
progress_mode = 1 # Kodi just started, don't block it with a foreground progress bar progress_mode = 1 # Kodi just started, don't block it with a foreground progress bar
@ -59,7 +59,7 @@ class BackupScheduler:
def start(self): def start(self):
# display upgrade messages if they exist # 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)) xbmcgui.Dialog().ok(utils.getString(30010), utils.getString(30132))
utils.setSetting('upgrade_notes', str(UPGRADE_INT)) utils.setSetting('upgrade_notes', str(UPGRADE_INT))
@ -75,16 +75,16 @@ class BackupScheduler:
while(not self.monitor.abortRequested()): while(not self.monitor.abortRequested()):
if(self.enabled == "true"): if(self.enabled):
# scheduler is still on # scheduler is still on
now = time.time() now = time.time()
if(self.next_run <= now): if(self.next_run <= now):
progress_mode = int(utils.getSetting('progress_mode')) progress_mode = utils.getSettingInt('progress_mode')
self.doScheduledBackup(progress_mode) self.doScheduledBackup(progress_mode)
# check if we should shut the computer down # 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 # wait 10 seconds to make sure all backup processes and files are completed
time.sleep(10) time.sleep(10)
xbmc.executebuiltin('ShutDown()') xbmc.executebuiltin('ShutDown()')
@ -105,21 +105,21 @@ class BackupScheduler:
if(backup.remoteConfigured()): if(backup.remoteConfigured()):
if(int(utils.getSetting('progress_mode')) in [0, 1]): if(utils.getSettingInt('progress_mode') in [0, 1]):
backup.backup(True) backup.backup(True)
else: else:
backup.backup(False) backup.backup(False)
# check if this is a "one-off" # 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 # disable the scheduler after this run
self.enabled = "false" self.enabled = False
utils.setSetting('enable_scheduler', 'false') utils.setSetting('enable_scheduler', 'false')
else: else:
utils.showNotification(utils.getString(30045)) utils.showNotification(utils.getString(30045))
def findNextRun(self, now): 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 # find the cron expression and get the next run time
cron_exp = self.parseSchedule() cron_exp = self.parseSchedule()
@ -141,22 +141,22 @@ class BackupScheduler:
utils.showNotification(utils.getString(30081) + " " + utils.getRegionalTimestamp(datetime.fromtimestamp(self.next_run), ['dateshort', 'time'])) utils.showNotification(utils.getString(30081) + " " + utils.getRegionalTimestamp(datetime.fromtimestamp(self.next_run), ['dateshort', 'time']))
def settingsChanged(self): 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 # scheduler was just turned on
self.enabled = current_enabled self.enabled = current_enabled
self.setup() self.setup()
elif (current_enabled == "false" and self.enabled == "true"): elif (not current_enabled and self.enabled):
# schedule was turn off # schedule was turn off
self.enabled = current_enabled self.enabled = current_enabled
if(self.enabled == "true"): if(self.enabled):
# always recheck the next run time after an update # always recheck the next run time after an update
self.findNextRun(time.time()) self.findNextRun(time.time())
def parseSchedule(self): def parseSchedule(self):
schedule_type = int(utils.getSetting("schedule_interval")) schedule_type = utils.getSettingInt("schedule_interval")
cron_exp = utils.getSetting("cron_schedule") cron_exp = utils.getSetting("cron_schedule")
hour_of_day = utils.getSetting("schedule_time") hour_of_day = utils.getSetting("schedule_time")