未验证 提交 bec06f5d 编写于 作者: 走神的阿圆's avatar 走神的阿圆 提交者: GitHub

add stat for product (#782)

上级 b5026ee0
...@@ -63,7 +63,7 @@ def create_app(args): ...@@ -63,7 +63,7 @@ def create_app(args):
babel = Babel(app) babel = Babel(app)
api_call = create_api_call(args.logdir, args.model, args.cache_timeout) api_call = create_api_call(args.logdir, args.model, args.cache_timeout)
update_util.PbUpdater().start() update_util.PbUpdater(args.product).start()
public_path = args.public_path public_path = args.public_path
api_path = public_path + '/api' api_path = public_path + '/api'
......
...@@ -37,6 +37,7 @@ class DefaultArgs(object): ...@@ -37,6 +37,7 @@ class DefaultArgs(object):
self.api_only = args.get('api_only', False) self.api_only = args.get('api_only', False)
self.open_browser = args.get('open_browser', False) self.open_browser = args.get('open_browser', False)
self.model = args.get('model', '') self.model = args.get('model', '')
self.product = args.get('product', 'normal')
def get_host(host=default_host, port=default_port): def get_host(host=default_host, port=default_port):
...@@ -94,6 +95,7 @@ class ParseArgs(object): ...@@ -94,6 +95,7 @@ class ParseArgs(object):
self.api_only = args.api_only self.api_only = args.api_only
self.open_browser = args.open_browser self.open_browser = args.open_browser
self.model = args.model self.model = args.model
self.product = args.product
def parse_args(): def parse_args():
...@@ -172,6 +174,12 @@ def parse_args(): ...@@ -172,6 +174,12 @@ def parse_args():
action="version", action="version",
version="%(prog)s {}".format(__version__) version="%(prog)s {}".format(__version__)
) )
parser.add_argument(
"--product",
type=str,
action="store",
default="normal",
help="specify the product")
args = parser.parse_args() args = parser.parse_args()
......
...@@ -29,7 +29,8 @@ def md5(text): ...@@ -29,7 +29,8 @@ def md5(text):
class PbUpdater(threading.Thread): class PbUpdater(threading.Thread):
def __init__(self): def __init__(self, product='normal'):
self.product = product
threading.Thread.__init__(self) threading.Thread.__init__(self)
def update_pb(self, def update_pb(self,
...@@ -39,7 +40,8 @@ class PbUpdater(threading.Thread): ...@@ -39,7 +40,8 @@ class PbUpdater(threading.Thread):
payload = { payload = {
"data": { "data": {
"version": version, "version": version,
"md5": md5_code "md5": md5_code,
"product": self.product
} }
} }
url = 'https://paddlepaddle.org.cn/paddlehub/stat?from=vdl' url = 'https://paddlepaddle.org.cn/paddlehub/stat?from=vdl'
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册