Unverified Commit 8927d9cd authored by cyjseagull's avatar cyjseagull Committed by GitHub
Browse files

fix ci (#103)

parent 6446c32f
......@@ -20,17 +20,6 @@ matrix:
- name: "Python 3.5 on Xenial Linux"
python: 3.5
dist: xenial
- name: "Python 3.7.2 on macOS"
os: osx
osx_image: xcode10.14.3 # Python 3.7.2 running on macOS 10.14.3
language: shell # 'language: python' is an error on Travis CI macOS
before_install:
- bash -x init_env.sh -p
- source ~/.bashrc
- pyenv global 3.7.3
- pip install --upgrade pip
- pip install -r requirements.txt
- bash init_env.sh -i
# - name: "Python 3.7.3 on Windows"
# os: windows # Windows 10.0.17134 N/A Build 17134
# language: shell # 'language: python' is an error on Travis CI Windows
......
......@@ -174,28 +174,28 @@ function test_permission_precompile()
# grantPermissionManager
execute_cmd "python console.py grantPermissionManager ${account}"
# listPermissionManager
execute_cmd "python console.py listPermissionManager | grep ${account}"
execute_cmd "python console.py listPermissionManager | grep -i ${account}"
granted_account="0xcDF16CeF9004b1ECCf464Ae559996712E250D5A9"
# grantNodeManager
execute_cmd "python console.py grantNodeManager ${granted_account}"
# listNodeManager
execute_cmd "python console.py listNodeManager | grep ${granted_account}"
execute_cmd "python console.py listNodeManager | grep -i ${granted_account}"
# grantCNSManager
execute_cmd "python console.py grantCNSManager ${granted_account}"
# listCNSManager
execute_cmd "python console.py listCNSManager | grep ${granted_account}"
execute_cmd "python console.py listCNSManager | grep -i ${granted_account}"
# grantSysConfigManager
execute_cmd "python console.py grantSysConfigManager ${granted_account}"
# listSysConfigManager
execute_cmd "python console.py listSysConfigManager | grep ${granted_account}"
execute_cmd "python console.py listSysConfigManager | grep -i ${granted_account}"
# grantUserTableManager
execute_cmd "python console.py grantUserTableManager ${table} ${granted_account}"
# listUserTableManager
execute_cmd "python console.py listUserTableManager ${table} |grep ${granted_account}"
execute_cmd "python console.py listUserTableManager ${table} |grep -i ${granted_account}"
# grantDeployAndCreateManager
execute_cmd "python console.py grantDeployAndCreateManager ${granted_account}"
# listDeployAndCreateManager
execute_cmd "python console.py listDeployAndCreateManager | grep ${granted_account}"
execute_cmd "python console.py listDeployAndCreateManager | grep -i ${granted_account}"
# call revoke
# revokeUserTableManager
......@@ -212,10 +212,10 @@ function test_permission_precompile()
execute_cmd "python console.py revokePermissionManager ${granted_account}"
# call list again
python console.py listUserTableManager ${table}| grep ${granted_account}
python console.py listUserTableManager ${table}| grep -i ${granted_account}
command_list="listDeployAndCreateManager listNodeManager listCNSManager listSysConfigManager listPermissionManager"
for command in ${command_list};do
python console.py ${command} | grep ${granted_account}
python console.py ${command} | grep -i ${granted_account}
done
}
......
......@@ -17,34 +17,38 @@ from client import clientlogger
import queue
import time
from client.channelpack import ChannelPack
class ChannelPushHandler: #interface
def on_push(self,packmsg):
class ChannelPushHandler: # interface
def on_push(self, packmsg):
pass
class ChannelPushDispatcher (threading.Thread):
dispatch_register = dict()
keepWorking = False
logger = clientlogger.logger
pushQueue = queue.Queue(1024*10)
lock = threading.RLock()
def __init__(self):
threading.Thread.__init__(self)
def add_handler(self,pack_type,handler):
def add_handler(self, pack_type, handler):
try:
self.lock.acquire()
if pack_type in self.dispatch_register:
self.dispatch_register[pack_type][handler] = True
else:
handlerMap = dict()
handlerMap[handler] =True
handlerMap[handler] = True
self.dispatch_register[pack_type] = handlerMap
except Exception as e:
self.logger.error("channel push dispatcher add handler error",e)
self.logger.error("channel push dispatcher add handler error", e)
finally:
self.lock.release()
def remove_handler(self,pack_type,handler):
def remove_handler(self, pack_type, handler):
try:
self.lock.acquire()
if pack_type in self.dispatch_register:
......@@ -53,11 +57,11 @@ class ChannelPushDispatcher (threading.Thread):
else:
return
except Exception as e:
self.logger.error("channel push dispatcher remove_handler error",e)
self.logger.error("channel push dispatcher remove_handler error", e)
finally:
self.lock.release()
def getHandler(self,pack_type):
def getHandler(self, pack_type):
try:
self.lock.acquire()
if pack_type in self.dispatch_register:
......@@ -65,7 +69,7 @@ class ChannelPushDispatcher (threading.Thread):
else:
return dict()
except Exception as e:
self.logger.error("channel push dispatcher remove_handler error",e)
self.logger.error("channel push dispatcher remove_handler error", e)
finally:
self.lock.release()
......@@ -74,64 +78,67 @@ class ChannelPushDispatcher (threading.Thread):
self.keepWorking = False
self.join(timeout=1)
def push(self,packmsg:ChannelPack):
def push(self, packmsg: ChannelPack):
if self.pushQueue.full():
pack = self.pushQueue.get_nowait()
self.logger.error("Push queue FULL pop and LOST: {}".format(pack.detail()))
self.pushQueue.put_nowait(packmsg)
def dealmsg(self,packmsg):
def dealmsg(self, packmsg):
try:
self.lock.acquire()
handlers = self.getHandler(packmsg.type)
if handlers is None:
#no handler register
# no handler register
return
for handler in handlers:
if isinstance(handler, ChannelPushHandler):
handler.on_push(packmsg)
except Exception as e:
print("{} push handler error {},{},{}".format(self.name, e, packmsg.type, packmsg.data))
self.logger.error("{} push handler error {},{},{}".format(self.name, e, packmsg.type, packmsg.data))
self.logger.error("{} push handler error {},{},{}".format(
self.name, e, packmsg.type, packmsg.data))
finally:
self.lock.release()
def run(self) :
def run(self):
try:
self.keepWorking = True
self.logger.debug(self.name + ":start thread-->")
#print(self.name + ":start thread-->")
while self.keepWorking:
#print(self.name + ":start-->",self.keepWorking)
packmsg:ChannelPack = None
packmsg = None
if not self.pushQueue.empty():
packmsg:ChannelPack =self.pushQueue.get_nowait()
packmsg = self.pushQueue.get_nowait()
if packmsg is None and self.keepWorking:
time.sleep(0.01)
#print("push running")
continue
self.dealmsg(packmsg)
except Exception as e:
print("push Thread exception:",e)
print("push Thread exception:", e)
self.logger.error("{} push dispatcher error {}".format(self.name, e))
finally:
self.logger.debug("{}:thread finished ,keepWorking = {}".format(
self.name, self.keepWorking))
if False:
cpp = ChannelPushDispacher()
handler = "test"
cpp.add_handler(1,handler)
cpp.add_handler(1,handler)
cpp.add_handler(1, handler)
cpp.add_handler(1, handler)
handler = "test123"
cpp.add_handler(1,handler)
cpp.add_handler(1, handler)
print(cpp.getHandler(1))
cpp.remove_handler(1,handler)
cpp.remove_handler(1, handler)
print(cpp.getHandler(1))
cpp.add_handler(2,"2handler")
cpp.add_handler(2,"3handler")
cpp.add_handler(3,"2handler")
cpp.add_handler(2, "2handler")
cpp.add_handler(2, "3handler")
cpp.add_handler(3, "2handler")
print(cpp.dispatch_register)
for (item,v) in cpp.getHandler(1).items():
print("{}:{}".format(item,v) )
\ No newline at end of file
for (item, v) in cpp.getHandler(1).items():
print("{}:{}".format(item, v))
......@@ -45,7 +45,6 @@ class ChannelHandler(threading.Thread):
recvThread = None
sendThread = None
keepWorking = False
pushDispacher = ChannelPushDispatcher()
def __init__(self, max_timeout=10, name="channelHandler"):
self.timeout = max_timeout
......@@ -140,6 +139,7 @@ class ChannelHandler(threading.Thread):
self.recvThread.start()
self.sendThread = ChannelSendThread(self)
self.sendThread.start()
self.pushDispacher = ChannelPushDispatcher()
self.pushDispacher.start()
super().start()
except Exception as e:
......
......@@ -46,7 +46,7 @@ class client_config:
# ---------runtime related--------------
# path of solc compiler
solc_path = "bin/solc/solc-gm.exe"
solc_path = os.environ["HOME"] + "/.py-solc/solc-v0.4.25/bin/solc"
solcjs_path = "./solcjs"
logdir = "bin/logs" # 默认日志输出目录,该目录必须先建立
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