Added cancel option for installing/uninstalling extensions

Former-commit-id: d594a918dbc21b9379a83e7fd01f560ba4b275ea
Former-commit-id: bfe3f71d2ee6be832e7614e4f05147e576530d78
This commit is contained in:
2023-07-06 13:02:02 -04:00
parent 43c10e74e2
commit 3cc5b5633c
+9 -3
View File
@@ -345,7 +345,7 @@ def whitelist_manage(_action):
def whitelist_menu(): def whitelist_menu():
while True: while True:
_choice = curses_radio(('setup/create pin', 'add to whitelist', 'remove from whitelist', _choice = curses_radio(('setup/create pin', 'add to whitelist', 'remove from whitelist',
'exit/done'), 'quick-unlock/whitelist management') 'BACK'), 'quick-unlock/whitelist management')
if _choice == 0: if _choice == 0:
whitelist_setup() whitelist_setup()
elif _choice == 1: elif _choice == 1:
@@ -366,7 +366,10 @@ def extension_downloader():
_pointer = ConfigParser() _pointer = ConfigParser()
_pointer.read_string(_file_data.decode('utf-8')) _pointer.read_string(_file_data.decode('utf-8'))
_extensions = _pointer.sections() _extensions = _pointer.sections()
_extensions.append('CANCEL')
_choice = curses_radio(_extensions, 'select an extension for more info') _choice = curses_radio(_extensions, 'select an extension for more info')
if _choice == len(_extensions)-1:
return False, False
_selected = _extensions[_choice-1] _selected = _extensions[_choice-1]
_choice = curses_radio(('no', 'yes'), f"install {_selected}?\n\n\n\n\ndescription: " _choice = curses_radio(('no', 'yes'), f"install {_selected}?\n\n\n\n\ndescription: "
f"{_pointer.get(_selected, 'desc')}\n\nusage: " f"{_pointer.get(_selected, 'desc')}\n\nusage: "
@@ -389,7 +392,10 @@ def extension_remover():
_installed = [] _installed = []
for _extension in listdir('/usr/lib/sshyp/extensions'): for _extension in listdir('/usr/lib/sshyp/extensions'):
_installed.append(_extension[:-4]) _installed.append(_extension[:-4])
_installed.append('CANCEL')
_choice = curses_radio(_installed, 'select an extension to uninstall') _choice = curses_radio(_installed, 'select an extension to uninstall')
if _choice == len(_installed)-1:
return False, False
_sure = curses_radio(('no', 'yes'), f"are you sure you want to remove {_installed[_choice]}?") _sure = curses_radio(('no', 'yes'), f"are you sure you want to remove {_installed[_choice]}?")
if _sure == 0: if _sure == 0:
return False, False return False, False
@@ -409,7 +415,7 @@ def extension_menu():
return "\n\u001b[38;5;9merror: privilege escalation required\n\n" \ return "\n\u001b[38;5;9merror: privilege escalation required\n\n" \
"neither 'doas' nor 'sudo' were found in the system's $PATH\u001b[0m\n", False, None, None "neither 'doas' nor 'sudo' were found in the system's $PATH\u001b[0m\n", False, None, None
while True: while True:
_choice = curses_radio(('download/update extensions', 'remove extensions', 'exit/done'), 'extension management') _choice = curses_radio(('download/update extensions', 'remove extensions', 'BACK'), 'extension management')
if _choice == 0: if _choice == 0:
_term_message, _ext_name = extension_downloader() _term_message, _ext_name = extension_downloader()
if _ext_name: if _ext_name:
@@ -443,7 +449,7 @@ def global_menu(_device_type, _top_message):
'[OPTIONAL] extension management']) '[OPTIONAL] extension management'])
else: else:
_options.extend(['manage quick-unlock/whitelist']) _options.extend(['manage quick-unlock/whitelist'])
_options.extend(['exit/done']) _options.extend(['EXIT/DONE'])
_choice += curses_radio(_options, _top_message) _choice += curses_radio(_options, _top_message)
if _choice == 0: if _choice == 0: