Merge remote-tracking branch 'upstream/dev' into dev

This commit is contained in:
2Shirt 2021-05-07 18:26:17 -06:00
commit db25a632fe
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C
2 changed files with 26 additions and 1 deletions

View file

@ -414,5 +414,19 @@ def stop_service(service_name):
raise GenericError(f'Failed to stop service {service_name}')
# Date / Time functions
def get_timezone():
"""Get current timezone using tzutil, returns str."""
cmd = ['tzutil', '/g']
proc = run_program(cmd, check=False)
return proc.stdout
def set_timezone(zone):
"""Set current timezone using tzutil."""
cmd = ['tzutil', '/s', zone]
run_program(cmd, check=False)
if __name__ == '__main__':
print("This file is not meant to be called directly.")

View file

@ -12,7 +12,7 @@ import time
from subprocess import CalledProcessError, DEVNULL
from wk.cfg.main import KIT_NAME_FULL, KIT_NAME_SHORT
from wk.cfg.main import KIT_NAME_FULL, KIT_NAME_SHORT, WINDOWS_TIME_ZONE
from wk.exe import (
get_procs,
run_program,
@ -29,6 +29,8 @@ from wk.kit.tools import (
)
from wk.log import format_log_path, update_log_path
from wk.os.win import (
get_timezone,
set_timezone,
reg_delete_value,
reg_read_value,
reg_set_value,
@ -301,6 +303,15 @@ def init_session(options):
"""Initialize Auto Repairs session."""
reg_set_value('HKCU', AUTO_REPAIR_KEY, 'SessionStarted', 1, 'DWORD')
# Check timezone
zone = get_timezone()
msg = (
'The timezone is currently set to '
f'{zone}, switch it to {WINDOWS_TIME_ZONE}?'
)
if zone != WINDOWS_TIME_ZONE and ask(msg):
set_timezone(WINDOWS_TIME_ZONE)
# Create logon task for Auto Repairs
cmd = [
'schtasks', '/create', '/f',