From 19176d30cf4a73d2e4ac2c16379ca1a9c4cd408c Mon Sep 17 00:00:00 2001 From: Alan Mason <1923621+2Shirt@users.noreply.github.com> Date: Fri, 1 Dec 2017 15:46:58 -0800 Subject: [PATCH] Open logs and cleanup --- .bin/Scripts/functions/backup.py | 2 +- .bin/Scripts/functions/disk.py | 2 +- .bin/Scripts/functions/winpe_menus.py | 26 +++++++++++++++++++++----- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/.bin/Scripts/functions/backup.py b/.bin/Scripts/functions/backup.py index c916a0e3..10ff9964 100644 --- a/.bin/Scripts/functions/backup.py +++ b/.bin/Scripts/functions/backup.py @@ -36,7 +36,7 @@ def prep_disk_for_backup(destination, disk, ticket_number): # Get partition totals disk['Bad Partitions'] = [par['Number'] for par in disk['Partitions'] - if is_bad_partition(partition)] + if is_bad_partition(par)] num_valid_partitions = len(disk['Partitions']) - len(disk['Bad Partitions']) disk['Valid Partitions'] = num_valid_partitions if disk['Valid Partitions'] <= 0: diff --git a/.bin/Scripts/functions/disk.py b/.bin/Scripts/functions/disk.py index 821529ae..897422bb 100644 --- a/.bin/Scripts/functions/disk.py +++ b/.bin/Scripts/functions/disk.py @@ -300,7 +300,7 @@ def run_diskpart(script): global_vars['Env']['SYSTEMDRIVE']), '/s', tempfile] result = run_program(cmd) - time.sleep(2) + sleep(2) return result def scan_disks(): diff --git a/.bin/Scripts/functions/winpe_menus.py b/.bin/Scripts/functions/winpe_menus.py index 5b412d50..a43c95d8 100644 --- a/.bin/Scripts/functions/winpe_menus.py +++ b/.bin/Scripts/functions/winpe_menus.py @@ -178,10 +178,17 @@ def menu_backup(): pass for line in par['Error']: print_error('\t{}'.format(line)) - time.sleep(30) else: print_success('\nNo errors were encountered during imaging.') - time.sleep(5) + if 'LogFile' in global_vars: + cmd = [ + global_vars['Tools']['NotepadPlusPlus'], + global_vars['LogFile']] + try: + popen_program(cmd) + except Exception: + print_error('ERROR: Failed to open log.') + sleep(30) pause('\nPress Enter to return to main menu... ') def menu_root(): @@ -219,7 +226,7 @@ def menu_root(): elif (selection == 'S'): run_program(['wpeutil', 'shutdown']) else: - exit_script() + sys.exit() def menu_setup(): """Format a disk (MBR/GPT), apply a Windows image, and setup boot files.""" @@ -346,6 +353,15 @@ def menu_setup(): # Print summary print_standard('\nDone.') + if 'LogFile' in global_vars: + cmd = [ + global_vars['Tools']['NotepadPlusPlus'], + global_vars['LogFile']] + try: + popen_program(cmd) + except Exception: + print_error('ERROR: Failed to open log.') + sleep(30) pause('\nPress Enter to return to main menu... ') def menu_tools(): @@ -371,7 +387,7 @@ def menu_tools(): popen_program(cmd) except Exception: print_error('Failed to run {}'.format(name)) - time.sleep(2) + sleep(2) pause() elif (selection == 'M'): break @@ -395,7 +411,7 @@ def select_minidump_path(): # Check results before showing menu if len(dumps) == 0: print_error(' No BSoD / MiniDump paths found') - time.sleep(2) + sleep(2) return None # Menu