-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLauncher.py
62 lines (60 loc) · 2.21 KB
/
Launcher.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
from RedisClient import RedisClient
from Keypad import Keypad
from FaceAuth import FaceAuth
from SettingParser import SettingParser
import os
import time
settingParser = SettingParser()
redisClient = RedisClient()
faceAuth = FaceAuth(settingParser.read()['FACE_API_KEY'])
keypad = Keypad()
while True:
time.sleep(2)
keypad.lcdWrite("'*'Camera mode ", "'#'password mode")
localPassword = keypad.read()
if localPassword == 'Camera':
remoteFaceId = redisClient.getFaceId()
print ('Face mode')
keypad.lcdWrite("Face Auth", "wait......")
if remoteFaceId == 'None':
keypad.lcdWrite("Face Auth", "Not have image")
continue
localFaceId = faceAuth.takePicture()
if localFaceId == 'None':
keypad.lcdWrite("Face Auth", "try again..")
print ('Cannot find face')
continue
result = faceAuth.compareFaceByIds(remoteFaceId, localFaceId)
if result == True:
# Open door
keypad.openDoor()
time.sleep(1)
keypad.lcdWrite("Face Auth", "Welcome!")
print ('Open Door')
elif result == False:
# Not You
keypad.lcdWrite("Face Auth", "try again..")
print ('Face Auth Error')
else:
remotePassword = redisClient.getPassword()
if remotePassword == localPassword:
keypad.openDoor()
time.sleep(1)
keypad.lcdWrite("Password Auth", "Welcome!")
print ('Open Door')
elif localPassword == settingParser.read()['MASTER_PW']:
keypad.openDoor()
time.sleep(1)
keypad.lcdWrite("Admin", "Welcome")
print ('Open Door')
elif localPassword == settingParser.read()['MASTER_PW'] + '*':
keypad.lcdWrite("Setting Mode", "Wait.....")
os.system("./softAP/softApTurnOn.sh")
keypad.lcdWrite("Conn All-Door", "192.168.2.1")
os.system("python app.py")
keypad.lcdWrite("Save data", "Wait.....")
os.system("./softAP/softApTurnOff.sh")
else:
# Not You
print ('Password Auth Error')
keypad.lcdWrite("Password Auth", "Fail! try again")