mirror of https://github.com/tp4a/teleport
.tmp.
parent
c240f94da5
commit
bffefe8965
|
@ -307,6 +307,7 @@ void TsWsClient::_create_response(ex_astr& buf, const AssistMessage& msg_ret, in
|
|||
|
||||
void TsWsClient::_on_message(const std::string& message, std::string& buf)
|
||||
{
|
||||
// e.g.:
|
||||
// {
|
||||
// "type":0,
|
||||
// "method":"run",
|
||||
|
@ -317,6 +318,8 @@ void TsWsClient::_on_message(const std::string& message, std::string& buf)
|
|||
// }
|
||||
// }
|
||||
|
||||
EXLOGV("on_message: %s\n", message.c_str());
|
||||
|
||||
AssistMessage msg_req;
|
||||
|
||||
Json::CharReaderBuilder jrb;
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
[common]
|
||||
; 'log-file' define the log file location. if not set, default locate
|
||||
; to $INSTDIR%/data/log/tpcore.log
|
||||
;log-file=/var/log/teleport/tpcore.log
|
||||
; to $TELEPORT_INSTDIR%/data/log/tpcore.log
|
||||
;log-file=/usr/local/teleport/data/log/tpcore.log
|
||||
|
||||
; log-level can be 0 ~ 4, default value is 2.
|
||||
; LOG_LEVEL_DEBUG 0 log every-thing.
|
||||
|
@ -18,8 +18,8 @@ log-level=2
|
|||
debug-mode=0
|
||||
|
||||
; 'replay-path' define the replay file location. if not set, default locate
|
||||
; to `$INSTDIR%/data/replay`
|
||||
;replay-path=/var/lib/teleport/replay
|
||||
; to `$TELEPORT_INSTDIR/data/replay`
|
||||
;replay-path=/usr/local/teleport/data/replay
|
||||
|
||||
; `web-server-rpc` is the rpc interface of web server.
|
||||
; default to `http://127.0.0.1:7190/rpc`.
|
||||
|
|
|
@ -38,14 +38,8 @@ def _export_table(db, table_name):
|
|||
else:
|
||||
fields_count = len(fields)
|
||||
for i in range(len(d)):
|
||||
# x = []
|
||||
# for j in range(fields_count):
|
||||
# x.append(d[i][j].__str__())
|
||||
# val = "','".join(x).replace('\n', '\\n')
|
||||
x = list()
|
||||
for j in range(fields_count):
|
||||
# if j > 0:
|
||||
# x.append(',')
|
||||
if s[j]:
|
||||
if d[i][j] is None:
|
||||
x.append('NULL')
|
||||
|
@ -54,12 +48,11 @@ def _export_table(db, table_name):
|
|||
else:
|
||||
x.append('{}'.format(d[i][j]))
|
||||
val = ','.join(x)
|
||||
print('VAL:', val, '\n')
|
||||
|
||||
sql = "INSERT INTO `{}` VALUES ({});".format(table_name, val)
|
||||
ret.append(sql)
|
||||
|
||||
return '\r\n'.join(ret)
|
||||
return '\n'.join(ret)
|
||||
|
||||
|
||||
def export_database(db):
|
||||
|
@ -67,9 +60,9 @@ def export_database(db):
|
|||
now = time.localtime(time.time())
|
||||
ret.append('-- {:04d}-{:02d}-{:02d} {:02d}:{:02d}:{:02d} '.format(now.tm_year, now.tm_mon, now.tm_mday, now.tm_hour, now.tm_min, now.tm_sec))
|
||||
if db.db_type == db.DB_TYPE_SQLITE:
|
||||
ret.append('-- export from SQLite Database')
|
||||
ret.append('-- export from Teleport SQLite Database')
|
||||
elif db.db_type == db.DB_TYPE_MYSQL:
|
||||
ret.append('-- export from MySQL Database')
|
||||
ret.append('-- export from Teleport MySQL Database')
|
||||
else:
|
||||
return '未知的数据库类型', False
|
||||
|
||||
|
@ -77,24 +70,7 @@ def export_database(db):
|
|||
if db_ret is None or 0 == len(db_ret):
|
||||
return '无法获取数据库版本', False
|
||||
else:
|
||||
ret.append('-- DATABASE VERSION {}'.format(db_ret[0][0]))
|
||||
|
||||
# _fields = ['account_id', 'account_type', 'account_name', 'account_pwd', 'account_status', 'account_lock', 'account_desc', 'oath_secret']
|
||||
# ret.append(_export_table(db, 'account', _fields))
|
||||
# _fields = ['auth_id', 'account_name', 'host_id', 'host_auth_id']
|
||||
# ret.append(_export_table(db, 'auth', _fields))
|
||||
# _fields = ['cert_id', 'cert_name', 'cert_pub', 'cert_pri', 'cert_desc']
|
||||
# ret.append(_export_table(db, 'key', _fields))
|
||||
# _fields = ['name', 'value']
|
||||
# ret.append(_export_table(db, 'config', _fields))
|
||||
# _fields = ['group_id', 'group_name']
|
||||
# ret.append(_export_table(db, 'group', _fields))
|
||||
# _fields = ['host_id', 'group_id', 'host_sys_type', 'host_ip', 'host_port', 'protocol', 'host_lock', 'host_desc']
|
||||
# ret.append(_export_table(db, 'host_info', _fields))
|
||||
# _fields = ['id', 'host_id', 'auth_mode', 'user_name', 'user_pswd', 'user_param', 'cert_id', 'encrypt', 'log_time']
|
||||
# ret.append(_export_table(db, 'auth_info', _fields))
|
||||
# _fields = ['id', 'session_id', 'account_name', 'host_ip', 'host_port', 'sys_type', 'auth_type', 'protocol', 'user_name', 'ret_code', 'begin_time', 'end_time', 'log_time']
|
||||
# ret.append(_export_table(db, 'log', _fields))
|
||||
ret.append('-- TELEPORT DATABASE VERSION {}'.format(db_ret[0][0]))
|
||||
|
||||
ret.append(_export_table(db, 'config'))
|
||||
ret.append(_export_table(db, 'core_server'))
|
||||
|
@ -116,4 +92,4 @@ def export_database(db):
|
|||
ret.append(_export_table(db, 'record'))
|
||||
ret.append(_export_table(db, 'record_audit'))
|
||||
|
||||
return '\r\n'.join(ret), True
|
||||
return '\n'.join(ret), True
|
||||
|
|
Loading…
Reference in New Issue