forked from chenmoaaaa/shadowsocksr-4
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configloader.py
46 lines (35 loc) · 936 Bytes
/
configloader.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
#!/usr/bin/python
# -*- coding: utf-8 -*-
import importloader
from utils.json_util import *
import os
g_config = None
mysql_config = None
def load_config():
global g_config
g_config = importloader.loads(['userapiconfig', 'apiconfig'])
def load_mysql_config():
global mysql_config
tmp = {
"host": "127.0.0.1",
"port": 3306,
"user": "ss",
"password": "pass",
"db": "shadowsocks",
"node_id": 0,
"transfer_mul": 1.0,
"ssl_enable": 0,
"ssl_ca": "",
"ssl_cert": "",
"ssl_key": ""}
config_path = g_config.MYSQL_CONFIG
with open(os.path.join(os.path.split(__file__)[0],config_path), 'rb+') as f:
cfg = JsonUtil.json_loads(f.read().decode('utf8'))
tmp.update(cfg)
mysql_config = tmp
def get_config():
return g_config
def get_mysql_config():
return mysql_config
load_config()
load_mysql_config()