-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython_project.py
More file actions
executable file
·112 lines (87 loc) · 3.12 KB
/
Copy pathpython_project.py
File metadata and controls
executable file
·112 lines (87 loc) · 3.12 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
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/usr/bin/env python3
import csv
import time
import math
import log
import mental_health as mh
import report as rp
def verify():
MAX_ATTEMPTS = 3
LOCKOUT_TIME = 5 # seconds
attempt_count = 0
while attempt_count < MAX_ATTEMPTS:
user_id = input("Enter your ID: ")
user_password = input("Enter your password: ")
with open('users.csv', mode='r') as file:
reader = csv.DictReader(file)
for row in reader:
if row['user_id'].strip() == user_id.strip() and row['password'].strip() == user_password.strip():
print("Access granted.")
return user_id
print("Access denied. Incorrect ID or password.")
attempt_count += 1
if attempt_count == MAX_ATTEMPTS:
print(f"Maximum attempt limit reached. Please try again in {LOCKOUT_TIME} seconds.")
time.sleep(LOCKOUT_TIME)
attempt_count = 0
LOCKOUT_TIME = 20 * math.log(LOCKOUT_TIME)
return None
def add_user():
new_id = input("Enter new user ID: ")
new_password = input("Enter new user password: ")
with open('users.csv', mode='a', newline='') as file:
writer = csv.DictWriter(file, fieldnames=['user_id', 'password'])
writer.writerow({'user_id': new_id, 'password': new_password})
print("New user added successfully.")
def main(user_type):
while True:
print("\nMenu: ")
print("0. Exit")
print("00. Sign out")
if user_type == "admin":
print("1. Tracker")
print("2. Mental Health")
print("3. Full Report")
print("4. System Settings")
print("5. Add User") # Admin-only feature
elif user_type != "admin": # Regular user menu
print("1. Tracker")
print("2. Mental Health")
choice = input("Enter choice: ")
if choice == '0':
print("Exiting program...")
exit(0)
elif choice == '00':
print("Signing Out...")
break
elif choice == '1':
log.log()
elif choice == '2':
mh.main()
elif user_type == "admin" and choice == '3':
while True:
print("Menu: ")
print("0. Exit")
print("1. Load weekly data")
print("2. Load daily data")
print("3. generate report")
choice = input("Enter your choice: ")
elif user_type == "admin" and choice == '4':
print("Accessing System Settings...")
elif user_type == "admin" and choice == '5':
add_user()
else:
print("Invalid choice")
if __name__ == '__main__':
while True:
print("Already a user?")
choice = input("y/n: ")
if(choice == "y"):
user_type = verify()
if(user_type):
main(user_type)
else:
exit(0)
else:
print("Request Admin to be a user...")
exit(0)