changed formatting of scheduler times
This commit is contained in:
@@ -41,14 +41,22 @@ try:
|
|||||||
schedules = json.load(f)
|
schedules = json.load(f)
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
shutdown_schedule = schedules['shutdown']['time']
|
shutdown_schedule_hour = schedules['shutdown']['hour']
|
||||||
reboot_schedule = schedules['reboot']['time']
|
shutdown_schedule_minute = schedules['shutdown']['minute']
|
||||||
|
|
||||||
|
reboot_schedule_hour = schedules['reboot']['hour']
|
||||||
|
reboot_schedule_minute = schedules['reboot']['minute']
|
||||||
|
|
||||||
timezone = schedules['timezone']
|
timezone = schedules['timezone']
|
||||||
shutdown_enabled = schedules['shutdown']['enabled']
|
shutdown_enabled = schedules['shutdown']['enabled']
|
||||||
reboot_enabled = schedules['reboot']['enabled']
|
reboot_enabled = schedules['reboot']['enabled']
|
||||||
except:
|
except:
|
||||||
shutdown_schedule = "00:00"
|
shutdown_schedule_hour = "00"
|
||||||
reboot_schedule = "00:00"
|
shutdown_schedule_minute = "00"
|
||||||
|
|
||||||
|
reboot_schedule_hour = "00"
|
||||||
|
reboot_schedule_minute = "00"
|
||||||
|
|
||||||
timezone = "GMT"
|
timezone = "GMT"
|
||||||
shutdown_enabled = False
|
shutdown_enabled = False
|
||||||
reboot_enabled = False
|
reboot_enabled = False
|
||||||
@@ -1269,14 +1277,22 @@ if __name__ == '__main__':
|
|||||||
f = open('csv/scheduler.json','r')
|
f = open('csv/scheduler.json','r')
|
||||||
schedules = json.load(f)
|
schedules = json.load(f)
|
||||||
f.close()
|
f.close()
|
||||||
shutdown_schedule = schedules['shutdown']['time']
|
shutdown_schedule_hour = schedules['shutdown']['hour']
|
||||||
reboot_schedule = schedules['reboot']['time']
|
shutdown_schedule_minute = schedules['shutdown']['minute']
|
||||||
|
|
||||||
|
reboot_schedule_hour = schedules['reboot']['hour']
|
||||||
|
reboot_schedule_minute = schedules['reboot']['minute']
|
||||||
|
|
||||||
timezone = schedules['timezone']
|
timezone = schedules['timezone']
|
||||||
shutdown_enabled = schedules['shutdown']['enabled']
|
shutdown_enabled = schedules['shutdown']['enabled']
|
||||||
reboot_enabled = schedules['reboot']['enabled']
|
reboot_enabled = schedules['reboot']['enabled']
|
||||||
except:
|
except:
|
||||||
shutdown_schedule = "00:00"
|
shutdown_schedule_hour = "00"
|
||||||
reboot_schedule = "00:00"
|
shutdown_schedule_minute = "00"
|
||||||
|
|
||||||
|
reboot_schedule_hour = "00"
|
||||||
|
reboot_schedule_minute = "00"
|
||||||
|
|
||||||
timezone = "GMT"
|
timezone = "GMT"
|
||||||
shutdown_enabled = False
|
shutdown_enabled = False
|
||||||
reboot_enabled = False
|
reboot_enabled = False
|
||||||
@@ -1284,13 +1300,13 @@ if __name__ == '__main__':
|
|||||||
pass
|
pass
|
||||||
#SHUTDOWN
|
#SHUTDOWN
|
||||||
try:
|
try:
|
||||||
if datetime.now(pytz.timezone(timezone)).strftime("%H:%M") == shutdown_schedule and shutdown_enabled:
|
if datetime.now(pytz.timezone(timezone)).strftime("%H:%M") == shutdown_schedule_hour+':'+shutdown_schedule_minute and shutdown_enabled:
|
||||||
os.system('sudo shutdown now')
|
os.system('sudo shutdown now')
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
#REBOOT
|
#REBOOT
|
||||||
try:
|
try:
|
||||||
if datetime.now(pytz.timezone(timezone)).strftime("%H:%M") == reboot_schedule and reboot_enabled:
|
if datetime.now(pytz.timezone(timezone)).strftime("%H:%M") == reboot_schedule_hour+':'+reboot_schedule_minute and reboot_enabled:
|
||||||
os.system('sudo reboot')
|
os.system('sudo reboot')
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
Reference in New Issue
Block a user