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:
|
||||
"""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
|
||||
cmd = [
|
||||
'schtasks', '/delete', '/f',
|
||||
|
|
|
|||
|
|
@ -163,8 +163,8 @@ def build_menus(base_menus, title, presets) -> dict[str, ui.Menu]:
|
|||
return menus
|
||||
|
||||
|
||||
def check_if_av_scan_is_needed():
|
||||
"""Check if an AV scan is needed based on last Fab run."""
|
||||
def check_if_auto_repairs_are_needed():
|
||||
"""Check if Auto Repairs are needed based on last Fab run."""
|
||||
try:
|
||||
last_run = reg_read_value(
|
||||
'HKCU', fr'Software\{KIT_NAME_FULL}', 'FabLastRun',
|
||||
|
|
@ -172,10 +172,24 @@ def check_if_av_scan_is_needed():
|
|||
except FileNotFoundError:
|
||||
# Assuming it isn't needed
|
||||
return
|
||||
fab_last_run = datetime.strptime(last_run, '%Y-%m-%d')
|
||||
|
||||
# Check date and prompt tech if necessary
|
||||
last_run_date = datetime.strptime(last_run, '%Y-%m-%d')
|
||||
if datetime.now() - last_run_date < timedelta(days=FAB_TIMEFRAME):
|
||||
# Check if Auto Repairs was run after Fab
|
||||
auto_repairs_last_run = None
|
||||
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.')
|
||||
selection = ui.choice(
|
||||
'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)
|
||||
|
||||
# Check if AV scan needs to be run
|
||||
check_if_av_scan_is_needed()
|
||||
check_if_auto_repairs_are_needed()
|
||||
|
||||
# Generate menus
|
||||
menus = build_menus(base_menus, title, presets)
|
||||
|
|
|
|||
Loading…
Reference in a new issue