From b95c65190854bd74d2c35b57232a1f012fd2163d Mon Sep 17 00:00:00 2001 From: Surayez Date: Thu, 1 Jun 2017 10:33:32 +1000 Subject: [PATCH 1/9] Create backend.py --- backend.py | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 backend.py diff --git a/backend.py b/backend.py new file mode 100644 index 0000000..26042ef --- /dev/null +++ b/backend.py @@ -0,0 +1,90 @@ +from firebase import firebase +firebase = firebase.FirebaseApplication('https://learntogether-a250b.firebaseio.com/') + +def fileUpload(firebase,file,user): + unitFile = open(file, 'r') + unitList = [] + + #converts file into readable format (i.e. List) + for line in unitFile: + unitList.append(line) + + unitFile.close() + unitStored = [] + #converts into usable name + # 0 - Unit Code + # 2 - Group + # 3 - Session + # 4 - Day && 5 - Time + # 7 - Location + #uniStored[4] = group + #uniStored[5] = activity + + for i in range(1,len(unitList)): + unitLine = unitList[i].strip().split("\t") + unitName = unitLine[0].split("_") + unitLine[0]=unitName[0] + unitStrip = [] + unitStrip.append(unitLine[0]) + unitStrip.append(unitLine[2]+unitLine[3]) + unitStrip.append(unitLine[4]+unitLine[5]) + unitStrip.append(unitLine[7].replace("/","-")) + unitStrip.append(unitLine[2]) + unitStrip.append(unitLine[3]) + if unitLine[9][1] == ".": + unitLine[9] = unitLine[9][:3] + else: + unitLine[9] = unitLine[9][0] + unitStrip.append(unitLine[9]) + unitStored.append(unitStrip) + + print("unitStored",unitStored) + + unit = [] + for item in unitStored: + unitStore = item[0] + "*" + item[1] + "*" + item[2] + "*" + item[3] + "*" + item[6] + unit.append(unitStore) + + print("unit", unit) + + newUnit = [] #all units from single user + for p in range(len(unit)): + newUnit.append([]) + + for x in range(len(unit)): + newUnit[x].append(unitStored[x][0]) + newUnit[x].append(unitStored[x][4]) + newUnit[x].append(unitStored[x][5]+unitStored[x][2]) + + firebase.put("","users/"+user+"/classes", unit) + + classes = firebase.get("","/classes/") + print("classes", classes) + + # if classes != None: + # for each in unit: + # if each in classes: + # tempUsers = [] + # for x in range(len(unit)): + # tempUsers.append(firebase.get('', '/classes/' + unit[x] + '/users/')) + # if user not in tempUsers[x]: + # tempUsers[x].append(user) + # + # print("Temp: ", tempUsers) + # + # dictionary = "" + # for i in range(len(unit)): + # dictionary = {'location': unitStored[i][3], 'time': unitStored[i][2], 'unitID': unitStored[i][0], + # 'group': unitStored[i][1], 'users': tempUsers[i]} + # firebase.put("", "/classes/" + str(unit[i]), dictionary) + # else: + + dictionary = "" + for i in range(len(unit)): + dictionary = {'location': unitStored[i][3], 'time': unitStored[i][2], 'unitID': unitStored[i][0],'group': unitStored[i][1], 'users': [user]} + firebase.put("", "/classes/" + str(unit[i]), dictionary) + +file = 'timetable-10001000.txt' +user = "test5" + +fileUpload(firebase,file,user) From 11d858ba9822263aaf5b0db186d3b3dd6e8717c4 Mon Sep 17 00:00:00 2001 From: Surayez Date: Thu, 1 Jun 2017 14:54:03 +1000 Subject: [PATCH 2/9] Updated backend.py --- backend.py | 91 ++++++++++++++++++++++++------------------------------ 1 file changed, 40 insertions(+), 51 deletions(-) diff --git a/backend.py b/backend.py index 26042ef..c8b6f8f 100644 --- a/backend.py +++ b/backend.py @@ -1,24 +1,16 @@ from firebase import firebase firebase = firebase.FirebaseApplication('https://learntogether-a250b.firebaseio.com/') -def fileUpload(firebase,file,user): + +def fileReader(firebase, file, user): unitFile = open(file, 'r') unitList = [] - #converts file into readable format (i.e. List) for line in unitFile: unitList.append(line) unitFile.close() unitStored = [] - #converts into usable name - # 0 - Unit Code - # 2 - Group - # 3 - Session - # 4 - Day && 5 - Time - # 7 - Location - #uniStored[4] = group - #uniStored[5] = activity for i in range(1,len(unitList)): unitLine = unitList[i].strip().split("\t") @@ -38,53 +30,50 @@ def fileUpload(firebase,file,user): unitStrip.append(unitLine[9]) unitStored.append(unitStrip) - print("unitStored",unitStored) - - unit = [] - for item in unitStored: - unitStore = item[0] + "*" + item[1] + "*" + item[2] + "*" + item[3] + "*" + item[6] - unit.append(unitStore) + unitOut = unitStored + unitSimple = [] + unitSimpleTemp = [] + for unitRef in unitOut: + unitStore = unitRef[0]+"*"+unitRef[1]+"*"+unitRef[2]+"*"+unitRef[3] + unitStoreTemp = unitRef[0]+"*"+unitRef[1]+"*"+unitRef[2]+"*"+unitRef[3]+ "*" +unitRef[6] + unitSimple.append(unitStore) + unitSimpleTemp.append(unitStoreTemp) + unit = unitSimple + unitTemp = unitSimpleTemp - print("unit", unit) + firebase.put("", "users/" + str(user[0]) + "/classes", unitTemp) - newUnit = [] #all units from single user + newUnit = [] for p in range(len(unit)): newUnit.append([]) for x in range(len(unit)): - newUnit[x].append(unitStored[x][0]) - newUnit[x].append(unitStored[x][4]) - newUnit[x].append(unitStored[x][5]+unitStored[x][2]) - - firebase.put("","users/"+user+"/classes", unit) - - classes = firebase.get("","/classes/") - print("classes", classes) - - # if classes != None: - # for each in unit: - # if each in classes: - # tempUsers = [] - # for x in range(len(unit)): - # tempUsers.append(firebase.get('', '/classes/' + unit[x] + '/users/')) - # if user not in tempUsers[x]: - # tempUsers[x].append(user) - # - # print("Temp: ", tempUsers) - # - # dictionary = "" - # for i in range(len(unit)): - # dictionary = {'location': unitStored[i][3], 'time': unitStored[i][2], 'unitID': unitStored[i][0], - # 'group': unitStored[i][1], 'users': tempUsers[i]} - # firebase.put("", "/classes/" + str(unit[i]), dictionary) - # else: - - dictionary = "" + newUnit[x].append(unitOut[x][0]) + newUnit[x].append(unitOut[x][4]) + newUnit[x].append(unitOut[x][5]+unitOut[x][2]) + + + oldUsers = [] + for n in range(len(unit)): + oldUsers.append([]) + temp = [] + + for x in range(len(unit)): + temp.append(firebase.get('','/classes/'+unit[x]+'/users/')) + if temp[x] not in oldUsers[x] and temp[x] is not None: + oldUsers[x].extend(temp[x]) + + if user[0] not in oldUsers[x]: + oldUsers[x].extend(user) + for i in range(len(unit)): - dictionary = {'location': unitStored[i][3], 'time': unitStored[i][2], 'unitID': unitStored[i][0],'group': unitStored[i][1], 'users': [user]} - firebase.put("", "/classes/" + str(unit[i]), dictionary) + dictionary = {'location': unitOut[i][3], 'time': unitOut[i][2], 'unitID': unitOut[i][0], 'group':unitOut[i][1],'users':oldUsers[i]} + firebase.put("","/classes/"+str(unit[i]),dictionary) -file = 'timetable-10001000.txt' -user = "test5" + #End of function -fileUpload(firebase,file,user) + +### Main +file = 'timetable-10001000.txt' +user = ["Ishan"] +fileReader(firebase, file, user) From 005a098116c82b26bcfec592ceb4b4cea316ca17 Mon Sep 17 00:00:00 2001 From: learntog Date: Thu, 1 Jun 2017 22:02:05 +1000 Subject: [PATCH 3/9] Create swap.py Swapping timetable slots, gives a list of user to user action. --- swap.py | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 swap.py diff --git a/swap.py b/swap.py new file mode 100644 index 0000000..6b96d57 --- /dev/null +++ b/swap.py @@ -0,0 +1,48 @@ +import networkx as nx +from firebase import firebase + +firebase = firebase.FirebaseApplication('https://learntogether-a250b.firebaseio.com/') +swaps = firebase.get("", "/swaps/unitcode/typeofactivity/") + +edgesindex = {} +listofgraphtuple = [] + +for each in swaps: + edgekeys = [] + edgekey = "" + currentedge = swaps[each][0] + for i in range(1,len(swaps[each])): + edgekey = currentedge + swaps[each][i] + listofgraphtuple.append((currentedge, swaps[each][i])) + edgekeys.append(edgekey) + edgekey = "" + for key in edgekeys: + edgesindex[key] = each + #print (edgekeys) + +print(edgesindex) +print(listofgraphtuple) + +G = nx.DiGraph(listofgraphtuple) +solution = list(nx.simple_cycles(G)) + +for x in solution: + x+=[x[0]] +print(solution) + +useraction = [] +for solutionz in solution: + actions = [] + for i in range(len(solutionz) - 1): + actions.append(edgesindex[solutionz[i]+solutionz[i+1]]) + useraction.append(actions) +print(useraction) + +""" +OUTPUT: +{'8pm4pm': 'uid', '4pm8pm': 'uid1', '4pm6pm': 'uid2', '6pm8pm': 'uid3', '6pm4pm': 'uid3', '6pm10am': 'uid3'} +[('8pm', '4pm'), ('4pm', '8pm'), ('4pm', '6pm'), ('6pm', '8pm'), ('6pm', '4pm'), ('6pm', '10am')] +[['6pm', '4pm', '6pm'], ['6pm', '8pm', '4pm', '6pm'], ['4pm', '8pm', '4pm']] +[['uid3', 'uid2'], ['uid3', 'uid', 'uid2'], ['uid1', 'uid']] +""" + From c29d2610693f230891ed84f8dedd6eb36e2b6974 Mon Sep 17 00:00:00 2001 From: learntog Date: Sun, 11 Jun 2017 22:21:44 +1000 Subject: [PATCH 4/9] Create newbackend.py --- newbackend.py | 139 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 139 insertions(+) create mode 100644 newbackend.py diff --git a/newbackend.py b/newbackend.py new file mode 100644 index 0000000..19a138b --- /dev/null +++ b/newbackend.py @@ -0,0 +1,139 @@ +#use this updated version +import pyrebase +""" +TODO: +""" +#TODO add file check (is legit text file) +#TODO only add semester 1 + + +from firebase import firebase +firebase = firebase.FirebaseApplication('https://learntogether-a250b.firebaseio.com/') + +config = { + 'apiKey': "AIzaSyBLA6sDqXwnMX6tJayM4dmYCPRzt5CW91M", + 'authDomain': "learntogether-a250b.firebaseapp.com", + 'databaseURL': "https://learntogether-a250b.firebaseio.com", + 'storageBucket': "learntogether-a250b.appspot.com", +} + + +pybase = pyrebase.initialize_app(config) + + +storage = pybase.storage() + +def fileReader(firebase, file, user): + unitFile = open(file, 'r') + unitList = [] + + for line in unitFile: + unitList.append(line) + + unitFile.close() + unitStored = [] + + for i in range(1,len(unitList)): + unitLine = unitList[i].strip().split("\t") + unitName = unitLine[0].split("_") + unitLine[0]=unitName[0] + unitStrip = [] + unitStrip.append(unitLine[0]) + unitStrip.append(unitLine[2]+unitLine[3]) + unitStrip.append(unitLine[4]+unitLine[5]) + unitStrip.append(unitLine[7].replace("/","-")) + unitStrip.append(unitLine[2]) + unitStrip.append(unitLine[3]) + if unitLine[9][1] == ".": + unitLine[9] = unitLine[9][:3] + else: + unitLine[9] = unitLine[9][0] + unitStrip.append(unitLine[9]) + unitStored.append(unitStrip) + + + unitOut = unitStored + + unitSimple = [] + unitSimpleTemp = [] + for unitRef in unitOut: + unitStore = unitRef[0]+"*"+unitRef[1]+"*"+unitRef[2][0:3]+"*"+unitRef[2][3:]+"*"+unitRef[3]+"*"+unitRef[-1].replace(".", "~") + unitStoreTemp = unitRef[0]+"*"+unitRef[1]+"*"+unitRef[2][0:3]+"*"+unitRef[2][3:]+"*"+unitRef[3]+"*"+unitRef[-1].replace(".", "~") + + # print(unitStore, unitStoreTemp) + + unitSimple.append(unitStore) + unitSimpleTemp.append(unitStoreTemp) + unit = unitSimple + #print(unit) + #print() + unitTemp = unitSimpleTemp + + + firebase.put("", "users/" + str(user[0]) + "/classes", unitTemp) + + newUnit = [] + for p in range(len(unit)): + newUnit.append([]) + + for x in range(len(unit)): + newUnit[x].append(unitOut[x][0]) + newUnit[x].append(unitOut[x][4]) + newUnit[x].append(unitOut[x][5]+unitOut[x][2]) + + #print(unit, newUnit) + + oldUsers = [] + for n in range(len(unit)): + oldUsers.append([]) + temp = [] + + for x in range(len(unit)): + try: + a = firebase.get('','classes/'+unit[x]+'/users/') + #print(unit[x]) + + temp.append(a) + + if temp[x] not in oldUsers[x] and temp[x] is not None: + oldUsers[x].extend(temp[x]) + + if user[0] not in oldUsers[x]: + oldUsers[x].extend(user) + except Exception as e: + firebase.put('/', 'requests/' + str(user[0]) + "/status", 'ERR'+str(e)) + + for i in range(len(unit)): + dictionary = {'location': unitOut[i][3], 'time': unitOut[i][2], 'unitID': unitOut[i][0], 'group':unitOut[i][1],'users':oldUsers[i]} + firebase.put("","classes/"+str(unit[i]),dictionary) + + firebase.put('/', 'requests/' + str(user[0]) + "/status", 'SUCCESS') + #End of function + + +### Main + + +requests = firebase.get('/','requests/') +#print(requests) +#Download all the files +for request in requests: + if(requests[request]['status'] == "UPLOAD"): + storage.child("usertimetable/"+request).download("user_files/"+request) + firebase.put('/','requests/'+request+"/status", 'DOWNLOADED') + +for request in requests: + if(requests[request]['status']!="SUCCESS"): + user = request + fileReader(firebase, "user_files/"+user, [user]) +# +# file = 'timetable-10001000.txt' +# user = ["Ishan"] +# fileReader(firebase, file, user) + + + + + + +#storage.child("hey/28809033.txt").download("288090331.txt") From 7067c8e4c4d83139d33bbcde52882e37e6a2f282 Mon Sep 17 00:00:00 2001 From: learntog Date: Mon, 12 Jun 2017 13:43:46 +1000 Subject: [PATCH 5/9] Create newbackend.py --- newbackend.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/newbackend.py b/newbackend.py index 19a138b..c5a3135 100644 --- a/newbackend.py +++ b/newbackend.py @@ -107,7 +107,7 @@ def fileReader(firebase, file, user): dictionary = {'location': unitOut[i][3], 'time': unitOut[i][2], 'unitID': unitOut[i][0], 'group':unitOut[i][1],'users':oldUsers[i]} firebase.put("","classes/"+str(unit[i]),dictionary) - firebase.put('/', 'requests/' + str(user[0]) + "/status", 'SUCCESS') + firebase.put('/', 'requests/' + str(user[0]) + "/status", 'SUCCESS') #End of function From 1616667aa19cf8b00772de989f3693469eda0415 Mon Sep 17 00:00:00 2001 From: Ishan Joshi Date: Fri, 16 Jun 2017 19:00:35 +1000 Subject: [PATCH 6/9] Create backend_optimized.py --- backend_optimized.py | 171 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 171 insertions(+) create mode 100644 backend_optimized.py diff --git a/backend_optimized.py b/backend_optimized.py new file mode 100644 index 0000000..000601d --- /dev/null +++ b/backend_optimized.py @@ -0,0 +1,171 @@ +import datetime +import json +import os.path + +import pyrebase +""" +TODO: +""" +#TODO add file check (is legit text file) +#TODO only add semester 1 + + +from firebase import firebase +firebase = firebase.FirebaseApplication('https://learntogether-a250b.firebaseio.com/') + +config = { + 'apiKey': "AIzaSyBLA6sDqXwnMX6tJayM4dmYCPRzt5CW91M", + 'authDomain': "learntogether-a250b.firebaseapp.com", + 'databaseURL': "https://learntogether-a250b.firebaseio.com", + 'storageBucket': "learntogether-a250b.appspot.com", +} + + +pybase = pyrebase.initialize_app(config) + + +allclasses = None +if os.path.exists("classes.json"): + j = open("classes.json", 'r+') + allclasses = json.load(j) + j.close() +else: + allclasses = firebase.get("","classes/") + j = open("classes.json", 'w') + json.dump(allclasses, j) + j.close() + +print(allclasses) + + + +storage = pybase.storage() + +def fileReader(firebase, file, user): + unitFile = open(file, 'r') + unitList = [] + + for line in unitFile: + unitList.append(line) + + unitFile.close() + unitStored = [] + + for i in range(1,len(unitList)): + unitLine = unitList[i].strip().split("\t") + unitName = unitLine[0].split("_") + unitLine[0]=unitName[0] + unitStrip = [] + unitStrip.append(unitLine[0]) + unitStrip.append(unitLine[2]+unitLine[3]) + unitStrip.append(unitLine[4]+unitLine[5]) + unitStrip.append(unitLine[7].replace("/","-")) + unitStrip.append(unitLine[2]) + unitStrip.append(unitLine[3]) + if unitLine[9][1] == ".": + unitLine[9] = unitLine[9][:3] + else: + unitLine[9] = unitLine[9][0] + unitStrip.append(unitLine[9]) + unitStored.append(unitStrip) + + + unitOut = unitStored + + unitSimple = [] + unitSimpleTemp = [] + for unitRef in unitOut: + unitStore = unitRef[0]+"*"+unitRef[1]+"*"+unitRef[2][0:3]+"*"+unitRef[2][3:]+"*"+unitRef[3]+"*"+unitRef[-1].replace(".", "~") + unitStoreTemp = unitRef[0]+"*"+unitRef[1]+"*"+unitRef[2][0:3]+"*"+unitRef[2][3:]+"*"+unitRef[3]+"*"+unitRef[-1].replace(".", "~") + + # print(unitStore, unitStoreTemp) + + unitSimple.append(unitStore) + unitSimpleTemp.append(unitStoreTemp) + unit = unitSimple + #print(unit) + #print() + unitTemp = unitSimpleTemp + + + firebase.put("", "users/" + str(user[0]) + "/classes", unitTemp) + + newUnit = [] + for p in range(len(unit)): + newUnit.append([]) + + for x in range(len(unit)): + newUnit[x].append(unitOut[x][0]) + newUnit[x].append(unitOut[x][4]) + newUnit[x].append(unitOut[x][5]+unitOut[x][2]) + + #print(unit, newUnit) + + oldUsers = [] + for n in range(len(unit)): + oldUsers.append([]) + temp = [] + + for x in range(len(unit)): + try: + #a = firebase.get('','classes/'+unit[x]+'/users/') + #print(unit[x]) + + a = allclasses[unit[x]]['users'] + + temp.append(a) + + if temp[x] not in oldUsers[x] and temp[x] is not None: + oldUsers[x].extend(temp[x]) + + if user[0] not in oldUsers[x]: + oldUsers[x].extend(user) + except Exception as e: + firebase.put('/', 'requests/' + str(user[0]) + "/status", 'ERR'+str(e)) + + for i in range(len(unit)): + dictionary = {'users':oldUsers[i]} + firebase.put("","classes/"+str(unit[i]),dictionary) + allclasses[str(unit[i])] = dictionary + + j = open("classes.json", 'w') + json.dump(allclasses, j) + j.close() + + + firebase.put('/', 'requests/' + str(user[0]) + "/status", 'SUCCESS') + #End of function + + +### Main + + +requests = firebase.get('/','requests/') +#print(requests) +#Download all the files + +for request in requests: + if(requests[request]['status'] == "UPLOAD"): + storage.child("usertimetable/"+request).download("user_files/"+request) + firebase.put('/','requests/'+request+"/status", 'DOWNLOADED') + + + +for request in requests: + if(requests[request]['status']!="SUCCESS"): + user = request + fileReader(firebase, "user_files/"+user, [user]) + + + +# +# file = 'timetable-10001000.txt' +# user = ["Ishan"] +# fileReader(firebase, file, user) + + + + + + +#storage.child("hey/28809033.txt").download("288090331.txt") From 11aa2e952f5cd4cbff71696511861e0b07bc8653 Mon Sep 17 00:00:00 2001 From: Ishan Joshi Date: Sat, 17 Jun 2017 12:14:06 +1000 Subject: [PATCH 7/9] Create seperate_unit_types.py --- seperate_unit_types.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 seperate_unit_types.py diff --git a/seperate_unit_types.py b/seperate_unit_types.py new file mode 100644 index 0000000..4988f28 --- /dev/null +++ b/seperate_unit_types.py @@ -0,0 +1,30 @@ +import json +classes = json.load(open("classes.json")) + +upload = {} + +def GetTextOnly(s): + return ''.join([i for i in s if not i.isdigit()]) + + +for cl in classes: + cll = cl.split("*") + #check if the unit is present + unit = cll[0] + if(unit not in upload): + upload[unit] = {} + type = GetTextOnly(cll[1]) + if(type not in upload[unit]): + upload[unit][type] = [] + upload[unit][type].append(cl) + +from firebase import firebase +firebase = firebase.FirebaseApplication('https://learntogether-a250b.firebaseio.com/') + +firebase.put('','seperate_unit_list/', upload) + + + + + + From bc4bd57656fee66772dd0a3cae5233f36cc8de06 Mon Sep 17 00:00:00 2001 From: Ishan Joshi Date: Sat, 17 Jun 2017 12:15:13 +1000 Subject: [PATCH 8/9] Update backend_optimized.py --- backend_optimized.py | 158 +++++++++++++++++++++++-------------------- 1 file changed, 83 insertions(+), 75 deletions(-) diff --git a/backend_optimized.py b/backend_optimized.py index 000601d..061f855 100644 --- a/backend_optimized.py +++ b/backend_optimized.py @@ -42,122 +42,130 @@ storage = pybase.storage() def fileReader(firebase, file, user): - unitFile = open(file, 'r') - unitList = [] + try: + unitFile = open(file, 'r') + unitList = [] - for line in unitFile: - unitList.append(line) + for line in unitFile: + unitList.append(line) - unitFile.close() - unitStored = [] + unitFile.close() + unitStored = [] - for i in range(1,len(unitList)): - unitLine = unitList[i].strip().split("\t") - unitName = unitLine[0].split("_") - unitLine[0]=unitName[0] - unitStrip = [] - unitStrip.append(unitLine[0]) - unitStrip.append(unitLine[2]+unitLine[3]) - unitStrip.append(unitLine[4]+unitLine[5]) - unitStrip.append(unitLine[7].replace("/","-")) - unitStrip.append(unitLine[2]) - unitStrip.append(unitLine[3]) - if unitLine[9][1] == ".": - unitLine[9] = unitLine[9][:3] - else: - unitLine[9] = unitLine[9][0] - unitStrip.append(unitLine[9]) - unitStored.append(unitStrip) + for i in range(1,len(unitList)): + unitLine = unitList[i].strip().split("\t") + unitName = unitLine[0].split("_") + if(unitName[2]!="S1"): + unitLine[0]=unitName[0] + unitStrip = [] + unitStrip.append(unitLine[0]) + unitStrip.append(unitLine[2]+unitLine[3]) + unitStrip.append(unitLine[4]+unitLine[5]) + unitStrip.append(unitLine[7].replace("/","-")) + unitStrip.append(unitLine[2]) + unitStrip.append(unitLine[3]) + if unitLine[9][1] == ".": + unitLine[9] = unitLine[9][:3] + else: + unitLine[9] = unitLine[9][0] + unitStrip.append(unitLine[9]) + unitStored.append(unitStrip) - unitOut = unitStored + unitOut = unitStored - unitSimple = [] - unitSimpleTemp = [] - for unitRef in unitOut: - unitStore = unitRef[0]+"*"+unitRef[1]+"*"+unitRef[2][0:3]+"*"+unitRef[2][3:]+"*"+unitRef[3]+"*"+unitRef[-1].replace(".", "~") - unitStoreTemp = unitRef[0]+"*"+unitRef[1]+"*"+unitRef[2][0:3]+"*"+unitRef[2][3:]+"*"+unitRef[3]+"*"+unitRef[-1].replace(".", "~") + unitSimple = [] + unitSimpleTemp = [] + for unitRef in unitOut: + unitStore = unitRef[0]+"*"+unitRef[1]+"*"+unitRef[2][0:3]+"*"+unitRef[2][3:]+"*"+unitRef[3]+"*"+unitRef[-1].replace(".", "~") + unitStoreTemp = unitRef[0]+"*"+unitRef[1]+"*"+unitRef[2][0:3]+"*"+unitRef[2][3:]+"*"+unitRef[3]+"*"+unitRef[-1].replace(".", "~") - # print(unitStore, unitStoreTemp) + # print(unitStore, unitStoreTemp) - unitSimple.append(unitStore) - unitSimpleTemp.append(unitStoreTemp) - unit = unitSimple - #print(unit) - #print() - unitTemp = unitSimpleTemp + unitSimple.append(unitStore) + unitSimpleTemp.append(unitStoreTemp) + unit = unitSimple + #print(unit) + #print() + unitTemp = unitSimpleTemp - firebase.put("", "users/" + str(user[0]) + "/classes", unitTemp) + firebase.put("", "users/" + str(user[0]) + "/classes", unitTemp) - newUnit = [] - for p in range(len(unit)): - newUnit.append([]) + newUnit = [] + for p in range(len(unit)): + newUnit.append([]) - for x in range(len(unit)): - newUnit[x].append(unitOut[x][0]) - newUnit[x].append(unitOut[x][4]) - newUnit[x].append(unitOut[x][5]+unitOut[x][2]) + for x in range(len(unit)): + newUnit[x].append(unitOut[x][0]) + newUnit[x].append(unitOut[x][4]) + newUnit[x].append(unitOut[x][5]+unitOut[x][2]) - #print(unit, newUnit) + #print(unit, newUnit) - oldUsers = [] - for n in range(len(unit)): - oldUsers.append([]) - temp = [] + oldUsers = [] + for n in range(len(unit)): + oldUsers.append([]) + temp = [] - for x in range(len(unit)): - try: - #a = firebase.get('','classes/'+unit[x]+'/users/') - #print(unit[x]) + for x in range(len(unit)): + try: + #a = firebase.get('','classes/'+unit[x]+'/users/') + #print(unit[x]) - a = allclasses[unit[x]]['users'] + a = allclasses[unit[x]]['users'] - temp.append(a) + temp.append(a) - if temp[x] not in oldUsers[x] and temp[x] is not None: - oldUsers[x].extend(temp[x]) + if temp[x] not in oldUsers[x] and temp[x] is not None: + oldUsers[x].extend(temp[x]) - if user[0] not in oldUsers[x]: - oldUsers[x].extend(user) - except Exception as e: - firebase.put('/', 'requests/' + str(user[0]) + "/status", 'ERR'+str(e)) + if user[0] not in oldUsers[x]: + oldUsers[x].extend(user) + except Exception as e: + firebase.put('/', 'requests/' + str(user[0]) + "/status", 'ERR'+str(e)) - for i in range(len(unit)): - dictionary = {'users':oldUsers[i]} - firebase.put("","classes/"+str(unit[i]),dictionary) - allclasses[str(unit[i])] = dictionary + for i in range(len(unit)): + dictionary = {'users':oldUsers[i]} + firebase.put("","classes/"+str(unit[i]),dictionary) + allclasses[str(unit[i])] = dictionary - j = open("classes.json", 'w') - json.dump(allclasses, j) - j.close() + j = open("classes.json", 'w') + json.dump(allclasses, j) + j.close() - firebase.put('/', 'requests/' + str(user[0]) + "/status", 'SUCCESS') - #End of function + firebase.put('/', 'requests/' + str(user[0]) + "/status", 'SUCCESS') + #End of function + except Exception as e: + firebase.put('/', 'requests/' + str(user[0]) + "/status", 'ERROR\t' + str(e)) -### Main + ### Main requests = firebase.get('/','requests/') + + #print(requests) #Download all the files +a = datetime.datetime.now() +print(a) for request in requests: if(requests[request]['status'] == "UPLOAD"): storage.child("usertimetable/"+request).download("user_files/"+request) firebase.put('/','requests/'+request+"/status", 'DOWNLOADED') - - +b = datetime.datetime.now() +print(b, b-a) for request in requests: if(requests[request]['status']!="SUCCESS"): user = request fileReader(firebase, "user_files/"+user, [user]) - - +c = datetime.datetime.now() +print(c-b) # # file = 'timetable-10001000.txt' # user = ["Ishan"] From e00d3a1ddb2406e7a68931103102564b1621a6cf Mon Sep 17 00:00:00 2001 From: Ishan Joshi Date: Tue, 20 Jun 2017 10:37:48 +1000 Subject: [PATCH 9/9] Add files via upload --- classes.json | 1 + new_db_structure_firebase.py | 272 +++++++++++++++++++++++++++++++++++ seperate_unit_types.py | 79 ++++++---- 3 files changed, 322 insertions(+), 30 deletions(-) create mode 100644 classes.json create mode 100644 new_db_structure_firebase.py diff --git a/classes.json b/classes.json new file mode 100644 index 0000000..ce3089c --- /dev/null +++ b/classes.json @@ -0,0 +1 @@ +{"FIT1043*Lecture01*Wed*10:00*CL_21Col-E2*2*S2!!2017": {"users": {"QPjoAO7nrOVH4YQMP6WcLEVwhOW2": "A", "TCAEsKIxqvSaI0FQzupsSNmjaIc2": "A", "uaBUroQsbWRiRBboI3iDct7HY892": "A"}}, "FIT1045*Laboratory32*Thu*13:00*CL_23Col-G47*2*S1!!2017": {"users": {"QPjoAO7nrOVH4YQMP6WcLEVwhOW2": "A", "uaBUroQsbWRiRBboI3iDct7HY892": "A"}}, "FIT1045*Lecture03-P1*Mon*17:00*CL_20Chn-H5*1*S1!!2017": {"users": {"QPjoAO7nrOVH4YQMP6WcLEVwhOW2": "A", "uaBUroQsbWRiRBboI3iDct7HY892": "A"}}, "FIT1045*Lecture03-P2*Tue*16:00*CL_21Col-E1*1*S1!!2017": {"users": {"QPjoAO7nrOVH4YQMP6WcLEVwhOW2": "A", "uaBUroQsbWRiRBboI3iDct7HY892": "A"}}, "FIT1045*PASSWorkshop04*Fri*15:00*CL_20Chn-E353*1*S1!!2017": {"users": {"QPjoAO7nrOVH4YQMP6WcLEVwhOW2": "A", "uaBUroQsbWRiRBboI3iDct7HY892": "A"}}, "FIT1045*Tutorial12*Wed*09:00*CL_14Rnf-G16*2*S1!!2017": {"users": {"QPjoAO7nrOVH4YQMP6WcLEVwhOW2": "A", "uaBUroQsbWRiRBboI3iDct7HY892": "A"}}, "FIT1047*Laboratory18*Thu*18:00*CL_14Rnf-G11A*2*S1!!2017": {"users": {"QPjoAO7nrOVH4YQMP6WcLEVwhOW2": "A", "uaBUroQsbWRiRBboI3iDct7HY892": "A"}}, "FIT1047*Lecture02-P2*Wed*16:00*-*1*S1!!2017": {"users": {"QPjoAO7nrOVH4YQMP6WcLEVwhOW2": "A", "uaBUroQsbWRiRBboI3iDct7HY892": "A"}}, "FIT1047*Lecture02-P1*Tue*14:00*-*1*S1!!2017": {"users": {"QPjoAO7nrOVH4YQMP6WcLEVwhOW2": "A", "uaBUroQsbWRiRBboI3iDct7HY892": "A"}}, "FIT1047*PASSWorkshop02*Thu*11:00*CL_7Inn-CG22*1*S1!!2017": {"users": {"QPjoAO7nrOVH4YQMP6WcLEVwhOW2": "A", "uaBUroQsbWRiRBboI3iDct7HY892": "A"}}, "FIT1050*Laboratory03*Wed*17:00*CL_22All-103*3*S1!!2017": {"users": {"QPjoAO7nrOVH4YQMP6WcLEVwhOW2": "A", "uaBUroQsbWRiRBboI3iDct7HY892": "A"}}, "FIT1050*Lecture01*Mon*10:00*CL_21Col-E1*1*S1!!2017": {"users": {"QPjoAO7nrOVH4YQMP6WcLEVwhOW2": "A", "uaBUroQsbWRiRBboI3iDct7HY892": "A"}}, "MAT1830*Lecture01-P2*Thu*12:00*CL_25Exh-C1*1*S1!!2017": {"users": {"QPjoAO7nrOVH4YQMP6WcLEVwhOW2": "A", "TCAEsKIxqvSaI0FQzupsSNmjaIc2": "A", "swhhZrPWz6bT8y117abMEoPcZ7E2": "A", "uaBUroQsbWRiRBboI3iDct7HY892": "A"}}, "MAT1830*Lecture01-P3*Fri*16:00*CL_25Exh-C1*1*S1!!2017": {"users": {"QPjoAO7nrOVH4YQMP6WcLEVwhOW2": "A", "TCAEsKIxqvSaI0FQzupsSNmjaIc2": "A", "swhhZrPWz6bT8y117abMEoPcZ7E2": "A", "uaBUroQsbWRiRBboI3iDct7HY892": "A"}}, "MAT1830*Lecture01-P1*Wed*12:00*CL_25Exh-C1*1*S1!!2017": {"users": {"QPjoAO7nrOVH4YQMP6WcLEVwhOW2": "A", "TCAEsKIxqvSaI0FQzupsSNmjaIc2": "A", "swhhZrPWz6bT8y117abMEoPcZ7E2": "A", "uaBUroQsbWRiRBboI3iDct7HY892": "A"}}, "MAT1830*Support-Class12*Tue*17:30*CL_7Inn-CG20*1~5*S1!!2017": {"users": {"QPjoAO7nrOVH4YQMP6WcLEVwhOW2": "A", "uaBUroQsbWRiRBboI3iDct7HY892": "A"}}, "MAT1841*Lecture01-P1*Mon*11:00*CL_16Rnf-S4*1*S2!!2017": {"users": {"QPjoAO7nrOVH4YQMP6WcLEVwhOW2": "A", "TCAEsKIxqvSaI0FQzupsSNmjaIc2": "A", "uaBUroQsbWRiRBboI3iDct7HY892": "A"}}, "MAT1841*Lecture01-P2*Wed*14:00*CL_15Rnf-S5*1*S2!!2017": {"users": {"QPjoAO7nrOVH4YQMP6WcLEVwhOW2": "A", "TCAEsKIxqvSaI0FQzupsSNmjaIc2": "A", "uaBUroQsbWRiRBboI3iDct7HY892": "A"}}, "MAT1841*Lecture01-P3*Thu*11:00*CL_15Rnf-S5*1*S2!!2017": {"users": {"QPjoAO7nrOVH4YQMP6WcLEVwhOW2": "A", "TCAEsKIxqvSaI0FQzupsSNmjaIc2": "A", "uaBUroQsbWRiRBboI3iDct7HY892": "A"}}, "FIT1041*Debate01*Mon*08:00*CL_20Chn-H8 (24-7-18-9, 2-10-16-10), CL_10Chn-CG60 (24-7-18-9, 2-10-16-10)*1*S2!!2017": {"users": {"TCAEsKIxqvSaI0FQzupsSNmjaIc2": "A"}}, "FIT1045*Laboratory25*Wed*18:00*CL_14Rnf-G11A*2*S1!!2017": {"users": {"TCAEsKIxqvSaI0FQzupsSNmjaIc2": "A"}}, "FIT1045*Lecture02-P1*Mon*15:00*CL_21Col-E3*1*S1!!2017": {"users": {"TCAEsKIxqvSaI0FQzupsSNmjaIc2": "A"}}, "FIT1045*Lecture02-P2*Tue*13:00*CL_21Col-E3*1*S1!!2017": {"users": {"TCAEsKIxqvSaI0FQzupsSNmjaIc2": "A"}}, "FIT1045*Tutorial14*Tue*15:00*CL_14Rnf-G16*2*S1!!2017": {"users": {"TCAEsKIxqvSaI0FQzupsSNmjaIc2": "A"}}, "FIT1047*Laboratory17*Thu*18:00*CL_14Rnf-147*2*S1!!2017": {"users": {"TCAEsKIxqvSaI0FQzupsSNmjaIc2": "A"}}, "FIT1047*Lecture01-P1*Tue*14:00*CL_43Rnf-STH1*1*S1!!2017": {"users": {"TCAEsKIxqvSaI0FQzupsSNmjaIc2": "A"}}, "FIT1047*Lecture01-P2*Wed*16:00*CL_43Rnf-STH1*1*S1!!2017": {"users": {"TCAEsKIxqvSaI0FQzupsSNmjaIc2": "A"}}, "MAT1830*Support-Class10*Mon*16:30*CL_7Inn-CG11*1~5*S1!!2017": {"users": {"TCAEsKIxqvSaI0FQzupsSNmjaIc2": "A"}}, "MGF1010*Workshop34*Mon*08:00*CA_F-F432*2*S1!!2017": {"users": {"TCAEsKIxqvSaI0FQzupsSNmjaIc2": "A"}}, "ACC1200*Seminar04*Wed*15:00*CL_7Inn-BG15*3*S1!!2017": {"users": {"swhhZrPWz6bT8y117abMEoPcZ7E2": "A"}}, "ETC1000*Comp-Lab09*Fri*08:00*CL_20Chn-E163*1~5*S1!!2017": {"users": {"swhhZrPWz6bT8y117abMEoPcZ7E2": "A"}}, "ETC1000*Lecture02*Fri*11:30*CL_25Exh-C1*1~5*S1!!2017": {"users": {"swhhZrPWz6bT8y117abMEoPcZ7E2": "A"}}, "FIT1045*Laboratory20*Fri*13:00*CL_23Col-G45*2*S1!!2017": {"users": {"swhhZrPWz6bT8y117abMEoPcZ7E2": "A"}}, "FIT1045*Lecture01-P1*Mon*13:00*CL_21Col-E3*1*S1!!2017": {"users": {"swhhZrPWz6bT8y117abMEoPcZ7E2": "A"}}, "FIT1045*Lecture01-P2*Tue*15:00*CL_21Col-E3*1*S1!!2017": {"users": {"swhhZrPWz6bT8y117abMEoPcZ7E2": "A"}}, "FIT1045*Tutorial16*Mon*14:00*CL_23Col-G46*2*S1!!2017": {"users": {"swhhZrPWz6bT8y117abMEoPcZ7E2": "A"}}, "MAT1830*Support-Class08*Mon*10:00*CL_7Inn-CG10*1~5*S1!!2017": {"users": {"swhhZrPWz6bT8y117abMEoPcZ7E2": "A"}}} \ No newline at end of file diff --git a/new_db_structure_firebase.py b/new_db_structure_firebase.py new file mode 100644 index 0000000..d8667a2 --- /dev/null +++ b/new_db_structure_firebase.py @@ -0,0 +1,272 @@ +import datetime +import json +import os.path + +import pyrebase + + + +""" +TODO: +""" +#TODO add file check (is legit text file) +#TODO only add semester 1 + + +from firebase import firebase +firebase = firebase.FirebaseApplication('https://learntogether-a250b.firebaseio.com/') + +config = { + 'apiKey': "AIzaSyBLA6sDqXwnMX6tJayM4dmYCPRzt5CW91M", + 'authDomain': "learntogether-a250b.firebaseapp.com", + 'databaseURL': "https://learntogether-a250b.firebaseio.com", + 'storageBucket': "learntogether-a250b.appspot.com", +} + + +pybase = pyrebase.initialize_app(config) + +auth = pybase.auth() + +# Log the user in + + +# Get a reference to the database service +db = pybase.database() + +if(user!=None): + + + allclasses = {} + if os.path.exists("classes.json"): + j = open("classes.json", 'r+') + allclasses = json.load(j) + if(allclasses == None): + allclasses = {} + j.close() + else: + allclasses = db.child("classes/").get(user['idToken']).val() + if (allclasses == None): + allclasses = {} + j = open("classes.json", 'w') + json.dump(allclasses, j) + j.close() + + + + storage = pybase.storage() + + def fileReader(firebase, file, curruservalue): + # print(curruservalue, "Hello excuse me") + try: + unitFile = open(file, 'r') + unitList = [] + + for line in unitFile: + unitList.append(line) + + unitFile.close() + unitStored = [] + + for i in range(1,len(unitList)): + unitLine = unitList[i].strip().split("\t") + unitName = unitLine[0].split("_") + if(unitName[2]!="S1" or unitName[2]=="S1"): + # if(True): + unitLine[0]=unitName[0] + unitStrip = [] + unitStrip.append(unitLine[0]) + unitStrip.append(unitLine[2]+unitLine[3]) + unitStrip.append(unitLine[4]+unitLine[5]) + unitStrip.append(unitLine[7].replace("/","-")) + unitStrip.append(unitLine[2]) + unitStrip.append(unitLine[3]) + if unitLine[9][1] == ".": + unitLine[9] = unitLine[9][:3] + else: + unitLine[9] = unitLine[9][0] + unitStrip.append(unitLine[9]) + unitStrip.append(unitName[2]+"!!2017") + unitStored.append(unitStrip) + + + unitOut = unitStored + + unitSimple = [] + unitSimpleTemp = [] + for unitRef in unitOut: + unitStore = unitRef[0]+"*"+unitRef[1]+"*"+unitRef[2][0:3]+"*"+unitRef[2][3:]+"*"+unitRef[3]+"*"+unitRef[-2].replace(".", "~") + "*" + unitRef[-1] + unitStoreTemp = unitRef[0]+"*"+unitRef[1]+"*"+unitRef[2][0:3]+"*"+unitRef[2][3:]+"*"+unitRef[3]+"*"+unitRef[-2].replace(".", "~") + "*" + unitRef[-1] + + # print(unitStore, unitStoreTemp) + + unitSimple.append(unitStore) + unitSimpleTemp.append(unitStoreTemp) + unit = unitSimple + + unitTemp = unitSimpleTemp + + + c = {} + for each in unitTemp: + c[each] = "S" + # print(c,"\n", user) + db.child("/users/").child(curruservalue[0]).child('classes').set(c, user['idToken']) + # firebase.put("", "users/" + str(user[0]) + "/classes", c) + + newUnit = [] + for p in range(len(unit)): + newUnit.append([]) + + for x in range(len(unit)): + newUnit[x].append(unitOut[x][0]) + newUnit[x].append(unitOut[x][4]) + newUnit[x].append(unitOut[x][5]+unitOut[x][2]) + + print(unit, newUnit) + + oldUsers = [] + for n in range(len(unit)): + oldUsers.append([]) + print(oldUsers, "\toldusers") + temp = [] + + + for x in range(len(unit)): + try: + # a = firebase.get('','classes/'+unit[x]+'/users/') + # print(unit[x]) + + + + if(allclasses.get(unit[x]) is None): + print("trueee") + allclasses[unit[x]] = {} + allclasses[unit[x]]['users'] = [] + print(allclasses) + + a = allclasses[unit[x]]['users'] + + print(a, "a") + + + temp.append(a) + + if temp[x] not in oldUsers[x] and temp[x] is not None: + oldUsers[x].extend(temp[x]) + + print(oldUsers, "2") + + if curruservalue[0] not in oldUsers[x]: + oldUsers[x].extend(curruservalue) + except Exception as e: + db.child("/requests/").child(str(curruservalue[0])).child('status').set('ERR' + str(e), + user['idToken']) + + for i in range(len(unit)): + print(oldUsers, "3") + sqwer = {} + for each in oldUsers[i]: + sqwer[each] = "A" + dictionary = {'users': sqwer} + db.child("classes/").child(str(unit[i])).set(dictionary, user['idToken']) + allclasses[str(unit[i])] = dictionary + # try: + # #a = firebase.get('','classes/'+unit[x]+'/users/') + # #print(unit[x]) + # + # + # ap = allclasses[unit[x]]['users'] + # a = [] + # if(ap is not None): + # for each in ap: + # a.append(each) + # + # + # + # temp.append(a) + # + # print("a\t", a, "\n", temp, " ", x, "\n", oldUsers) + # print() + # + # if temp[x] not in oldUsers[x] and temp[x] is not None: + # oldUsers[x].extend(temp[x]) + # + # if curruservalue[0] not in oldUsers[x]: + # oldUsers[x].extend(curruservalue) + # + # + # except Exception as e: + # pass + # # print(e) + # #db.child("/requests/").child(str(curruservalue[0])).child('status').set('ERR'+str(e), user['idToken']) + # # firebase.put('/', 'requests/' + str(user[0]) + "/status", 'ERR'+str(e)) + # + # for i in range(len(unit)): + # qc = {} + # print(oldUsers[i]) + # for each in oldUsers[i]: + # qc[each] = "P" + # dictionary = {'users':qc} + # print(dictionary) + # try: + # db.child("classes/").child(str(unit[i])).set(dictionary, user['idToken']) + # except Exception as e: + # print(e) + # # firebase.put("","classes/"+str(unit[i]),dictionary) + # allclasses[str(unit[i])] = dictionary + + j = open("classes.json", 'w') + json.dump(allclasses, j) + j.close() + + db.child("/requests/").child(str(curruservalue[0])).child('status').set('SUCCESS', user['idToken']) + # firebase.put('/', 'requests/' + str(user[0]) + "/status", 'SUCCESS') + #End of function + except Exception as e: + print(e) + db.child("/requests/").child(str(curruservalue[0])).child('status').set('ERR' + str(e), user['idToken']) + # firebase.put('/', 'requests/' + str(user[0]) + "/status", 'ERROR\t' + str(e)) + + + ### Main + + + requests = db.child("/requests/").get(user['idToken']).val() + + + #print(requests) + #Download all the files + + a = datetime.datetime.now() + print(a) + for request in requests: + if(requests[request]['status'] == "UPLOAD"): + storage.child("usertimetable/"+request).download("user_files/"+request) + db.child("/requests/").child(request).child('status').set('DOWNLOADED', user['idToken']) + # firebase.put('/','requests/'+request+"/status", 'DOWNLOADED') + b = datetime.datetime.now() + print(b, b-a) + + for request in requests: + if(requests[request]['status']!="SUCCESS"): + userp = request + fileReader(firebase, "user_files/"+userp, [userp]) + + # userp = "TCAEsKIxqvSaI0FQzupsSNmjaIc2" + # fileReader(firebase, "user_files/" + userp, [userp]) + c = datetime.datetime.now() + # print(c-b) +else: + print("Auth failed.") +# +# file = 'timetable-10001000.txt' +# user = ["Ishan"] +# fileReader(firebase, file, user) + + + + + + +#storage.child("hey/28809033.txt").download("288090331.txt") diff --git a/seperate_unit_types.py b/seperate_unit_types.py index 4988f28..3da7367 100644 --- a/seperate_unit_types.py +++ b/seperate_unit_types.py @@ -1,30 +1,49 @@ -import json -classes = json.load(open("classes.json")) - -upload = {} - -def GetTextOnly(s): - return ''.join([i for i in s if not i.isdigit()]) - - -for cl in classes: - cll = cl.split("*") - #check if the unit is present - unit = cll[0] - if(unit not in upload): - upload[unit] = {} - type = GetTextOnly(cll[1]) - if(type not in upload[unit]): - upload[unit][type] = [] - upload[unit][type].append(cl) - -from firebase import firebase -firebase = firebase.FirebaseApplication('https://learntogether-a250b.firebaseio.com/') - -firebase.put('','seperate_unit_list/', upload) - - - - - - +import json +classes = json.load(open("classes.json")) + +upload = {} + +def GetTextOnly(s): + return ''.join([i for i in s if not i.isdigit()]) + + +for cl in classes: + cll = cl.split("*") + #check if the unit is present + unit = cll[0] + if(unit not in upload): + upload[unit] = {} + type = GetTextOnly(cll[1]) + if(type not in upload[unit]): + upload[unit][type] = [] + upload[unit][type].append(cl) + +pwd = "ishan4899qwert123" +import pyrebase + +config = { + 'apiKey': "AIzaSyBLA6sDqXwnMX6tJayM4dmYCPRzt5CW91M", + 'authDomain': "learntogether-a250b.firebaseapp.com", + 'databaseURL': "https://learntogether-a250b.firebaseio.com", + 'storageBucket': "learntogether-a250b.appspot.com", +} + +firebase = pyrebase.initialize_app(config) + + +auth = firebase.auth() + +# Log the user in +user = auth.sign_in_with_email_and_password("ishan@ishanjoshi.me", pwd) +print(user) + +# Get a reference to the database service +db = firebase.database() + +db.child('seperate_unit_list/').set(upload, user['idToken']) + + + + + +