未验证 提交 cdb30bbb 编写于 作者: B Bin Long 提交者: GitHub

Merge pull request #154 from ShenYuhan/develop

add log level default value
...@@ -24,7 +24,6 @@ import requests ...@@ -24,7 +24,6 @@ import requests
import json import json
import yaml import yaml
import random import random
import fcntl
from random import randint from random import randint
from paddlehub.common import utils, srv_utils from paddlehub.common import utils, srv_utils
...@@ -39,9 +38,6 @@ CACHE_TIME = 60 * 10 ...@@ -39,9 +38,6 @@ CACHE_TIME = 60 * 10
class HubServer(object): class HubServer(object):
def __init__(self, config_file_path=None): def __init__(self, config_file_path=None):
LOCK_FILE = os.path.join(hub.HUB_HOME, '__LOCK__')
LOCK_FP = open(LOCK_FILE, 'a+')
fcntl.flock(LOCK_FP.fileno(), fcntl.LOCK_EX)
if not config_file_path: if not config_file_path:
config_file_path = os.path.join(hub.CONF_HOME, 'config.json') config_file_path = os.path.join(hub.CONF_HOME, 'config.json')
if not os.path.exists(hub.CONF_HOME): if not os.path.exists(hub.CONF_HOME):
...@@ -57,7 +53,6 @@ class HubServer(object): ...@@ -57,7 +53,6 @@ class HubServer(object):
self.server_url = self.config['server_url'] self.server_url = self.config['server_url']
self.request() self.request()
self._load_resource_list_file_if_valid() self._load_resource_list_file_if_valid()
LOCK_FP.close()
def get_server_url(self): def get_server_url(self):
random.seed(int(time.time())) random.seed(int(time.time()))
......
...@@ -43,7 +43,7 @@ class Logger(object): ...@@ -43,7 +43,7 @@ class Logger(object):
self.logger.setLevel(self._get_logging_level()) self.logger.setLevel(self._get_logging_level())
if os.path.exists(os.path.join(CONF_HOME, "config.json")): if os.path.exists(os.path.join(CONF_HOME, "config.json")):
with open(os.path.join(CONF_HOME, "config.json"), "r") as fp: with open(os.path.join(CONF_HOME, "config.json"), "r") as fp:
level = json.load(fp).get("log_level") level = json.load(fp).get("log_level", "DEBUG")
self.logLevel = level self.logLevel = level
self.setLevel(level) self.setLevel(level)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册