-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuser_add.py
More file actions
41 lines (32 loc) · 1.2 KB
/
Copy pathuser_add.py
File metadata and controls
41 lines (32 loc) · 1.2 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
import getpass
import sys
def yn_choice(message, default='y'):
choices = 'Y/n' if default.lower() in ('y', 'yes') else 'y/N'
choice = raw_input("%s [%s] " % (message, choices))
values = ('y', 'yes', '') if default == 'y' else ('y', 'yes')
return choice.strip().lower() in values
username = raw_input("Enter username: ")
valid_pass = False
while (valid_pass == False):
password = getpass.getpass("Enter new password: ")
retypepass = getpass.getpass("Retype new password: ")
if (password == retypepass):
valid_pass = True
else:
print("Sorry, passwords do not match")
if (yn_choice("Try again?", 'n') == False):
sys.exit()
print("Adding the user information for %s:" % username)
valid_info = False
while (valid_info == False):
full_name = raw_input("\tFull name: ")
room_number = raw_input("\tRoom number: ")
work_phone = raw_input("\tWork phone: ")
home_phone = raw_input("\tHome phone: ")
email = raw_input("\tE-mail: ")
if (yn_choice("Is the information correct?", 'y') == True):
valid_info = True
else:
if (yn_choice("Try again?", 'n') == False):
sys.exit()
# Store the user informations ...