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