-
Notifications
You must be signed in to change notification settings - Fork 0
/
pyredb.py
81 lines (66 loc) · 2.95 KB
/
pyredb.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
#!/usr/bin/env python3
from pyrebase import *
class ForgetMeNot:
def __init__(self):
self.config = {
"apiKey": "AIzaSyASyA1nD_CMsjwefumq-8vUJzZxH6BOFNc",
"authDomain": "wearhacks17-56091.firebaseapp.com",
"databaseURL": "https://wearhacks17-56091.firebaseio.com",
"storageBucket": "wearhacks17-56091.appspot.com"
}
self.firebase = initialize_app(self.config)
self.db = self.firebase.database()
def start(self):
self.stream = self.db.stream(self.streamHandler)
print(self.stream)
# self.addSession("Jeffy", "Guffy", "2:00", "4:00", "Waterloo", "Medicare")
# self.addSession("Ert", "Geh", "4:00", "9:00", "Yeth", "Medicare")
# self.addSession("Bob", "Hiw", "1:00", "7:00", "Toronto", "Health Plus")
#self.editSession("Nim", "Feteov", "15:00", "18:00", "Toronto", "med")
#self.getAll()
# times = {"Start Time" : "01:00", "End Time" : "03:00"}
# self.db.child("Bob Fred").set(times)
##endTime = {"End Time": "8:00"}
##self.db.child("Bob Fred").set(endTime)
def addSession(self, firstName, lastName, startTime, endTime, location, clinicName):
self.db.child(firstName + " " + lastName).set({"Start Time" : startTime, "End Time" : endTime, "Location" : location, "Clinic Name" : clinicName})
def addIndex(self, curIndex):
self.db.child("stuff").set({"curIndex":curIndex})
def editIndex(self, curIndex):
self.db.child("stuff").update({"curIndex":curIndex})
def addScript(self, script):
self.db.child("scriptText").set({"text":script})
def editScript(self, script):
self.db.child("scriptText").update({"text":script})
def alert(self, state, mssg):
if state:
self.db.child("alerts").child("alert").set({"state": "true", "mssg": mssg})
else:
self.db.child("alerts").child("alert").set({"state": "false", "mssg": mssg})
def editSession(self, startTime, endTime, name, location, clinicName):
if typeOfString == "Start Time" or typeOfString == "End Time":
self.db.child(oldFirstName + " " + oldLastName).update({typeOfString : newString})
def getText(self):
# print((self.db.child("wait-no-more").get()).each())
# print(type(self.db))
# print((self.db.child("/").get()).each())
# for i in range(0, len(self.db)):
all_users = self.db.child("/").get()
masterList = []
for user in all_users.each():
text = (user.val())["curIndex"]
print(text)
return text
def streamHandler(self, post):
event = post["event"]
key = post["path"]
value = post["data"]
if event == "put":
print(key, ":", value)
if __name__ == "__main__":
a = ForgetMeNot()
a.start()
#ForgetMeNot().getText()
a.editIndex(4)
a.addScript("asdasd")
a.alert(False, "heee;sad")