当前位置: 首页>>代码示例>>Python>>正文


Python Log.i方法代码示例

本文整理汇总了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, ()))
开发者ID:RoyZeng,项目名称:ivy-webchat,代码行数:29,代码来源:external.py

示例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')
开发者ID:RoyZeng,项目名称:ivy-webchat,代码行数:9,代码来源:message_test.py

示例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))
开发者ID:RoyZeng,项目名称:ivy-webchat,代码行数:9,代码来源:webchat.py

示例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)
开发者ID:RoyZeng,项目名称:ivy-webchat,代码行数:12,代码来源:network.py

示例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
开发者ID:RoyZeng,项目名称:ivy-webchat,代码行数:15,代码来源:message.py

示例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))
开发者ID:RoyZeng,项目名称:ivy-webchat,代码行数:17,代码来源:network_test.py

示例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)
开发者ID:RoyZeng,项目名称:ivy-webchat,代码行数:44,代码来源:network_test.py

示例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
开发者ID:RoyZeng,项目名称:ivy-webchat,代码行数:22,代码来源:message_wrapper.py

示例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)
开发者ID:RoyZeng,项目名称:ivy-webchat,代码行数:41,代码来源:network.py

示例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')
开发者ID:RoyZeng,项目名称:ivy-webchat,代码行数:5,代码来源:dispatcher.py

示例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]))
开发者ID:RoyZeng,项目名称:ivy-webchat,代码行数:8,代码来源:network_test.py

示例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')
开发者ID:RoyZeng,项目名称:ivy-webchat,代码行数:6,代码来源:dispatcher.py


注:本文中的application.Log.i方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。