From 8e5d350ac2f24ce26c07f9b6497da6d0e8c2eb30 Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Tue, 6 Apr 2021 15:52:57 -0600 Subject: [PATCH 1/3] Update default log dir under macOS --- scripts/wk/log.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/wk/log.py b/scripts/wk/log.py index d1b7c4e0..0bb5f587 100644 --- a/scripts/wk/log.py +++ b/scripts/wk/log.py @@ -15,7 +15,7 @@ from wk.io import non_clobber_path # STATIC VARIABLES if os.path.exists('/.wk-live-macos'): # Workaround for live macOS env - DEFAULT_LOG_DIR = '/var/log/WizardKit' + DEFAULT_LOG_DIR = '/Volumes/RAM_Disk/Logs' elif os.name == 'nt': # Example: "C:\WK\1955-11-05\WizardKit" DEFAULT_LOG_DIR = ( From 61f2b00a2acc17086a93aec5e860098a592c10b4 Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Tue, 6 Apr 2021 15:53:19 -0600 Subject: [PATCH 2/3] Export SMC data in HW Diagnostics Addresses issue #154 --- scripts/wk/hw/diags.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/scripts/wk/hw/diags.py b/scripts/wk/hw/diags.py index fbea7b98..5576970e 100644 --- a/scripts/wk/hw/diags.py +++ b/scripts/wk/hw/diags.py @@ -352,6 +352,21 @@ class State(): _f.write(f'\n{name}:\n') _f.write('\n'.join(debug.generate_object_report(test, indent=1))) + # SMC + if os.path.exists('/.wk-live-macos'): + data = [] + try: + proc = exe.run_program(['smc', '-f']) + data.extend(proc.stdout.splitlines()) + data.append('----') + proc = exe.run_program(['smc', '-l']) + data.extend(proc.stdout.splitlines()) + except Exception: # pylint: disable=broad-except + LOG.ERROR('Error(s) encountered while exporting SMC data') + data = [line.strip() for line in data] + with open(f'{debug_dir}/smc.data', 'a') as _f: + _f.write('\n'.join(data)) + def update_progress_pane(self): """Update progress pane.""" report = [] From 9478000cdfd31976987497076ed0acbd9ec9c0f8 Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Tue, 6 Apr 2021 16:57:31 -0600 Subject: [PATCH 3/3] Add Clock Sync option to HW-Diags menu under macOS --- scripts/wk/hw/diags.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/scripts/wk/hw/diags.py b/scripts/wk/hw/diags.py index 5576970e..8b094ddc 100644 --- a/scripts/wk/hw/diags.py +++ b/scripts/wk/hw/diags.py @@ -48,6 +48,7 @@ MENU_ACTIONS = ( 'Audio Test', 'Keyboard Test', 'Network Test', + 'Clock Sync', 'Start', 'Quit') MENU_ACTIONS_SECRET = ( @@ -367,6 +368,17 @@ class State(): with open(f'{debug_dir}/smc.data', 'a') as _f: _f.write('\n'.join(data)) + def update_clock(self): + """Update 'Started' pane following clock sync.""" + tmux.respawn_pane( + pane_id=self.panes['Started'], + text=std.color_string( + ['Started', time.strftime("%Y-%m-%d %H:%M %Z")], + ['BLUE', None], + sep='\n', + ), + ) + def update_progress_pane(self): """Update progress pane.""" report = [] @@ -421,6 +433,7 @@ def audio_test_linux(): def build_menu(cli_mode=False, quick_mode=False): + # pylint: disable=too-many-branches """Build main menu, returns wk.std.Menu.""" menu = std.Menu(title=None) @@ -456,6 +469,13 @@ def build_menu(cli_mode=False, quick_mode=False): for name in ('Matrix', 'Network Test', 'Tubes'): menu.actions[name]['Disabled'] = True + # Live macOS actions + if os.path.exists('.wk-live-macos'): + menu.actions['Clock Sync']['Separator'] = True + else: + menu.actions['Clock Sync']['Disabled'] = True + menu.actions['Clock Sync']['Hidden'] = True + # Done return menu @@ -1149,6 +1169,8 @@ def main(): action = keyboard_test elif 'Network Test' in selection: action = network_test + elif 'Clock Sync' in selection: + action = sync_clock # Run simple test if action: @@ -1159,6 +1181,8 @@ def main(): std.print_warning('Aborted.') std.print_standard('') std.pause('Press Enter to return to main menu...') + if 'Clock Sync' in selection: + state.update_clock() # Secrets if 'Matrix' in selection: @@ -1406,5 +1430,15 @@ def stop_mprime(proc_mprime): set_apple_fan_speed('auto') +def sync_clock(): + """Sync clock under macOS using sntp.""" + cmd = ['sudo', 'sntp', '-Ss', 'us.pool.ntp.org'] + proc = exe.run_program(cmd, check=False) + if proc.returncode: + # Assuming we're running under an older version of macOS + cmd[2] = '-s' + exe.run_program(cmd, check=False) + + if __name__ == '__main__': print("This file is not meant to be called directly.")