changed formatting of scheduler times

This commit is contained in:
Justin 2023-04-21 19:10:21 +08:00 committed by GitHub
parent d5258a7aaf
commit ba1a67e2eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -41,14 +41,22 @@ try:
schedules = json.load(f)
f.close()
shutdown_schedule = schedules['shutdown']['time']
reboot_schedule = schedules['reboot']['time']
shutdown_schedule_hour = schedules['shutdown']['hour']
shutdown_schedule_minute = schedules['shutdown']['minute']
reboot_schedule_hour = schedules['reboot']['hour']
reboot_schedule_minute = schedules['reboot']['minute']
timezone = schedules['timezone']
shutdown_enabled = schedules['shutdown']['enabled']
reboot_enabled = schedules['reboot']['enabled']
except:
shutdown_schedule = "00:00"
reboot_schedule = "00:00"
shutdown_schedule_hour = "00"
shutdown_schedule_minute = "00"
reboot_schedule_hour = "00"
reboot_schedule_minute = "00"
timezone = "GMT"
shutdown_enabled = False
reboot_enabled = False
@ -1269,14 +1277,22 @@ if __name__ == '__main__':
f = open('csv/scheduler.json','r')
schedules = json.load(f)
f.close()
shutdown_schedule = schedules['shutdown']['time']
reboot_schedule = schedules['reboot']['time']
shutdown_schedule_hour = schedules['shutdown']['hour']
shutdown_schedule_minute = schedules['shutdown']['minute']
reboot_schedule_hour = schedules['reboot']['hour']
reboot_schedule_minute = schedules['reboot']['minute']
timezone = schedules['timezone']
shutdown_enabled = schedules['shutdown']['enabled']
reboot_enabled = schedules['reboot']['enabled']
except:
shutdown_schedule = "00:00"
reboot_schedule = "00:00"
shutdown_schedule_hour = "00"
shutdown_schedule_minute = "00"
reboot_schedule_hour = "00"
reboot_schedule_minute = "00"
timezone = "GMT"
shutdown_enabled = False
reboot_enabled = False
@ -1284,13 +1300,13 @@ if __name__ == '__main__':
pass
#SHUTDOWN
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')
except:
pass
#REBOOT
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')
except:
pass