Enabled logging for hw-diags
This commit is contained in:
parent
74ba8fb758
commit
03d7646685
2 changed files with 23 additions and 2 deletions
|
|
@ -132,7 +132,7 @@ def exit_script(return_value=0):
|
|||
|
||||
# Open Log (if it exists)
|
||||
log = global_vars.get('LogFile', '')
|
||||
if log and os.path.exists(log):
|
||||
if log and os.path.exists(log) and psutil.WINDOWS:
|
||||
try:
|
||||
extract_item('NotepadPlusPlus', silent=True)
|
||||
popen_program(
|
||||
|
|
@ -359,7 +359,7 @@ def print_warning(*args, **kwargs):
|
|||
|
||||
def print_log(message='', end='\n', timestamp=True):
|
||||
time_str = time.strftime("%Y-%m-%d %H%M%z: ") if timestamp else ''
|
||||
if 'LogFile' in global_vars and global_vars['LogFile'] is not None:
|
||||
if 'LogFile' in global_vars and global_vars['LogFile']:
|
||||
with open(global_vars['LogFile'], 'a', encoding='utf-8') as f:
|
||||
for line in message.splitlines():
|
||||
f.write('{timestamp}{line}{end}'.format(
|
||||
|
|
|
|||
|
|
@ -88,6 +88,15 @@ def menu_diags():
|
|||
action_entries = actions,
|
||||
spacer = '──────────────────────────')
|
||||
if selection.isnumeric():
|
||||
if diag_modes[int(selection)-1]['Name'] != 'Quick drive test':
|
||||
# Save log for non-quick tests
|
||||
ticket_number = get_ticket_number()
|
||||
global_vars['LogDir'] = '{}/Tickets/{}'.format(
|
||||
global_vars['Env']['HOME'],
|
||||
ticket_number)
|
||||
os.makedirs(global_vars['LogDir'], exist_ok=True)
|
||||
global_vars['LogFile'] = '{}/Hardware Diagnostics.log'.format(
|
||||
global_vars['LogDir'])
|
||||
run_tests(diag_modes[int(selection)-1]['Tests'])
|
||||
elif selection == 'A':
|
||||
run_program(['hw-diags-audio'], check=False, pipe=False)
|
||||
|
|
@ -110,6 +119,7 @@ def run_badblocks():
|
|||
def run_mprime():
|
||||
aborted = False
|
||||
clear_screen()
|
||||
print_log('\nStart Prime95 test')
|
||||
TESTS['Prime95']['Status'] = 'Working'
|
||||
update_progress()
|
||||
|
||||
|
|
@ -135,6 +145,15 @@ def run_mprime():
|
|||
run_program('killall -s INT mprime'.split(), check=False)
|
||||
run_program(['apple-fans', 'auto'])
|
||||
|
||||
# Move logs to Ticket folder
|
||||
for item in os.scandir(global_vars['TmpDir']):
|
||||
try:
|
||||
shutil.move(item.path, global_vars['LogDir'])
|
||||
except Exception:
|
||||
print_error('ERROR: Failed to move "{}" to "{}"'.format(
|
||||
item.path,
|
||||
global_vars['LogDir']))
|
||||
|
||||
# Update status
|
||||
if aborted:
|
||||
TESTS['Prime95']['Status'] = 'Aborted'
|
||||
|
|
@ -166,6 +185,8 @@ def run_smart():
|
|||
run_program(['tmux kill-pane -a'.split()], check=False)
|
||||
|
||||
def run_tests(tests):
|
||||
print_log('Starting Hardware Diagnostics')
|
||||
print_log('\nRunning tests: {}'.format(', '.join(tests)))
|
||||
# Enable selected tests
|
||||
for t in ['Prime95', 'NVMe/SMART', 'badblocks']:
|
||||
TESTS[t]['Enabled'] = t in tests
|
||||
|
|
|
|||
Loading…
Reference in a new issue