From e907dacaa18f679fcdec5fb2648027363ec98f9f Mon Sep 17 00:00:00 2001 From: msincenselee Date: Thu, 11 May 2017 18:58:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=BA=E5=9C=A8=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E7=9A=84gateway=E6=B8=85=E5=8D=95=E4=B8=AD=E8=BF=9B?= =?UTF-8?q?=E8=A1=8C=E5=8A=A0=E8=BD=BD=EF=BC=8C=E5=87=8F=E5=B0=91=E8=BD=AE?= =?UTF-8?q?=E8=AF=A2=E7=9B=AE=E5=BD=95=E7=9A=84=E8=80=97=E6=97=B6=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vn.trader/gateway/__init__.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/vn.trader/gateway/__init__.py b/vn.trader/gateway/__init__.py index 20baa591..153d615d 100644 --- a/vn.trader/gateway/__init__.py +++ b/vn.trader/gateway/__init__.py @@ -11,9 +11,26 @@ import traceback # 用来保存Gateway类的字典 GATEWAY_DICT = {} +# modified by Incense Lee +# 只加载指定的gateway清单 + # 需要加载的gateway清单 load_gateways = ['ctpGateway'] +# 逐一加载 +for load_gateway in load_gateways: + # 模块名称需要上前缀 + moduleName = 'gateway.' + load_gateway + print u'load Module:{0}'.format(moduleName) + try: + # 使用importlib动态载入模块,并保存到字典中 + module = importlib.import_module(moduleName) + GATEWAY_DICT[module.gatewayName] = module + except Exception as ex: + print u'Load {0} exception:{1}'.format(moduleName, ex) + traceback.print_exc() + +""" # 获取目录路径 path = os.path.abspath(os.path.dirname(__file__)) @@ -41,3 +58,4 @@ for root, subdirs, files in os.walk(path): print u'Load {0} exception:{1}'.format(moduleName, ex) traceback.print_exc() +""" \ No newline at end of file