WizardKit/.bin/Scripts/sw_diagnostics.py
Alan Mason b37a492db5 2017-03: Retroactive Updates
## 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++
2017-11-17 00:56:16 -07:00

84 lines
3.7 KiB
Python

# Wizard Kit: Software Diagnostics
import os
# Init
os.chdir(os.path.dirname(os.path.realpath(__file__)))
os.system('title Wizard Kit: Software Diagnostics Tool')
from functions import *
init_global_vars()
set_global_vars(LogFile='{LogDir}\\Software Diagnostics.log'.format(**global_vars))
def abort():
print_warning('Aborted.')
pause("Press Enter to exit...")
exit_script()
if __name__ == '__main__':
stay_awake()
get_ticket_number()
os.system('cls')
other_results = {
'Error': {
'CalledProcessError': 'Unknown Error',
},
'Warning': {
'GenericRepair': 'Repaired',
'UnsupportedOSError': 'Unsupported OS',
}}
print_info('Starting Software Diagnostics for Ticket #{TicketNumber}\n'.format(**global_vars))
# Sanitize Environment
print_info('Sanitizing Environment')
try_and_print(message='Killing processes...', function=run_process_killer, cs='Done')
try_and_print(message='Running RKill...', function=run_rkill, cs='Done')
try_and_print(message='Running TDSSKiller...', function=run_tdsskiller, cs='Done')
# Re-run if earlier process was stopped.
stay_awake()
# Start diags
print_info('Starting Background Scans')
check_connection()
try_and_print(message='Running HitmanPro...', function=run_hitmanpro, cs='Started')
try_and_print(message='Running Autoruns...', function=run_autoruns, cs='Started')
# OS Health Checks
print_info('OS Health Checks')
try_and_print(message='CHKDSK ({SYSTEMDRIVE})...'.format(**global_vars['Env']), function=run_chkdsk, cs='CS', ns='NS', other_results=other_results)
try_and_print(message='SFC scan...', function=run_sfc_scan, cs='CS', ns='NS', other_results=other_results)
try_and_print(message='DISM CheckHealth...', function=run_dism_scan_health, cs='CS', ns='NS', other_results=other_results)
# Export system info
print_info('Backup System Information')
try_and_print(message='AIDA64 reports...', function=run_aida64, cs='Done')
try_and_print(message='BleachBit report...', function=run_bleachbit, cs='Done')
try_and_print(message='Browsers...', function=backup_browsers, cs='Done')
try_and_print(message='File listing...', function=backup_file_list, cs='Done')
try_and_print(message='Power plans...', function=backup_power_plans, cs='Done')
try_and_print(message='Product Keys...', function=run_produkey, cs='Done')
try_and_print(message='Registry...', function=backup_registry, cs='Done')
# Summary
print_info('Summary')
try_and_print(message='Temp Size:', function=show_temp_files_size, silent_function=False)
show_free_space()
try_and_print(message='Installed RAM:', function=show_installed_ram, ns='Unknown', silent_function=False)
try_and_print(message='Installed Office:', function=get_installed_office, ns='Unknown', print_return=True)
try_and_print(message='Product Keys:', function=get_product_keys, ns='Unknown', print_return=True)
try_and_print(message='Operating System:', function=show_os_name, ns='Unknown', silent_function=False)
try_and_print(message='', function=show_os_activation, ns='Unknown', silent_function=False)
# User data
print_info('User Data')
show_user_data_summary()
# Upload info
print_info('Finalizing')
try_and_print(message='Compressing Info...', function=compress_info, cs='Done')
try_and_print(message='Uploading to NAS...', function=upload_info, cs='Done')
# Done
print_standard('\nDone.')
pause('Press Enter to exit...')
exit_script()