Merge remote-tracking branch 'upstream/dev' into dev
This commit is contained in:
commit
86f0f14c34
1 changed files with 49 additions and 0 deletions
|
|
@ -48,6 +48,7 @@ MENU_ACTIONS = (
|
|||
'Audio Test',
|
||||
'Keyboard Test',
|
||||
'Network Test',
|
||||
'Clock Sync',
|
||||
'Start',
|
||||
'Quit')
|
||||
MENU_ACTIONS_SECRET = (
|
||||
|
|
@ -380,6 +381,32 @@ class State():
|
|||
with open(f'{debug_dir}/osTicket.report', 'a') as _f:
|
||||
_f.write('\n'.join(debug.generate_object_report(self.ost)))
|
||||
|
||||
# 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_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 = []
|
||||
|
|
@ -434,6 +461,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)
|
||||
|
||||
|
|
@ -472,6 +500,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
|
||||
|
||||
|
|
@ -1197,6 +1232,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:
|
||||
|
|
@ -1207,6 +1244,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:
|
||||
|
|
@ -1711,5 +1750,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.")
|
||||
|
|
|
|||
Loading…
Reference in a new issue