本文整理汇总了Python中application.Log类的典型用法代码示例。如果您正苦于以下问题:Python Log类的具体用法?Python Log怎么用?Python Log使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Log类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load
def load(self, name, vmId, port, password):
self.vmInfo = {'name': name, 'port': port, 'password': password, 'obj': self}
try:
self.mach = self.vbox.findMachine(name)
desc = self.mach.getGuestPropertyValue('vm_desc')
self.vmInfo['desc'] = str(desc) if desc else ''
type_ = self.mach.getGuestPropertyValue('vm_type')
if not type_ or int(type_) not in (VirtualMachine.Type_Stand, VirtualMachine.Type_Id_Extract):
self.vmInfo['status'] = VirtualMachine.Status_Invalid
self.vmInfo['type'] = -1
return self.vmInfo
self.vmInfo['type'] = int(type_)
if self.mach.state == self.mgr.constants.MachineState_Running:
self.vmInfo['status'] = VirtualMachine.Status_Running
return self.vmInfo
self.session = self.mgr.mgr.getSessionObject(self.vbox)
self.mach.lockMachine(self.session, self.mgr.constants.LockType_Write)
mutable = self.session.machine
mutable.setGuestPropertyValue('vm_vmId', vmId)
mutable.VRDEServer.setVRDEProperty('VNCPassword', str(password))
mutable.VRDEServer.setVRDEProperty('TCP/Ports', str(port))
mutable.VRDEServer.enabled = True
mutable.saveSettings()
self.session.unlockMachine()
except Exception, e:
Log.e(getExceptionInfo(e))
return
示例2: read
def read(self):
try:
message = self.socket.recv(4096)
except Exception as e:
Log.e(getExceptionInfo(e))
return Client.ReadError
if len(message) == 0:
return Client.NoMessage
self.buf += message
while len(self.buf) > 4:
length = int(self.buf[0:4])
if not len(self.buf) >= length + 4:
break
msg = self.buf[4: length + 4]
self.buf = self.buf[length + 4:]
message = Message()
if not message.loads(msg):
Log.w(u'Unknown Message')
else:
self.requests.put(message)
return Client.NewMessage
示例3: __getitem__
def __getitem__(self, item):
param = None
try:
param = self.params[item]
except Exception as e:
Log.e(getExceptionInfo(e))
return param
示例4: deleteSelectedItems
def deleteSelectedItems(self):
selection = self.gpsTable.selectionModel()
indexes = selection.selectedRows()
#uuids: {clientId: [uuid,]}
uuids = {}
for index in indexes:
uuid_ = self.gpsModel.gpsItems[index.row()].id()
clientId = application.lookUpClientIdByResourceId(uuid_)
if clientId in uuids:
uuids[clientId].append(uuid_)
else:
uuids[clientId] = [uuid_]
if len(uuids) == 0:
return
for clientId in uuids:
message = Message(cmd=Message.CMD_DELETE_GPS)
message['ids'] = uuids[clientId]
EventManager.trigger(Event('Client.replyReady.' + clientId, message))
self.deleteGpsItems(uuids[clientId])
for uuid_ in uuids[clientId]:
toolBarId = application.lookUpToolBarIdByResourceId(uuid_)
if toolBarId:
EventManager.trigger(Event('ToolBar.changeState.' + toolBarId, True))
else:
Log.e(u'未找到对应的ToolBar')
示例5: dumps
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')
示例6: dispatchRequest
def dispatchRequest(self, request):
cmd = request.getCMD()
if not cmd:
Log.i('缺少cmd参数')
identifier = request.getParam('identifier')
EventManager.trigger(Event('Socket.addReply.' + identifier,
request))
示例7: getParam
def getParam(self, name):
param = None
try:
param = self.request[name]
except Exception as e:
Log.e(getExceptionInfo(e))
return param
示例8: handleDeleteGpsOk
def handleDeleteGpsOk(self, request):
ids = request['ids']
for id_ in ids:
toolBarId = application.lookUpToolBarIdByResourceId(id_)
if toolBarId:
EventManager.trigger(Event('ToolBar.changeState.' + toolBarId, False))
else:
Log.e(u'未找到需要改变状态的ToolBar')
application.delItemFromToolBar(id_)
示例9: lastInsertRowId
def lastInsertRowId(self):
query = QSqlQuery(self.db)
if not query.exec_('SELECT last_insert_rowid()'):
Log.e('获取最后插入id失败')
return False
if not query.next():
Log.e('获取最后插入id失败')
return False
return query.value(0)
示例10: updateGps
def updateGps(self, request):
clientId = request.getParam('clientId')
if not clientId:
Log.e('ExternalDispatcher.updateGps: 权限不足')
return
if clientId not in self.server.clients:
Log.e('ExternalDispatcher.updateGps: 该客户端在服务器中不存在')
return
EventManager.trigger(Event('DataCenter.updateGps', request['id'], request['desc'], clientId))
示例11: queryAccount
def queryAccount(self, request):
clientId = request.getParam('clientId')
if not clientId:
Log.e('ExternalDispatcher.queryAccount: 权限不足')
return
if clientId not in self.server.clients:
Log.e('ExternalDispatcher.queryAccount: 该客户端在服务器中不存在')
return
EventManager.trigger(Event('DataCenter.loadAllAccount', clientId))
示例12: reply
def reply(self):
reply = self.replies.get()
data = reply.dumps()
if data:
try:
self.socket.send(bytes(str(len(data)).zfill(4)) + data)
return self.WriteSuccess
except Exception as e:
Log.e("Can't send reply: " + getExceptionInfo(e))
return self.WriteError
示例13: clearVmForClient
def clearVmForClient(self, clientId):
if clientId in self.externalToVm:
for vm in self.externalToVm[clientId]:
success, vmInfo = self.vm.closeMachine(vm[0])
if not success:
Log.e('关闭虚拟机失败:' + vm[1]['name'])
continue
message = Message(cmd=Message.CMD_VM_UPDATED, vmId=vm[0], status=VirtualMachine.Status_Idle)
EventManager.trigger(Event('Message.broadcast', message, ()))
del self.externalToVm[clientId]
示例14: addRecord
def addRecord(self, table, **kwargs):
model = QSqlTableModel(self, self.db)
model.setTable(table)
record = model.record()
for field in kwargs:
record.setValue(field, kwargs[field])
if not model.insertRecord(-1, record):
Log.e('添加记录失败')
return False
else:
model.submitAll()
示例15: dispatchRequest
def dispatchRequest(self, request):
cmd = request.getCMD()
if cmd in self.callbacks:
self.callbacks[cmd](request)
elif Message.CMD_BRIDGE_START <= cmd < Message.CMD_WEBCHAT_END:
try:
webchatId = request.getParam('webchatId')
EventManager.trigger(Event('Socket.addReply.' + webchatId, request))
except Exception as e:
Log.e(getExceptionInfo(e))
else:
Log.w('未实现的命令: ' + str(cmd))