Don't prompt to run Auto Repairs if run recently
Added a Registry marker for the last Auto Repairs Run. This is set during end_session() regardless of the actual repairs run but it should be good enough. Addresses issue #33
This commit is contained in:
parent
7156578124
commit
96f55fd992
2 changed files with 29 additions and 6 deletions
|
|
@ -191,6 +191,15 @@ def build_menus(base_menus, title, presets) -> dict[str, ui.Menu]:
|
||||||
|
|
||||||
def end_session(menus: dict[str, ui.Menu]) -> None:
|
def end_session(menus: dict[str, ui.Menu]) -> None:
|
||||||
"""End Auto Repairs session."""
|
"""End Auto Repairs session."""
|
||||||
|
# Add last run marker
|
||||||
|
reg_set_value(
|
||||||
|
'HKCU',
|
||||||
|
fr'Software\{KIT_NAME_FULL}',
|
||||||
|
'AutoRepairsLastRun',
|
||||||
|
time.strftime('%Y-%m-%d'),
|
||||||
|
'SZ',
|
||||||
|
)
|
||||||
|
|
||||||
# Remove logon task
|
# Remove logon task
|
||||||
cmd = [
|
cmd = [
|
||||||
'schtasks', '/delete', '/f',
|
'schtasks', '/delete', '/f',
|
||||||
|
|
|
||||||
|
|
@ -163,8 +163,8 @@ def build_menus(base_menus, title, presets) -> dict[str, ui.Menu]:
|
||||||
return menus
|
return menus
|
||||||
|
|
||||||
|
|
||||||
def check_if_av_scan_is_needed():
|
def check_if_auto_repairs_are_needed():
|
||||||
"""Check if an AV scan is needed based on last Fab run."""
|
"""Check if Auto Repairs are needed based on last Fab run."""
|
||||||
try:
|
try:
|
||||||
last_run = reg_read_value(
|
last_run = reg_read_value(
|
||||||
'HKCU', fr'Software\{KIT_NAME_FULL}', 'FabLastRun',
|
'HKCU', fr'Software\{KIT_NAME_FULL}', 'FabLastRun',
|
||||||
|
|
@ -172,10 +172,24 @@ def check_if_av_scan_is_needed():
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
# Assuming it isn't needed
|
# Assuming it isn't needed
|
||||||
return
|
return
|
||||||
|
fab_last_run = datetime.strptime(last_run, '%Y-%m-%d')
|
||||||
|
|
||||||
# Check date and prompt tech if necessary
|
# Check if Auto Repairs was run after Fab
|
||||||
last_run_date = datetime.strptime(last_run, '%Y-%m-%d')
|
auto_repairs_last_run = None
|
||||||
if datetime.now() - last_run_date < timedelta(days=FAB_TIMEFRAME):
|
try:
|
||||||
|
last_run = reg_read_value(
|
||||||
|
'HKCU', fr'Software\{KIT_NAME_FULL}', 'AutoRepairsLastRun',
|
||||||
|
)
|
||||||
|
auto_repairs_last_run = datetime.strptime(last_run, '%Y-%m-%d')
|
||||||
|
except FileNotFoundError:
|
||||||
|
# Assuming it wasn't
|
||||||
|
pass
|
||||||
|
|
||||||
|
# Check date(s) and prompt tech if necessary
|
||||||
|
if datetime.now() - fab_last_run < timedelta(days=FAB_TIMEFRAME):
|
||||||
|
if auto_repairs_last_run and auto_repairs_last_run >= fab_last_run:
|
||||||
|
# Auto Repairs shouldn't be needed
|
||||||
|
return
|
||||||
ui.print_warning('Fab was recently run, Auto Repairs may be needed.')
|
ui.print_warning('Fab was recently run, Auto Repairs may be needed.')
|
||||||
selection = ui.choice(
|
selection = ui.choice(
|
||||||
'Continue with Auto Setup, run Auto Repairs, or Quit?', ['C', 'R', 'Q'],
|
'Continue with Auto Setup, run Auto Repairs, or Quit?', ['C', 'R', 'Q'],
|
||||||
|
|
@ -297,7 +311,7 @@ def run_auto_setup(base_menus, presets) -> None:
|
||||||
title = check_os_and_set_menu_title(title)
|
title = check_os_and_set_menu_title(title)
|
||||||
|
|
||||||
# Check if AV scan needs to be run
|
# Check if AV scan needs to be run
|
||||||
check_if_av_scan_is_needed()
|
check_if_auto_repairs_are_needed()
|
||||||
|
|
||||||
# Generate menus
|
# Generate menus
|
||||||
menus = build_menus(base_menus, title, presets)
|
menus = build_menus(base_menus, title, presets)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue