Repository navigation
Expand file tree
/
Copy pathmain.py
More file actions
43 lines (38 loc) · 1.78 KB
/
Copy pathmain.py
File metadata and controls
43 lines (38 loc) · 1.78 KB
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
import database_manager as dm
from command import commands as c
import sys
def main():
dm.manager.setup()
while True:
success,encryption_success = c.get_user_obj()
if success and encryption_success:
print("You can write 'help' to show all commands")
while c.user:
if encryption_success: # Only if user object has been set.
# Enter 'command mode'.
command=input("Command: ")
command = c.command_format(command)
try:
s = c.commands[command]()
if not s is None:
if s[0] == "logout":
success = s[1]
encryption_success = s[2]
except KeyError:
try:
s = c.commands[c.user_shortcuts[command]]()
if not s is None:
if s[0] == "logout":
success = s[1]
encryption_success = s[2]
except KeyError:
print("Command not found. Use the command 'help' for more info.")
else:
if success:
print("LOGGED IN")
print(f"You have now logged in successfully as {c.user.get('username')}. This device has yet to be authenticated by another device where this user is already authenticated. Please log in on your other device to confirm this device's authentication.")
input("Press Enter to shutdown...")
sys.exit(0)
success, encryption_success = c.get_user_obj()
if __name__ == "__main__":
main()