Commit d6fe0f6d authored by tarak.li's avatar tarak.li

提测版本

parent 37c3a38b
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import os import os
import socket
import sys import sys
sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)), 'webroot')) sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)), 'webroot'))
def current_ip():
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect(("8.8.8.8", 80))
ip = s.getsockname()[0]
s.close()
return ip
class Consul(object):
def __init__(self, url):
self._url = url
@property
def url(self):
return "{}/v1/agent/service/register".format(self._url)
def register_device(self, name, addr, port: int):
data = {
"ID": "{}".format(name),
"Name": name,
"Address": addr,
"Port": int(port),
}
header = {"Authorization": "Basic bWljcm8tY29uc3VsLWFnZW50OjEyMzQ1Ng=="}
from app.base.logger import log
log.i(self.url)
log.i(data)
import requests
resp = requests.put(self.url, headers=header, json=data)
log.i('register_device %s %s', resp.status_code, resp.text)
return resp.status_code == 200
def main(): def main():
from app.app_env import PATH_APP_ROOT, PATH_DATA from app.app_env import PATH_APP_ROOT, PATH_DATA
from app.base.webapp import tp_web_app from app.base.webapp import tp_web_app
_web_app = tp_web_app() _web_app = tp_web_app()
if not _web_app.init(PATH_APP_ROOT, PATH_DATA): if not _web_app.init(PATH_APP_ROOT, PATH_DATA):
return 1 return 1
# from app.base.configs import tp_cfg
# cfg = tp_cfg()
# consul_host = cfg.plugin.consul
# Consul(consul_host).register_device('micro-remote', current_ip(), 7190)
return _web_app.run() return _web_app.run()
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge"/> <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<meta content="yes" name="apple-mobile-web-app-capable"> <meta content="yes" name="apple-mobile-web-app-capable">
<meta content="black-translucent" name="apple-mobile-web-app-status-bar-style"> <meta content="black-translucent" name="apple-mobile-web-app-status-bar-style">
<title>${self.attr.page_title_}::TELEPORT</title> <title>${self.attr.page_title_}::micro-remote</title>
<link rel="shortcut icon" href="${ static_url('favicon.png') }"> <link rel="shortcut icon" href="${ static_url('favicon.png') }">
<link href="${ static_url('plugins/bootstrap/css/bootstrap.min.css') }" rel="stylesheet" type="text/css"/> <link href="${ static_url('plugins/bootstrap/css/bootstrap.min.css') }" rel="stylesheet" type="text/css"/>
......
...@@ -316,7 +316,8 @@ class AppConfig(BaseAppConfig): ...@@ -316,7 +316,8 @@ class AppConfig(BaseAppConfig):
return [ return [
{'common': ['ip', 'port', 'log-file', 'log-level', 'debug-mode', 'core-server-rpc']}, {'common': ['ip', 'port', 'log-file', 'log-level', 'debug-mode', 'core-server-rpc']},
{'database': ['type', 'sqlite-file', 'mysql-host', 'mysql-port', 'mysql-db', 'mysql-prefix', 'mysql-user', {'database': ['type', 'sqlite-file', 'mysql-host', 'mysql-port', 'mysql-db', 'mysql-prefix', 'mysql-user',
'mysql-password']} 'mysql-password']},
{"plugin": ["core_host", "consul"]}
] ]
def _on_load(self, cfg_parser): def _on_load(self, cfg_parser):
...@@ -389,6 +390,16 @@ class AppConfig(BaseAppConfig): ...@@ -389,6 +390,16 @@ class AppConfig(BaseAppConfig):
if _tmp_str is not None: if _tmp_str is not None:
self.set_kv('database::mysql-password', _tmp_str) self.set_kv('database::mysql-password', _tmp_str)
_sec = cfg_parser['plugin']
_tmp_str = _sec.get('core_host', None)
if _tmp_str is not None:
self.set_kv('plugin::core_host', _tmp_str)
_tmp_str = _sec.get('consul', None)
if _tmp_str is not None:
self.set_kv('plugin::consul', _tmp_str)
_log_file, ok = self.get_str('common::log-file') _log_file, ok = self.get_str('common::log-file')
if ok and _log_file: if ok and _log_file:
self.log_path = os.path.abspath(os.path.dirname(_log_file)) self.log_path = os.path.abspath(os.path.dirname(_log_file))
...@@ -459,7 +470,7 @@ class AppConfig(BaseAppConfig): ...@@ -459,7 +470,7 @@ class AppConfig(BaseAppConfig):
if conf_data is None: if conf_data is None:
log.w('system default config info is empty.\n') log.w('system default config info is empty.\n')
# return True # return True
# ===================================== # =====================================
# 全局设置相关 # 全局设置相关
# ===================================== # =====================================
...@@ -472,7 +483,7 @@ class AppConfig(BaseAppConfig): ...@@ -472,7 +483,7 @@ class AppConfig(BaseAppConfig):
self.sys.glob = tp_convert_to_attr_dict(_glob) self.sys.glob = tp_convert_to_attr_dict(_glob)
if not self.sys.glob.is_exists('url_proto'): if not self.sys.glob.is_exists('url_proto'):
self.sys.glob.url_proto = False self.sys.glob.url_proto = False
# ===================================== # =====================================
# 密码策略相关 # 密码策略相关
# ===================================== # =====================================
......
...@@ -292,9 +292,10 @@ controllers = [ ...@@ -292,9 +292,10 @@ controllers = [
# 绑定支付宝账户 # 绑定支付宝账户
(r'/plugin/bind_pay_account', plugin.BindPayAccountHandler), (r'/plugin/bind_pay_account', plugin.BindPayAccountHandler),
# 账户状态 # 账户状态
(r'/plugin/account_status', plugin.AccountStatusHandler), (r'/micro_remote/plugin/account_status', plugin.AccountStatusHandler),
# 账户账户密码获取 # 账户账户密码获取
(r'/plugin/account_info', plugin.AccountInfoHandler),
(r'/micro_remote/plugin/account_info', plugin.AccountInfoHandler),
# websocket for real-time information # websocket for real-time information
# ws-client call 'http://ip:7190/ws/action/' # ws-client call 'http://ip:7190/ws/action/'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment