-
Notifications
You must be signed in to change notification settings - Fork 0
/
__main__.py
49 lines (39 loc) · 1.42 KB
/
__main__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
from enum import Enum
from Linux.open_ssh import is_ssh_installed, install_ssh
from Linux.package_managers import get_package_manager
class Mode(Enum):
CLIENT = 0
SERVER = 1
class Modes:
def __init__(self):
self.active_mode = None # No mode active initially
# HARDCODED MODE CHECK EDIT WHEN ADDING NEW MODES
def set_active_mode(self):
while True:
mode_input = input('Select mode (Client - 0 : Server - 1): ').strip()
# Using match-case to replace if-elif structure
match mode_input:
case "0":
self._set_mode(Mode.CLIENT)
case "1":
self._set_mode(Mode.SERVER)
case _:
print("Invalid input. Please select '0' for Client or '1' for Server.")
# Break out of the loop if mode is set
if self.active_mode is not None:
break
def _set_mode(self, mode):
if self.active_mode == mode:
print(f"Already in {mode.name.title()} mode.")
else:
self.active_mode = mode
print(f"Mode set to {mode.name.title()}.")
def get_active_mode(self):
return self.active_mode
if __name__ == '__main__':
modes = Modes()
print('WELCOME TO TETHER\n')
print(is_ssh_installed())
install_ssh(get_package_manager())
print(is_ssh_installed())
# modes.set_active_mode()