mirror of
https://github.com/rwinkhart/sshyp.git
synced 2026-09-05 16:47:14 -04:00
Fixed potential variable undefined errors
Former-commit-id: e5e902682c90b221f8bb58d4a5ca08f2c82bb703 Former-commit-id: c210e048d0ee28327e8302f37f9dc439db826055
This commit is contained in:
+13
-7
@@ -1,5 +1,5 @@
|
|||||||
from configparser import ConfigParser
|
from configparser import ConfigParser
|
||||||
from curses import A_REVERSE, echo, KEY_DOWN, KEY_UP, cbreak, curs_set, endwin, initscr, newwin, noecho, nocbreak
|
from curses import A_REVERSE, KEY_DOWN, KEY_UP, curs_set, newwin
|
||||||
from curses.textpad import rectangle, Textbox
|
from curses.textpad import rectangle, Textbox
|
||||||
from os import environ, listdir, remove
|
from os import environ, listdir, remove
|
||||||
from os.path import exists, expanduser, isfile
|
from os.path import exists, expanduser, isfile
|
||||||
@@ -456,11 +456,15 @@ def global_menu(_scr, _device_type, _top_message):
|
|||||||
# ...and quick-unlock settings are missing
|
# ...and quick-unlock settings are missing
|
||||||
if not sshyp_data.has_option('CLIENT-ONLINE', 'quick_unlock_enabled'):
|
if not sshyp_data.has_option('CLIENT-ONLINE', 'quick_unlock_enabled'):
|
||||||
quick_unlock_config(True)
|
quick_unlock_config(True)
|
||||||
|
# set to None to check if modified later
|
||||||
|
_ip, _username_ssh, _port = None, None, None
|
||||||
# ...and there is no sshync config present
|
# ...and there is no sshync config present
|
||||||
if not sshyp_data.has_section('SSHYNC'):
|
if not sshyp_data.has_section('SSHYNC'):
|
||||||
_ip, _username_ssh, _port = ssh_config()
|
_ip, _username_ssh, _port = ssh_config()
|
||||||
# ...and there is no device ID present
|
# ...and there is no device ID present
|
||||||
if not listdir(f"{home}/.config/sshyp/devices"):
|
if not listdir(f"{home}/.config/sshyp/devices"):
|
||||||
|
if None in (_ip, _username_ssh, _port):
|
||||||
|
_ip, _username_ssh, _port = ssh_config()
|
||||||
dev_id_config(_ip, _username_ssh, _port)
|
dev_id_config(_ip, _username_ssh, _port)
|
||||||
# ...or ssh_error is missing
|
# ...or ssh_error is missing
|
||||||
elif not sshyp_data.has_option('CLIENT-ONLINE', 'ssh_error'):
|
elif not sshyp_data.has_option('CLIENT-ONLINE', 'ssh_error'):
|
||||||
@@ -501,10 +505,8 @@ def global_menu(_scr, _device_type, _top_message):
|
|||||||
'entry directory not found\u001b[0m')
|
'entry directory not found\u001b[0m')
|
||||||
elif _choice == 7:
|
elif _choice == 7:
|
||||||
_ext_name, _escalator, _action = extension_menu()
|
_ext_name, _escalator, _action = extension_menu()
|
||||||
else:
|
|
||||||
_exit_signal = True
|
|
||||||
# if root is needed for extension management...
|
# if root is needed for extension management...
|
||||||
if _choice == 7 and _ext_name:
|
if _ext_name:
|
||||||
if _action:
|
if _action:
|
||||||
# install with privilege escalation (outside of curses)
|
# install with privilege escalation (outside of curses)
|
||||||
from tempfile import gettempdir
|
from tempfile import gettempdir
|
||||||
@@ -514,8 +516,11 @@ def global_menu(_scr, _device_type, _top_message):
|
|||||||
run((_escalator, 'mv', _ini_dir, f"/usr/lib/sshyp/extensions/{_ext_name}.ini"))
|
run((_escalator, 'mv', _ini_dir, f"/usr/lib/sshyp/extensions/{_ext_name}.ini"))
|
||||||
else:
|
else:
|
||||||
# uninstall with privilege escalation (outside of curses)
|
# uninstall with privilege escalation (outside of curses)
|
||||||
run((_escalator, 'rm', '-I', f"/usr/lib/sshyp/{_ext_name}", f"/usr/lib/sshyp/extensions/{_ext_name}.ini"))
|
run((_escalator, 'rm', '-I', f"/usr/lib/sshyp/{_ext_name}",
|
||||||
|
f"/usr/lib/sshyp/extensions/{_ext_name}.ini"))
|
||||||
break
|
break
|
||||||
|
else:
|
||||||
|
_exit_signal = True
|
||||||
if _exit_signal:
|
if _exit_signal:
|
||||||
break
|
break
|
||||||
|
|
||||||
@@ -582,8 +587,9 @@ def wrapped_entry(_gm_device_type, _gm_top_message='configuration options:'):
|
|||||||
# a boolean value represents init
|
# a boolean value represents init
|
||||||
if isinstance(_gm_device_type, bool):
|
if isinstance(_gm_device_type, bool):
|
||||||
wrapper(lambda _wrap_stdscr: (use_default_colors(), initial_setup(_wrap_stdscr)))
|
wrapper(lambda _wrap_stdscr: (use_default_colors(), initial_setup(_wrap_stdscr)))
|
||||||
# any other vlaue will be provided as the global menu device type
|
# any other value will be provided as the global menu device type
|
||||||
else:
|
else:
|
||||||
wrapper(lambda _wrap_stdscr: (use_default_colors(), global_menu(_wrap_stdscr, _gm_device_type, _gm_top_message)))
|
wrapper(lambda _wrap_stdscr: (use_default_colors(),
|
||||||
|
global_menu(_wrap_stdscr, _gm_device_type, _gm_top_message)))
|
||||||
for _message in term_messages:
|
for _message in term_messages:
|
||||||
print(f"\n{_message}\n")
|
print(f"\n{_message}\n")
|
||||||
|
|||||||
Reference in New Issue
Block a user