未验证 提交 bfcee759 编写于 作者: L Linhe Huo 提交者: GitHub

[TD-10771]<fix>: fix invalid syntax error for python2 (#8430)

上级 94318159
...@@ -28,15 +28,12 @@ def test_schemaless_insert(conn): ...@@ -28,15 +28,12 @@ def test_schemaless_insert(conn):
'stf,t1=4i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"passitagin_stf",c2=false,c5=5f64,c6=7u64 1626006933641000000', 'stf,t1=4i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"passitagin_stf",c2=false,c5=5f64,c6=7u64 1626006933641000000',
] ]
conn.schemaless_insert(lines, 0, "ns") conn.schemaless_insert(lines, 0, "ns")
print("inserted")
lines = [ lines = [
'stf,t1=5i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"passitagin_stf",c2=false,c5=5f64,c6=7u64 1626006933641000000', 'stf,t1=5i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"passitagin_stf",c2=false,c5=5f64,c6=7u64 1626006933641000000',
] ]
conn.schemaless_insert(lines, 0, "ns") conn.schemaless_insert(lines, 0, "ns")
print("inserted")
result = conn.query("select * from st") result = conn.query("select * from st")
print(*result.fields)
all = result.rows_iter() all = result.rows_iter()
for row in all: for row in all:
print(row) print(row)
......
...@@ -21,78 +21,91 @@ import json ...@@ -21,78 +21,91 @@ import json
import random import random
import time import time
import datetime import datetime
import multiprocessing
from multiprocessing import Manager, Pool, Lock from multiprocessing import Manager, Pool, Lock
from multipledispatch import dispatch from multipledispatch import dispatch
from concurrent.futures import ThreadPoolExecutor, wait, ALL_COMPLETED from concurrent.futures import ThreadPoolExecutor, wait, ALL_COMPLETED
@dispatch(str, str) @dispatch(str, str)
def v_print(msg: str, arg: str): def v_print(msg, arg):
# type: (str, str) -> None
if verbose: if verbose:
print(msg % arg) print(msg % arg)
@dispatch(str, str, str) @dispatch(str, str, str)
def v_print(msg: str, arg1: str, arg2: str): def v_print(msg, arg1, arg2):
# type: (str, str, str) -> None
if verbose: if verbose:
print(msg % (arg1, arg2)) print(msg % (arg1, arg2))
@dispatch(str, str, str, str) @dispatch(str, str, str, str)
def v_print(msg: str, arg1: str, arg2: str, arg3: str): def v_print(msg, arg1, arg2, arg3):
# type: (str, str, str, str) -> None
if verbose: if verbose:
print(msg % (arg1, arg2, arg3)) print(msg % (arg1, arg2, arg3))
@dispatch(str, str, str, str, str) @dispatch(str, str, str, str, str)
def v_print(msg: str, arg1: str, arg2: str, arg3: str, arg4: str): def v_print(msg, arg1, arg2, arg3, arg4):
# type: (str, str, str, str, str) -> None
if verbose: if verbose:
print(msg % (arg1, arg2, arg3, arg4)) print(msg % (arg1, arg2, arg3, arg4))
@dispatch(str, int) @dispatch(str, int)
def v_print(msg: str, arg: int): def v_print(msg, arg):
# type: (str, int) -> None
if verbose: if verbose:
print(msg % int(arg)) print(msg % int(arg))
@dispatch(str, int, str) @dispatch(str, int, str)
def v_print(msg: str, arg1: int, arg2: str): def v_print(msg, arg1, arg2):
# type: (str, int, str) -> None
if verbose: if verbose:
print(msg % (int(arg1), str(arg2))) print(msg % (int(arg1), str(arg2)))
@dispatch(str, str, int) @dispatch(str, str, int)
def v_print(msg: str, arg1: str, arg2: int): def v_print(msg, arg1, arg2):
# type: (str, str, int) -> None
if verbose: if verbose:
print(msg % (arg1, int(arg2))) print(msg % (arg1, int(arg2)))
@dispatch(str, int, int) @dispatch(str, int, int)
def v_print(msg: str, arg1: int, arg2: int): def v_print(msg, arg1, arg2):
# type: (str, int, int) -> None
if verbose: if verbose:
print(msg % (int(arg1), int(arg2))) print(msg % (int(arg1), int(arg2)))
@dispatch(str, int, int, str) @dispatch(str, int, int, str)
def v_print(msg: str, arg1: int, arg2: int, arg3: str): def v_print(msg, arg1, arg2, arg3):
# type: (str, int, int, str) -> None
if verbose: if verbose:
print(msg % (int(arg1), int(arg2), str(arg3))) print(msg % (int(arg1), int(arg2), str(arg3)))
@dispatch(str, int, int, int) @dispatch(str, int, int, int)
def v_print(msg: str, arg1: int, arg2: int, arg3: int): def v_print(msg, arg1, arg2, arg3):
# type: (str, int, int, int) -> None
if verbose: if verbose:
print(msg % (int(arg1), int(arg2), int(arg3))) print(msg % (int(arg1), int(arg2), int(arg3)))
@dispatch(str, int, int, int, int) @dispatch(str, int, int, int, int)
def v_print(msg: str, arg1: int, arg2: int, arg3: int, arg4: int): def v_print(msg, arg1, arg2, arg3, arg4):
# type: (str, int, int, int, int) -> None
if verbose: if verbose:
print(msg % (int(arg1), int(arg2), int(arg3), int(arg4))) print(msg % (int(arg1), int(arg2), int(arg3), int(arg4)))
def restful_execute(host: str, port: int, user: str, password: str, cmd: str): def restful_execute(host, port, user, password, cmd):
# type: (str, int, str, str, str) -> None
url = "http://%s:%d/rest/sql" % (host, restPort) url = "http://%s:%d/rest/sql" % (host, restPort)
v_print("restful_execute - cmd: %s", cmd) v_print("restful_execute - cmd: %s", cmd)
...@@ -112,7 +125,8 @@ def restful_execute(host: str, port: int, user: str, password: str, cmd: str): ...@@ -112,7 +125,8 @@ def restful_execute(host: str, port: int, user: str, password: str, cmd: str):
print("resp: %s" % json.dumps(resp.json())) print("resp: %s" % json.dumps(resp.json()))
def query_func(process: int, thread: int, cmd: str): def query_func(process, thread, cmd):
# type: (int, int, str) -> None
v_print("%d process %d thread cmd: %s", process, thread, cmd) v_print("%d process %d thread cmd: %s", process, thread, cmd)
if oneMoreHost != "NotSupported" and random.randint( if oneMoreHost != "NotSupported" and random.randint(
...@@ -133,7 +147,8 @@ def query_func(process: int, thread: int, cmd: str): ...@@ -133,7 +147,8 @@ def query_func(process: int, thread: int, cmd: str):
host, port, user, password, cmd) host, port, user, password, cmd)
def query_data_process(cmd: str): def query_data_process(cmd):
# type: (str) -> None
# establish connection if native # establish connection if native
if native: if native:
v_print("host:%s, user:%s passwd:%s configDir:%s ", host, user, password, configDir) v_print("host:%s, user:%s passwd:%s configDir:%s ", host, user, password, configDir)
...@@ -256,7 +271,8 @@ def drop_databases(): ...@@ -256,7 +271,8 @@ def drop_databases():
(dbName, i)) (dbName, i))
def insert_func(process: int, thread: int): def insert_func(process, thread):
# type: (int, int) -> None
v_print("%d process %d thread, insert_func ", process, thread) v_print("%d process %d thread, insert_func ", process, thread)
# generate uuid # generate uuid
...@@ -374,7 +390,8 @@ def create_tb(): ...@@ -374,7 +390,8 @@ def create_tb():
(tbName, j)) (tbName, j))
def insert_data_process(lock, i: int, begin: int, end: int): def insert_data_process(lock, i, begin, end):
# type: (multiprocessing._LockType, int, int, int) -> None
lock.acquire() lock.acquire()
tasks = end - begin tasks = end - begin
v_print("insert_data_process:%d table from %d to %d, tasks %d", i, begin, end, tasks) v_print("insert_data_process:%d table from %d to %d, tasks %d", i, begin, end, tasks)
...@@ -675,7 +692,10 @@ if __name__ == "__main__": ...@@ -675,7 +692,10 @@ if __name__ == "__main__":
printConfig() printConfig()
if not skipPrompt: if not skipPrompt:
input("Press any key to continue..") try:
input("Press any key to continue..")
except SyntaxError:
pass
# establish connection first if native # establish connection first if native
if native: if native:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册