-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.py
93 lines (80 loc) · 2 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
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
from threading import Thread, Condition, Timer
import sklearn
import time
import serial
import os, sys
import datetime
import socket
import glob
import ipaddress
import cv2
import numpy as np
import nfc
from pygame import mixer
import sqlite3
import config
#import db_handler
import new_db_handler
#from verification import *
from new_verification import *
from detectors import *
from webcam import *
from relay import *
from card import *
import sound
def main():
thread_arr = []
detector = cv2.QRCodeDetector()
db = new_db_handler.Userdb()
# db.delete_table()
# db.table_create()
# db.delete_by_eppn("[email protected]")
# db.insert_andrew()
# db.delete_by_eppn('[email protected]')
# db.insert_user('[email protected]', 'Nicho', '12345678', '01234567', '12345678', '4321', 'Y', 'N', '')
db.get_all()
db.close()
config.ser = serUSB()
sound.init_sound()
# relay_on()
#show_webcam(mirror=True)
'''
thread = Thread(target = receiver, args = [])
thread.start()
thread_arr.append(thread)
'''
thread = Thread(target = show_webcam, args = [False])
thread.start()
thread_arr.append(thread)
thread = Thread(target = card, args = [])
thread.start()
thread_arr.append(thread)
thread = Thread(target = relay_loop, args = [])
thread.start()
thread_arr.append(thread)
print("server started")
while True:
try:
time.sleep(0.5)
except KeyboardInterrupt:
config.done = True
os.system("killall python3")
print("main interrupted")
for th in thread_arr:
th.join()
break
ser.close()
'''
def test1(): # for DB testing only
db = db_handler.userdb()
db.delete_by_eppn("[email protected]")
db.insert_andrew()
#db.get_all()
# r = db.get_by_cardID('97505fc8')
r = db.get_by_cardID('c7a451c8')
if r:
print(r['eppn'])
db.delete_by_eppn("[email protected]")
'''
if __name__ == '__main__':
main()