-
Notifications
You must be signed in to change notification settings - Fork 1
/
main_desktop.py
51 lines (43 loc) · 1.22 KB
/
main_desktop.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
import sys
import pyrebase
import time
import datetime
import threading
import subprocess
import ntplib
import time
from time import ctime
class AttendanceSystem():
config = {
"apiKey": "AIzaSyBWbttyxQRQoha0JqeanWuF4pZgKcFbGXY",
"authDomain": "brophyattendance.firebaseapp.com",
"databaseURL": "https://brophyattendance.firebaseio.com",
"storageBucket": "brophyattendance.appspot.com"
}
firebase = pyrebase.initialize_app(config)
db = firebase.database()
def __init__(self):
pass
def main(self):
code = ""
try:
while True:
try:
code = int(raw_input())
if len(str(code)) == 5:
self.post_data(code)
except ValueError:
print "Invalid Code"
except KeyboardInterrupt:
print "Closed"
def post_data(self, id):
data = {
"id": id,
"time": {".sv": "timestamp"}
}
if id == 99999:
results = self.db.child("debug").push(data)
else:
results = self.db.child("sign-in").push(data)
if __name__ == "__main__":
AttendanceSystem().main()