|
@@ -15,10 +15,12 @@ class Config:
|
|
|
|
|
|
def read_local_config(self):
|
|
def read_local_config(self):
|
|
try:
|
|
try:
|
|
- f = open(self.path)
|
|
|
|
|
|
+ f = open(self.path, encoding='utf-8')
|
|
self.local_config = json.load(f)
|
|
self.local_config = json.load(f)
|
|
|
|
+ f.close()
|
|
except Exception as e:
|
|
except Exception as e:
|
|
logging.error("[CONFIG] read config with path: %s error: %s", self.path, e)
|
|
logging.error("[CONFIG] read config with path: %s error: %s", self.path, e)
|
|
|
|
+ return self.local_config
|
|
|
|
|
|
def read_redis_config(self):
|
|
def read_redis_config(self):
|
|
if self.local_config is None:
|
|
if self.local_config is None:
|
|
@@ -31,9 +33,10 @@ class Config:
|
|
|
|
|
|
try:
|
|
try:
|
|
r = redis.Redis(host, port, db=db, password=password)
|
|
r = redis.Redis(host, port, db=db, password=password)
|
|
- config = r.get('config').decode('utf8')
|
|
|
|
|
|
+ config = r.get('config').decode('utf-8')
|
|
if config is None or config is "":
|
|
if config is None or config is "":
|
|
return
|
|
return
|
|
self.redis_config = json.loads(config)
|
|
self.redis_config = json.loads(config)
|
|
except Exception as e:
|
|
except Exception as e:
|
|
- print(e)
|
|
|
|
|
|
+ logging.error("[CONFIG] read redis config with local_config(%s) error: %s", self.local_config, e)
|
|
|
|
+ return self.redis_config
|