-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigurator.py
91 lines (76 loc) · 2.42 KB
/
configurator.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
from configparser import ConfigParser
from getpass import getpass
import inquirer
from inquirer.themes import GreenPassion
# initialize required variables
config = ConfigParser()
config.read("configFiles/database.ini")
# def for the general Config
def generalconf():
config["general"]["locktime"] = input(
"How long should it take to detect that "
"the computer has not been locked?"
f"\nCurrent saved value: {config['general']['locktime']} minutes"
"\nThe input should be a number and is calculated in minutes: "
)
# def for the db Config
def dbconf():
config["database"]["host"] = input(
"Enter the host name of the database\n"
f"Current saved value: {config['database']['host']}: "
)
config["database"]["dbname"] = input(
"Enter the name of the database\n"
f"Current saved value: {config['database']['dbname']}: "
)
config["database"]["user"] = input(
"Enter the username of the database\n"
f"Current saved value: {config['database']['user']}: "
)
config["database"]["port"] = input(
"Enter the port of the database\n"
f"Current saved value: {config['database']['port']}: "
)
while True:
password = getpass("Enter the password of the database: ")
password2 = getpass("Confirm password: ")
if password != password2:
input(
"The entered passwords are not equal - "
"The password has not been saved!"
)
else:
config["database"]["password"] = password
break
# Start - Banner
print(f"{30 * '#'}\n" "lazyLogger - configuration\n" f"{30 * '#'}\n")
# Navigation
config_options = [
"Everything",
"The Database",
"General settings",
"X NOTHING X",
]
config_option_selection = inquirer.prompt(
[
inquirer.List(
"selection",
message="WHAT WOULD YOU LIKE TO CONFIGURE?",
choices=config_options,
default="",
)
],
theme=GreenPassion(),
)
selected_option = config_option_selection["selection"]
if selected_option == config_options[0]:
generalconf()
dbconf()
elif selected_option == config_options[1]:
dbconf()
elif selected_option == config_options[2]:
generalconf()
elif selected_option == config_options[3]:
print("BYE.")
with open("configFiles/database.ini", "w") as configfile:
config.write(configfile)