added setting for 'one-off' schedules

This commit is contained in:
Rob Weber
2013-08-25 10:58:23 -05:00
parent 3ae5ce8f6f
commit f028bffca4
5 changed files with 17 additions and 5 deletions

View File

@ -52,6 +52,12 @@ class BackupScheduler:
backup = XbmcBackup()
backup.run(XbmcBackup.Backup,True)
#check if this is a "one-off"
if(int(utils.getSetting("schedule_interval")) == 0):
#disable the scheduler after this run
self.enabled = "false"
utils.setSetting('enable_scheduler','false')
#check if we should shut the computer down
if(utils.getSetting("cron_shutdown") == 'true'):
#wait 10 seconds to make sure all backup processes and files are completed
@ -72,6 +78,7 @@ class BackupScheduler:
if(new_run_time != self.next_run):
self.next_run = new_run_time
#utils.showNotification("Scheduler will run again on " + datetime.datetime.fromtimestamp(self.next_run).strftime('%m-%d-%Y %H:%M')")
utils.log("scheduler will run again on " + datetime.datetime.fromtimestamp(self.next_run).strftime('%m-%d-%Y %H:%M'))
def settingsChanged(self):
@ -95,14 +102,14 @@ class BackupScheduler:
hour_of_day = utils.getSetting("schedule_time")
hour_of_day = int(hour_of_day[0:2])
if(schedule_type == 0):
if(schedule_type == 0 or schedule_type == 1):
#every day
cron_exp = "0 " + str(hour_of_day) + " * * *"
elif(schedule_type == 1):
elif(schedule_type == 2):
#once a week
day_of_week = utils.getSetting("day_of_week")
cron_exp = "0 " + str(hour_of_day) + " * * " + day_of_week
elif(schedule_type == 2):
elif(schedule_type == 3):
#first day of month
cron_exp = "0 " + str(hour_of_day) + " 1 * *"