-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
50 lines (50 loc) · 1.21 KB
/
main.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
#main.py
try:
import getpass
import hashlib
import svr_conn as conn
#checking dbconnection
if conn.testconn():
print("connected sucessfully")
else:
print("connected failed")
print("{:+^100}".format("Welcome to Civorution"))
while True:
print("waiting for command...")
user = ""
pswd = ""
comd = input()
#command list: "i"for log in;"u"for log up;"h"for gethelp
if comd == "i":
user = input("username:")
pswd = input("password:")
pswd = hashlib.md5(pswd.encode('utf-8')).hexdigest()
rt = conn.login(user,pswd)
if rt == -1:
print("woring username")
elif rt == 0:
print("woring password")
elif rt == 1:
print("welcome back {}".format(user))
else:
print("unexpect")
break
elif comd == "u":
print("Creating new accont...")
user = input("username:")
pswd = input("password(well not show characters):")
pswd = hashlib.md5(pswd.encode('utf-8')).hexdigest()
rt = conn.logup(user,pswd)
if rt == 0:
print("username has been ocupied")
elif rt == 1:
print("sucess")
else:
print("unexpect")
break
else:
print("command list: \"i\"for log in;\"u\"for log up;\"h\"for gethelp")
except:
print("error")
finally:
input('Press Enter to exit...')