## MAJOR refactoring in progress ##
# BROKEN SCRIPTS #
(These scripts need updated to use the new global_vars & try_and_print)
* user_data_transfer.py
* install_sw_bundle.py
* All Python scripts
* PLAN: Replace vars_wk with global_vars
* functions.py
* PLAN: Will hold (nearly?) all functions going forward
* Should simplify the remaining scripts
* (e.g. reset_browsers and sw_diagnostics both had a backup_browsers())
* PLAN: Move all program definitions to functions.py
* (e.g. vars_wk['SevenZip'] --> global_vars['Programs']['SevenZip'])
* Added major_exception()
* Should be called if anything goes wrong to alert user and provide info
* Added non_clobber_rename()
* Appends a number (if necessary) to avoid overwriting data
* Added popen_program()
* Removes subprocess req for sw_checklist
* Added try_and_print()
* Run a function and show CS/NS/etc
* Can add additional "result" strings via Exception classes
* Passes unrecognized args/kwargs to the function
* Used by scripts to standardize message formatting and error handling
* exit_script() now handles opening the log (if set) and killing caffeine.exe
* Refactored init_vars_wk/os code to work with global_vars
* Uses the try_and_print function for better formatting and error handling
* BREAKING: 'OS' vars now located in global_vars['OS'] (including 'Arch')
* OS labeled as 'outdated', 'very outdated', and 'unrecognized' as needed
* BREAKING: renamed PROGRAMS to TOOLS
* Expanded TOOLS
* Removed log_file as a required argument from all functions
* Removed vars_wk/global_vars as a required argument from all functions
* Removed unused WinPE functions
* Sorted functions
* user_checklist() (formerly reset_browsers())
* Most functions moved to functions.py (see above)
* Browsers
* Work has been split into backup, reset, and config sections
* Script now asks all questions before starting backup/reset/config
* Script now forces the homepage to DEFAULT_HOMEPAGE (set in functions.py)
* (i.e. it no longer asks first, it just does it)
* Current homepages are listed where possible before backup/reset/config
* Launch/Launchers
* Added QuickBooks support
* Removed launchers
* CPU-Z
* HWMonitor
* PerfMonitor2
* SanDisk Express Cache
* Shortcut Cleaner
* SuperAntiSpyware (SAS)
* Replaced Notepad2-Mod with Notepad++
45 lines
1.5 KiB
Python
45 lines
1.5 KiB
Python
# Wizard Kit: DISM wrapper
|
|
|
|
import os
|
|
|
|
# Init
|
|
os.chdir(os.path.dirname(os.path.realpath(__file__)))
|
|
os.system('title Wizard Kit: DISM helper Tool')
|
|
from functions import *
|
|
init_global_vars()
|
|
set_global_vars(LogFile='{LogDir}\\DISM helper tool.log'.format(**global_vars))
|
|
|
|
def abort():
|
|
print_warning('Aborted.')
|
|
exit_script()
|
|
|
|
if __name__ == '__main__':
|
|
stay_awake()
|
|
other_results = {
|
|
'Error': {
|
|
'CalledProcessError': 'Unknown Error',
|
|
},
|
|
'Warning': {
|
|
'GenericRepair': 'Repaired',
|
|
'UnsupportedOSError': 'Unsupported OS',
|
|
}}
|
|
options = [
|
|
{'Name': 'Check Health', 'Command': 'Check'},
|
|
{'Name': 'Restore Health', 'Command': 'Restore'}]
|
|
actions = [{'Name': 'Quit', 'Letter': 'Q'}]
|
|
selection = menu_select('Please select action to perform', options, actions)
|
|
os.system('cls')
|
|
print_info('DISM helper tool')
|
|
if selection == 'Q':
|
|
abort()
|
|
elif options[int(selection)-1]['Command'] == 'Check':
|
|
try_and_print(message='DISM ScanHealth...', function=run_dism_scan_health, cs='No corruption', ns='Corruption detected', other_results=other_results)
|
|
elif options[int(selection)-1]['Command'] == 'Restore':
|
|
try_and_print(message='DISM RestoreHealth...', function=run_dism_restore_health, cs='No corruption', ns='Corruption detected', other_results=other_results)
|
|
else:
|
|
abort()
|
|
|
|
# Done
|
|
print_success('Done.')
|
|
pause("Press Enter to exit...")
|
|
exit_script()
|