Added CLI options to hw-diags
This commit is contained in:
parent
ee7d656f2a
commit
72905f9ccc
1 changed files with 15 additions and 4 deletions
|
|
@ -23,11 +23,11 @@ atexit.register(tmux.kill_all_panes)
|
||||||
DOCSTRING = f'''{cfg.main.KIT_NAME_FULL}: Hardware Diagnostics
|
DOCSTRING = f'''{cfg.main.KIT_NAME_FULL}: Hardware Diagnostics
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
hw-diags
|
hw-diags [options]
|
||||||
hw-diags (-q | --quick)
|
|
||||||
hw-diags (-h | --help)
|
hw-diags (-h | --help)
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
|
-c --cli Force CLI mode
|
||||||
-h --help Show this page
|
-h --help Show this page
|
||||||
-q --quick Skip menu and perform a quick check
|
-q --quick Skip menu and perform a quick check
|
||||||
'''
|
'''
|
||||||
|
|
@ -189,7 +189,7 @@ def audio_test_linux():
|
||||||
exe.run_program(cmd, check=False, pipe=False)
|
exe.run_program(cmd, check=False, pipe=False)
|
||||||
|
|
||||||
|
|
||||||
def build_menu(quick_mode=False):
|
def build_menu(cli_mode=False, quick_mode=False):
|
||||||
"""Build main menu, returns wk.std.Menu."""
|
"""Build main menu, returns wk.std.Menu."""
|
||||||
menu = std.Menu(title=None)
|
menu = std.Menu(title=None)
|
||||||
|
|
||||||
|
|
@ -212,6 +212,11 @@ def build_menu(quick_mode=False):
|
||||||
# Only select quick option(s)
|
# Only select quick option(s)
|
||||||
menu.options[name]['Selected'] = name in MENU_OPTIONS_QUICK
|
menu.options[name]['Selected'] = name in MENU_OPTIONS_QUICK
|
||||||
|
|
||||||
|
# Add CLI actions if necessary
|
||||||
|
if cli_mode or 'DISPLAY' not in os.environ:
|
||||||
|
menu.add_action('Reboot')
|
||||||
|
menu.add_action('Power Off')
|
||||||
|
|
||||||
# Compatibility checks
|
# Compatibility checks
|
||||||
if platform.system() != 'Linux':
|
if platform.system() != 'Linux':
|
||||||
for name in ('Audio Test', 'Keyboard Test', 'Network Test'):
|
for name in ('Audio Test', 'Keyboard Test', 'Network Test'):
|
||||||
|
|
@ -278,7 +283,7 @@ def main():
|
||||||
raise RuntimeError('tmux session not found')
|
raise RuntimeError('tmux session not found')
|
||||||
|
|
||||||
# Init
|
# Init
|
||||||
menu = build_menu(args['--quick'])
|
menu = build_menu(cli_mode=args['--cli'], quick_mode=args['--quick'])
|
||||||
state = State()
|
state = State()
|
||||||
|
|
||||||
# Show menu
|
# Show menu
|
||||||
|
|
@ -314,6 +319,12 @@ def main():
|
||||||
# Quit
|
# Quit
|
||||||
if 'Quit' in selection:
|
if 'Quit' in selection:
|
||||||
break
|
break
|
||||||
|
elif 'Reboot' in selection:
|
||||||
|
cmd = ['/usr/local/bin/wk-power-command', 'reboot']
|
||||||
|
exe.run_program(cmd, check=False)
|
||||||
|
elif 'Power Off' in selection:
|
||||||
|
cmd = ['/usr/local/bin/wk-power-command', 'poweroff']
|
||||||
|
exe.run_program(cmd, check=False)
|
||||||
|
|
||||||
# Start diagnostics
|
# Start diagnostics
|
||||||
if 'Start' in selection:
|
if 'Start' in selection:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue