Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/local/bin/python3
- import random, time, os, string
- #Clear Class Variables
- def clearClasses():
- newStaff=None
- newStudent=None
- #Clear Terminal Screen
- def cls():
- os.system('cls' if os.name=='nt' else 'clear')
- pass
- #Remove punctuation characters from input date
- def dateCheck(date):
- if (date.find(string.punctuation)):
- date=date.translate(None, string.punctuation)
- return date
- #Capitalize Names
- def cleanInput(name):
- x=string.upper(name[0])
- name=x+name[1:]
- return name
- #User selects account type (staff or student)
- def typeSelect():
- print("-"*90)
- print("""
- \nPlease select the type of user:
- 1. Student
- 2. Staff
- 3. Cancel/Exit
- """)
- userType=input("Your Selection: ")
- if userType==2:
- userType="staff"
- elif userType==1:
- userType="student"
- else:
- print("Ending Script")
- exit()
- return userType
- #Student user class
- class newStudent:
- firstName = ""
- lastName = ""
- birthday = ""
- startDate = ""
- #staff user class
- class newStaff:
- firstName = ""
- lastName = ""
- startdate = ""
- #New user profile data
- def inputInfo(userCheck):
- print("-"*90+"\n")
- print("*"*90)
- print("\n\nPlease enter the user info\n\n")
- print("*"*90+"\n\n")
- if userCheck == "student":
- newStudent.firstName=raw_input("New Student First Name: ")
- newStudent.lastName=raw_input("New Student Last Name: ")
- newStudent.birthday=raw_input("New Student Birthday: ")
- newStudent.birthday=dateCheck(newStudent.birthday)
- newStudent.startDate=raw_input("New Student Start Date: ")
- newStudent.startDate=dateCheck(newStudent.startDate)
- print("\n\n"+"*"*90+"\n")
- time.sleep(1)
- cls()
- return newStudent
- if userCheck == "staff":
- newStaff.firstName=raw_input("New Staff First Name: ")
- newStaff.lastName=raw_input("New Staff Last Name: ")
- newStaff.startDate=raw_input("New Staff Start Date: ")
- print("\n\n"+"*"*90+"\n")
- time.sleep(1)
- cls()
- return newStaff
- #Generate Student user password FLastnameMMDDYYYY
- def studentPasswordGen(firstName, lastName, birthday):
- x= string.upper(firstName[0])
- y= string.upper(lastName[0])
- f= lastName[1:]
- z= str(y)+str(f)
- pw= str(x) + str(z) + str(birthday)
- return pw
- def staffPasswordGen():
- charSet=string.ascii_uppercase+ string.ascii_lowercase+ string.digits
- return ("".join(random.choice(charSet) for i in range(12)))
- #Run student user creation script (GAM)
- def studentCreation(firstName, lastName, password, startDate):
- print("Running GAM...")
- x=str(random.randint(0,9))+str(random.randint(0,9))+str(random.randint(0,9))+str(random.randint(0,9))
- os.system("~/bin/gam/gam create user "+firstName[0]+lastName[0]+x+" firstname "+firstName+" lastName "+lastName+" password "+password+" org '/kec root/restart/students' changepassword off")
- #Run staff user creation script (GAM)
- def staffCreation(firstName, lastName, password, startDate):
- print("Running GAM...")
- os.system("~/bin/gam/gam create user "+firstName[0]+lastName+" firstname " +firstName+" lastname "+lastName+" password "+password)
- #Print data input and confirmation request.
- def printData(userCheck):
- print("-"*90+"\n")
- print("New Account Info to be Input: \n")
- if userCheck=="student":
- password=studentPasswordGen(newStudent.firstName, newStudent.lastName, newStudent.birthday)
- print("*"*90+"\n\n")
- newStudent.firstName=cleanInput(newStudent.firstName)
- newStudent.lastName=cleanInput(newStudent.lastName)
- print("New Student First Name: "+newStudent.firstName)
- print("New Student Last Name: "+newStudent.lastName)
- print("New Student Password: "+str(password))
- print("New Student Start Date: "+newStudent.startDate)
- print("\n\n"+"*"*90+"\n")
- print("""If this information is correct please make appropriate selection:
- 1: Yes this information is correct.
- 2: No this information is incorrect.\n""")
- selection=raw_input("Please make selection (1 or 2): ")
- if selection=="1":
- #move forward
- print("*"*90+"\n\n")
- print("Moving forward...")
- print("\n\n"+"*"*90+"\n")
- studentCreation(newStudent.firstName, newStudent.lastName, password, newStudent.startDate)
- elif selection=="2":
- print("*"*90+"\n\n")
- print("Starting over...")
- print("\n\n"+"*"*90+"\n")
- time.sleep(3)
- Main()
- else:
- printData(userCheck)
- if userCheck=="staff":
- password=staffPasswordGen()
- newStaff.firstName=cleanInput(newStaff.firstName)
- newStaff.lastName=cleanInput(newStaff.lastName)
- print("*"*90+"\n\n")
- print("New Staff First Name: "+newStaff.firstName)
- print("New Staff Last Name: "+newStaff.lastName)
- print("New Staff Password: "+str(password))
- print("New Staff Start Date: "+newStaff.startDate)
- print("\n\n"+"*"*90+"\n")
- print("""If this information is correct please make appropriate selection:
- 1: Yes this information is correct.
- 2: No this information is incorrect.\n""")
- selection=raw_input("Please make selection (1 or 2): ")
- if selection=="1":
- #move forward
- print("*"*90+"\n\n")
- print("Moving forward...")
- print("\n\n"+"*"*90+"\n")
- staffCreation(newStaff.firstName, newStaff.lastName, password, newStaff.startDate)
- elif selection=="2":
- print("*"*90+"\n\n")
- print("Starting over...")
- print("\n\n"+"*"*90+"\n")
- time.sleep(3)
- Main()
- else:
- printData(userCheck)
- def Main():
- cls()
- clearClasses()
- userType = typeSelect()
- inputInfo(userType)
- printData(userType)
- clearClasses()
- Main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement