-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
45 lines (40 loc) 路 1.59 KB
/
Copy pathmain.py
File metadata and controls
45 lines (40 loc) 路 1.59 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
44
45
import sys
import traceback
from cryptography.fernet import Fernet
from app import settings
from app.config import get_or_create_config, initialize_config
from app.vault_app import FileVaultApp
from cli_interface.Questionary.questionary_tui import QuestionaryTUI
from encryption_key_generator import get_or_create_key
def main(fernet, config):
vault = FileVaultApp(fernet, config)
print("馃敀 Welcome to the FileVault! ")
try:
ui = QuestionaryTUI(vault=vault)
while True:
ui.run()
except KeyboardInterrupt:
print("Bye!")
sys.exit(0)
except Exception as e:
tb = traceback.TracebackException.from_exception(e)
print("\033[91m" + f"Fatal error: {e}" + "\033[0m")
for line in tb.format():
print("\033[91m" + line.strip() + "\033[0m")
if __name__ == '__main__':
try:
# Load the encryption key
encryption_key = get_or_create_key()
fernet = Fernet(encryption_key)
# Setup the config paths and create files if not existing
config_path, default_config_path = initialize_config()
# Prompt user to use default or input manual config
config = get_or_create_config(config_path, default_config_path)
# Make config class and path global for access through the settings module
settings.configure(config, str(config_path))
main(fernet, config)
except OSError as e:
print(f"App startup error: {e}")
tb = traceback.TracebackException.from_exception(e)
for line in tb.format():
print("\033[91m" + line.strip() + "\033[0m")