本文整理汇总了Python中application.Log.i方法的典型用法代码示例。如果您正苦于以下问题:Python Log.i方法的具体用法?Python Log.i怎么用?Python Log.i使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类application.Log
的用法示例。
在下文中一共展示了Log.i方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: startVM
# 需要导入模块: from application import Log [as 别名]
# 或者: from application.Log import i [as 别名]
def startVM(self, request):
clientId = request.getParam('clientId')
if not clientId:
Log.e('ExternalDispatcher.startVM: 权限不足')
return
if clientId not in self.server.clients:
Log.e('ExternalDispatcher.startVM: 该客户端在服务器中不存在')
return
vmId = request['vmId']
success, vmInfo = self.vm.startMachine(vmId)
if not success:
Log.e("启动虚拟机失败")
EventManager.trigger(Event('Socket.addReply.' + clientId,
Message(cmd=Message.CMD_VM_START_FAIL, vmId=vmId)))
return
else:
Log.i('成功启动虚拟机: ' + str(vmInfo['name']))
if clientId in self.externalToVm:
self.externalToVm[clientId].append((vmId, vmInfo))
else:
self.externalToVm[clientId] = [(vmId, vmInfo)]
EventManager.trigger(Event('Socket.addReply.' + clientId,
Message(cmd=Message.CMD_VM_START_OK, vmId=vmId, port=vmInfo['port'],
password=vmInfo['password'])))
message = Message(cmd=Message.CMD_VM_UPDATED, vmId=vmId, status=VirtualMachine.Status_Running)
EventManager.trigger(Event('Message.broadcast', message, ()))
示例2: dumps
# 需要导入模块: from application import Log [as 别名]
# 或者: from application.Log import i [as 别名]
def dumps(self):
if 'cmd' not in self.params:
Log.e('cmd不存在')
return None
message = json.dumps(self.params)
Log.i('生成Message: ' + message)
return bytes(message).encode('utf-8')
示例3: dispatchRequest
# 需要导入模块: from application import Log [as 别名]
# 或者: from application.Log import i [as 别名]
def dispatchRequest(self, request):
cmd = request.getCMD()
if not cmd:
Log.i('缺少cmd参数')
identifier = request.getParam('identifier')
EventManager.trigger(Event('Socket.addReply.' + identifier,
request))
示例4: acceptNewClient
# 需要导入模块: from application import Log [as 别名]
# 或者: from application.Log import i [as 别名]
def acceptNewClient(self):
Log.i('connect in')
s, addr = self.serverSocket.accept()
if not s:
Log.e('Cannot accept connection')
return
identifier = uuid.uuid4().hex
self.clients[identifier] = Socket(s, identifier)
self.clients[identifier].addReply(Message(cmd=Message.CMD_CLIENT_VALIDATED, clientId=identifier))
Log.i(self.clients)
示例5: loads
# 需要导入模块: from application import Log [as 别名]
# 或者: from application.Log import i [as 别名]
def loads(self, message):
try:
message = message.decode('utf-8')
except UnicodeError:
Log.e('无法使用utf-8解码消息: ' + binascii.hexlify(message))
return False
try:
self.params = json.loads(message)
Log.i('成功解析Message: ' + str(self.params))
except Exception as e:
Log.e(getExceptionInfo(e))
return False
return True
示例6: connectToServer
# 需要导入模块: from application import Log [as 别名]
# 或者: from application.Log import i [as 别名]
def connectToServer(self, address):
"""address格式为(url, port)"""
if self.hasConnected(address):
Log.w('已经连接到服务器')
return
clientSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
clientSocket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
try:
clientSocket.connect(address)
client = Client(clientSocket, -1)
self.clients[client] = (address, -1)
Log.i('成功连接到服务器')
return True
except Exception as e:
Log.e(getExceptionInfo(e))
示例7: run
# 需要导入模块: from application import Log [as 别名]
# 或者: from application.Log import i [as 别名]
def run(self):
while True:
brokenClients = []
readers, writers = self.setFs()
rList, wList, eList = select.select(readers, writers, [], 0.2)
for client in self.clients:
if client.getFd() in rList:
status = client.read()
if status == Client.ReadError:
Log.e('Socket read error')
brokenClients.append(client)
elif status == Client.NoMessage:
Log.i('No Message')
brokenClients.append(client)
elif status == Client.NewMessage:
Log.i('New Message')
else:
Log.e('Unknown socket status')
if client.hasRequests():
self.treatMessage(client)
if client.getFd() in wList:
status = client.reply()
if status == Client.WriteError:
Log.e('Socket write error with socket %s' % (self.clients[client][0], ))
if client not in brokenClients:
brokenClients.append(client)
elif status == Client.WriteSuccess:
Log.i('Send Message success')
for client in brokenClients:
Log.i('删除客户端: ' + str(self.clients[client][0]))
client.close()
del self.clients[client]
self.clientDisconnected.emit(str(client.clientId))
Log.i(self.clients)
示例8: dumps
# 需要导入模块: from application import Log [as 别名]
# 或者: from application.Log import i [as 别名]
def dumps(self):
reply = '{'
if 'cmd' not in self.params:
Log.e('cmd不存在')
return None
else:
for count, name in enumerate(self.params):
if count > 0:
reply += ', '
reply += '"{name}": '.format(name=name)
value = self.params[name]
if isinstance(value, str) or isinstance(value, unicode):
reply += '"{value}"'.format(value=value)
else:
reply += str(value)
reply.rstrip(' ')
reply += '}'
Log.i('生成Reply: ' + reply)
self.reply = bytes(reply).encode('utf-8')
return self.reply
示例9: run
# 需要导入模块: from application import Log [as 别名]
# 或者: from application.Log import i [as 别名]
def run(self):
while True:
brokenClients = []
readers, writers = self.setFs()
rList, wList, eList = select.select(readers, writers, [], 0.2)
if self.getFd() in rList:
self.acceptNewClient()
for identifier in self.clients:
if self.clients[identifier].getFd() in rList:
status = self.clients[identifier].read()
if status == Socket.ReadError:
Log.e('Socket read error')
brokenClients.append(identifier)
elif status == Socket.NoMessage:
Log.i('No Message')
brokenClients.append(identifier)
elif status == Socket.NoMessage:
Log.i('New Message')
if self.clients[identifier].hasRequests():
self.treatMessage(self.clients[identifier])
if self.clients[identifier].getFd() in wList:
status = self.clients[identifier].reply()
if status == Socket.WriteError:
Log.e('Socket write error with socket %s' % (identifier, ))
if identifier not in brokenClients:
brokenClients.append(identifier)
elif status == Socket.WriteSuccess:
Log.i('Send Message success')
for identifier in brokenClients:
Log.i('删除客户端: ' + str(identifier))
self.clients[identifier].close()
del self.clients[identifier]
self.clientDisconnected.emit(identifier)
Log.i(self.clients)
示例10: dispatchRequest
# 需要导入模块: from application import Log [as 别名]
# 或者: from application.Log import i [as 别名]
def dispatchRequest(self, request):
Log.i('Default dispatcher: ' + str(request))
Log.w('You need to setDispatcher for the Server')
示例11: disConnectToServer
# 需要导入模块: from application import Log [as 别名]
# 或者: from application.Log import i [as 别名]
def disConnectToServer(self, address):
for client in self.clients:
if self.clients[client][0] == address:
client.close()
del self.clients[client]
Log.i('删除客户端: ' + str(self.clients[client][0]))
示例12: dispatchRequest
# 需要导入模块: from application import Log [as 别名]
# 或者: from application.Log import i [as 别名]
def dispatchRequest(self, client):
request = client.getRequest()
Log.i('Default dispatcher: ' + str(request))
Log.w('You need to setDispatcher for the Server')