[Mod]部分代码向3风格兼容修改

This commit is contained in:
vn.py 2017-11-30 17:19:26 +08:00
parent 64bd2eb6d2
commit b2aa6c5c2b
8 changed files with 20 additions and 16 deletions

View File

@ -1,3 +1,3 @@
# encoding: UTF-8
from .eventEngine import EventEngine, EventEngine2, Event
from .eventEngine import EventEngine, EventEngine2, Event, EVENT_TIMER

View File

@ -1,7 +1,7 @@
# encoding: UTF-8
# 系统模块
from Queue import Queue, Empty
from queue import Queue, Empty
from threading import Thread
from time import sleep
from collections import defaultdict
@ -10,7 +10,7 @@ from collections import defaultdict
from qtpy.QtCore import QTimer
# 自己开发的模块
from eventType import *
from .eventType import *
########################################################################
@ -339,7 +339,7 @@ def test():
from PyQt4.QtCore import QCoreApplication
def simpletest(event):
print u'处理每秒触发的计时器事件:%s' % str(datetime.now())
print(u'处理每秒触发的计时器事件:{}'.format(str(datetime.now())))
app = QCoreApplication(sys.argv)

View File

@ -32,12 +32,12 @@ def test():
for key, value in check_dict.items():
if len(value)>1:
print u'存在重复的常量定义:' + str(key)
print(u'存在重复的常量定义:{}'.format(str(key)))
for name in value:
print name
print ''
print u'测试完毕'
print(u'测试完毕')
# 直接运行脚本可以进行测试

View File

@ -1,7 +1,7 @@
# encoding: UTF-8
from ctaEngine import CtaEngine
from uiCtaWidget import CtaEngineManager
from .ctaEngine import CtaEngine
from .uiCtaWidget import CtaEngineManager
appName = 'CtaStrategy'
appDisplayName = u'CTA策略'

View File

@ -385,8 +385,9 @@ class CtaEngine(object):
try:
name = setting['name']
className = setting['className']
except Exception, e:
self.writeCtaLog(u'载入策略出错:%s' %e)
except Exception:
msg = traceback.format_exc()
self.writeCtaLog(u'载入策略出错:%s' %msg)
return
# 获取策略类

View File

@ -23,7 +23,7 @@ def loadStrategyModule(moduleName):
v = module.__getattribute__(k)
STRATEGY_CLASS[k] = v
except:
print '-' * 20
print ('-' * 20)
print ('Failed to import strategy file %s:' %moduleName)
traceback.print_exc()

View File

@ -4,9 +4,9 @@ import json
import os
# 默认设置
from chinese import text, constant
from .chinese import text, constant
# 是否要使用英文
from vnpy.trader.vtGlobal import globalSetting
if globalSetting['language'] == 'english':
from english import text, constant
from .english import text, constant

View File

@ -7,7 +7,7 @@
import os
import traceback
import json
from vtFunction import getJsonPath
from .vtFunction import getJsonPath
settingFileName = "VT_setting.json"
@ -16,8 +16,11 @@ settingFilePath = getJsonPath(settingFileName, __file__)
globalSetting = {} # 全局配置字典
try:
f = file(settingFilePath)
globalSetting = json.load(f)
with open(settingFilePath) as f:
setting = f.read()
if type(setting) is not str:
setting = str(setting, encoding='utf8')
globalSetting = json.loads(setting)
except:
traceback.print_exc()