-
Notifications
You must be signed in to change notification settings - Fork 0
/
load.py
61 lines (40 loc) 路 2.09 KB
/
load.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
import json
class Load:
def __init__(self):
# Configs vars.
#! NO MODIFICAR ESTAS VARIABLES, ESTAS DE ASIGNAN DESDE EL ARCHIVO [Config.json]
self.port = 0 # Puerto donde corre la app principal.
self.secretKey = 'Zzzzzzzzzzzzzzzzzzzzzzz' # Clave de las API's de Flask.
self.debug = False; # Estado de las API's.
self.credentials = {}
# Usuarios permitidos.
self.authUsers = ['DONT PUT NOTHING HERE']
def configurations(self):
# Leemos el archivo de configuraciones.
with open('./Config.json') as f:
auth = False # Variable que usaremos para validar si las configuraciones est谩n bien
data = json.load(f)
# Validaci贸n de los campos b谩sicos.
MainKeys = list(data.keys())
if 'AppConfig' in MainKeys and 'AuthKeys' in MainKeys:
auth = True
else:
auth = False
print("There seems to be something wrong with the configurations. Try downloading the project again from GitHub. (Error 01: Configuration error).")
exit()
# Obtenemos las configuraciones de la app.
if (auth):
config = data['AppConfig']
# instanciamos las variables de configuraci贸n.
self.port = config['port']
self.secretKey = config["secretKey"]
self.debug = config["debug"]
# Instnaciamos los usuarios permitidos.
self.authUsers = data['AuthKeys']
# Obtenemos la ruta de las credenciales, las abrimos y las guardamos.
# Instnaciamos los usuarios permitidos.
credentials_route = data['credentials_json']
with open(credentials_route) as cred:
cred_data = json.load(cred)
self.credentials['google_email'] = cred_data['google_credentials']['email']
self.credentials['google_password'] = cred_data['google_credentials']['password']