Added keyboard_test()
This commit is contained in:
parent
100757ba69
commit
fe228a5edc
1 changed files with 49 additions and 10 deletions
|
|
@ -102,17 +102,18 @@ def audio_test_linux():
|
||||||
run_program(cmd, check=False, pipe=False)
|
run_program(cmd, check=False, pipe=False)
|
||||||
|
|
||||||
|
|
||||||
def main_menu():
|
def build_menu(quick_mode=False):
|
||||||
"""Main menu for hardware diagnostics."""
|
"""Build main menu, returns wk.std.Menu."""
|
||||||
args = docopt(DOCSTRING)
|
|
||||||
menu = Menu()
|
menu = Menu()
|
||||||
|
|
||||||
# Build menu
|
# Set title
|
||||||
menu.title = color_string(
|
menu.title = color_string(
|
||||||
strings=['Hardware Diagnostics', 'Main Menu'],
|
strings=['Hardware Diagnostics', 'Main Menu'],
|
||||||
colors=['GREEN', None],
|
colors=['GREEN', None],
|
||||||
sep='\n',
|
sep='\n',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Add actions, options, etc
|
||||||
for action in MENU_ACTIONS:
|
for action in MENU_ACTIONS:
|
||||||
menu.add_action(action)
|
menu.add_action(action)
|
||||||
for option in MENU_OPTIONS:
|
for option in MENU_OPTIONS:
|
||||||
|
|
@ -123,8 +124,8 @@ def main_menu():
|
||||||
menu.add_set(name, {'Targets': targets})
|
menu.add_set(name, {'Targets': targets})
|
||||||
menu.actions['Start']['Separator'] = True
|
menu.actions['Start']['Separator'] = True
|
||||||
|
|
||||||
# Check if running a quick check
|
# Update default selections for quick mode if necessary
|
||||||
if args['--quick']:
|
if quick_mode:
|
||||||
for name in menu.options.keys():
|
for name in menu.options.keys():
|
||||||
# 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
|
||||||
|
|
@ -134,16 +135,54 @@ def main_menu():
|
||||||
for name in ('Audio Test', 'Keyboard Test', 'Network Test'):
|
for name in ('Audio Test', 'Keyboard Test', 'Network Test'):
|
||||||
menu.actions[name]['Disabled'] = True
|
menu.actions[name]['Disabled'] = True
|
||||||
|
|
||||||
|
# Done
|
||||||
|
return menu
|
||||||
|
|
||||||
|
|
||||||
|
def keyboard_test():
|
||||||
|
"""Test keyboard using xev."""
|
||||||
|
cmd = ['xev', '-event', 'keyboard']
|
||||||
|
clear_screen()
|
||||||
|
run_program(cmd, check=False, pipe=False)
|
||||||
|
|
||||||
|
|
||||||
|
def main_menu():
|
||||||
|
"""Main menu for hardware diagnostics."""
|
||||||
|
args = docopt(DOCSTRING)
|
||||||
|
menu = build_menu(args['--quick'])
|
||||||
|
|
||||||
# Show menu
|
# Show menu
|
||||||
while True:
|
while True:
|
||||||
|
action = None
|
||||||
selection = menu.advanced_select()
|
selection = menu.advanced_select()
|
||||||
|
|
||||||
|
# Set action
|
||||||
if 'Audio Test' in selection:
|
if 'Audio Test' in selection:
|
||||||
audio_test()
|
action = audio_test
|
||||||
if 'Network Test' in selection:
|
elif 'Keyboard Test' in selection:
|
||||||
network_test()
|
action = keyboard_test
|
||||||
elif 'Quit' in selection:
|
elif 'Network Test' in selection:
|
||||||
|
action = network_test
|
||||||
|
|
||||||
|
# Run simple test
|
||||||
|
if action:
|
||||||
|
try:
|
||||||
|
action()
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
print_warning('Aborted.')
|
||||||
|
print_standard('')
|
||||||
|
pause('Press Enter to return to main menu...')
|
||||||
|
|
||||||
|
# Quit
|
||||||
|
if 'Quit' in selection:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
# Start diagnostics
|
||||||
|
if 'Start' in selection:
|
||||||
|
#TODO
|
||||||
|
#run_diags()
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def network_test():
|
def network_test():
|
||||||
"""Run network tests."""
|
"""Run network tests."""
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue