-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.py
136 lines (117 loc) · 3.08 KB
/
config.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
from configparser import ConfigParser
from kazoo_put import get_headers, get_auth_token, get_acc_id
KAZOO_HOST = '18.218.219.1'
KAZOO_SERVER = 'http://18.218.219.1'
WEBHOOKS_SERVER = ''
AUTH_TOKEN = get_auth_token()
HEADERS = get_headers(AUTH_TOKEN)
ACC_ID = get_acc_id()
DOC_CREATE_WEBHOOKS = {"data": {
"name": "Destroy2",
"uri": WEBHOOKS_SERVER,
"http_verb": "post",
"hook": "object",
"action": "doc_created",
"type": "account",
"retries": 3,
"custom_data": {
"type": "user",
"action": "doc_created"
}
}
}
DOC_CREATED_WEBHOOKS = {"data": {
"name": "account3",
"uri": WEBHOOKS_SERVER,
"http_verb": "post",
"hook": "object",
"action": "doc_created",
"type": "account",
"include_subaccounts": "true",
"retries": 3,
"custom_data": {
"type": "account",
"action": "doc_created"
}
}
}
CHANNEL_CREATE_WEBHOOKS = {"data": {
"name": "Get_Calls",
"uri": WEBHOOKS_SERVER,
"http_verb": "post",
"hook": "channel_create",
"retries": 3,
}
}
CHANNEL_DESTROY_WEBHOOKS = {"data": {
"name": "End_Calls",
"uri": WEBHOOKS_SERVER,
"http_verb": "post",
"hook": "channel_destroy",
"retries": 3,
}
}
WEBSOCKET_CreateUser = {
'action': 'subscribe',
'auth_token': AUTH_TOKEN,
'request_id': ACC_ID,
'data': {
'account_id': ACC_ID,
'binding': 'object.doc_created.user'
}
}
WEBSOCKET_CreateDevice = {
'action': 'subscribe',
'auth_token': AUTH_TOKEN,
'request_id': ACC_ID,
'data': {
'account_id': ACC_ID,
'binding': 'object.doc_created.device'
}
}
WEBSOCKET_Channel_Create = {
'action': 'subscribe',
'auth_token': AUTH_TOKEN,
'request_id': ACC_ID,
'data': {
'account_id': ACC_ID,
'binding': 'call.CHANNEL_CREATE.*'
}
}
WEBSOCKET_Channel_Destroy = {
'action': 'subscribe',
'auth_token': AUTH_TOKEN,
'request_id': ACC_ID,
'data': {
'account_id': ACC_ID,
'binding': 'call.CHANNEL_DESTROY.*'
}
}
def config(filename='database.ini', section='postgresql'):
# create a parser
parser = ConfigParser()
# read config file
parser.read(filename)
# get section, default to postgresql
db = {}
if parser.has_section(section):
params = parser.items(section)
for param in params:
db[param[0]] = param[1]
else:
raise Exception('Section {0} not found in the {1} file'.format(section, filename))
return db
def config1(filename='database1.ini', section='postgresql'):
# create a parser
parser = ConfigParser()
# read config file
parser.read(filename)
# get section, default to postgresql
db = {}
if parser.has_section(section):
params = parser.items(section)
for param in params:
db[param[0]] = param[1]
else:
raise Exception('Section {0} not found in the {1} file'.format(section, filename))
return db