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