-change : 适配Python3的语法
This commit is contained in:
parent
1e1ca13655
commit
b956769f9c
@ -339,7 +339,7 @@ def test():
|
||||
from PyQt4.QtCore import QCoreApplication
|
||||
|
||||
def simpletest(event):
|
||||
print u'处理每秒触发的计时器事件:%s' % str(datetime.now())
|
||||
print(u'处理每秒触发的计时器事件:%s' % str(datetime.now()))
|
||||
|
||||
app = QCoreApplication(sys.argv)
|
||||
|
||||
|
@ -8,9 +8,13 @@ import zmq
|
||||
from msgpack import packb, unpackb
|
||||
from json import dumps, loads
|
||||
|
||||
import cPickle
|
||||
pDumps = cPickle.dumps
|
||||
pLoads = cPickle.loads
|
||||
try:
|
||||
import cPickle as pickle
|
||||
except:
|
||||
# 对 python3 的支持
|
||||
import pickle
|
||||
pDumps = pickle.dumps
|
||||
pLoads = pickle.loads
|
||||
|
||||
|
||||
# 实现Ctrl-c中断recv
|
||||
|
@ -3,6 +3,7 @@
|
||||
# import shelve
|
||||
from collections import OrderedDict
|
||||
from datetime import datetime
|
||||
import traceback
|
||||
|
||||
from pymongo import MongoClient
|
||||
from pymongo.errors import ConnectionFailure
|
||||
@ -58,8 +59,8 @@ class MainEngine(object):
|
||||
self.addGateway(gatewayModule.gateway, gatewayModule.gatewayName)
|
||||
if gatewayModule.gatewayQryEnabled:
|
||||
self.gatewayDict[gatewayModule.gatewayName].setQryEnabled(True)
|
||||
except Exception, e:
|
||||
print e
|
||||
except:
|
||||
traceback.print_exc()
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def addGateway(self, gateway, gatewayName=None):
|
||||
|
@ -1,8 +1,13 @@
|
||||
# encoding: utf-8
|
||||
|
||||
import sys
|
||||
reload(sys)
|
||||
sys.setdefaultencoding('utf-8')
|
||||
try:
|
||||
# python2 需要设置编码
|
||||
reload(sys)
|
||||
sys.setdefaultencoding('utf-8')
|
||||
except:
|
||||
# python3 不需要
|
||||
pass
|
||||
import vtGlobal
|
||||
import json
|
||||
import os
|
||||
|
Loading…
Reference in New Issue
Block a user