-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathno-processing.py
71 lines (56 loc) · 1.82 KB
/
no-processing.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
# -*- coding: utf-8 -*-
# @author: Dante Fernando Bazaldua Huerta
# Manage all connections
#
import keys as security
# External libraries
import pyrebase # Conexión con firebase
firebase = pyrebase.initialize_app(security.config) # Inicializar firebase
# ------------------------ FIREBASE -------------------------
auth = firebase.auth() # Objecto de autenticación
# Iniciar sesion en firebase
user = auth.sign_in_with_email_and_password(security.email, security.passwd)
storage = firebase.storage() # Referencia al storage
db = firebase.database() # Referencia a la base de datos
DB_PATH_POSITION = 'Encuestas'
def getPositionKey(key):
try:
element = db.child('Transfer').child(key).get()
tran = element.val()
if 'key_encuesta' not in tran:
return None
except Exception as e:
print str(e)
return None
return tran['key_encuesta']
def getPositionInfo(key_encuesta):
try:
element = db.child(DB_PATH_POSITION).child(key_encuesta).get()
tran = element.val()
if 'cuestionario' not in tran:
return None
except Exception as e:
print str(e)
return None
return tran['cuestionario']
def convertPosIntoPathList(questionary):
count = 0
paths = []
try:
for element in questionary:
for key in element:
if (key == "tipo") and (element[key] == "pregunta"):
paths.append(str(count) + ".wav")
count = count + 1
if count == 0:
return 0
except Exception as e:
print str(e)
return paths
uid = "-L7x2Gaf_9aDjg2z7ZVN"
key_encuesta = getPositionKey(uid)
if key_encuesta is not None:
quest = getPositionInfo(key_encuesta)
if quest is not None:
paths = convertPosIntoPathList(quest)
print paths