forked from binay-jana/RoboticsContestScoringSystem
-
Notifications
You must be signed in to change notification settings - Fork 0
/
initialize_registry.py
46 lines (35 loc) · 964 Bytes
/
initialize_registry.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
# -*- coding: utf-8; -*-
import redis
import registry
from constants import settings
from libraries.my_sql_connection import MySQLConnection
from raven import Client
from libraries.repositories.robots import Robots
from libraries.repositories.runs import Runs
def load_registry():
""" Initialize and load the global registry
"""
r = registry.get_registry()
if r.is_locked():
return
init_mysql(r)
init_redis(r)
init_clients(r)
init_db_objects(r)
r.lock()
def init_mysql(r):
r['MY_SQL'] = MySQLConnection()
def init_redis(r):
r['REDIS'] = redis.StrictRedis(
host=settings.redis_host,
port=settings.redis_port,
db=settings.redis_db
)
def init_clients(r):
r['SENTRY'] = Client(
'https://858c1ce455dc43538c50f8ca3b3358ce:93608270372'
'b4b939737b04a3c816612@app.getsentry.com/60618'
)
def init_db_objects(r):
r['ROBOTS'] = Robots
r['RUNS'] = Runs