本文整理汇总了Python中util.logException函数的典型用法代码示例。如果您正苦于以下问题:Python logException函数的具体用法?Python logException怎么用?Python logException使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了logException函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: pixmapFromSvg
def pixmapFromSvg(self, pmapSize=None, withBorders=None):
"""returns a pixmap with default size as given in SVG and optional borders/shadows"""
if withBorders is None:
withBorders = Preferences.showShadows
if withBorders:
wantSize = self.tileset.tileSize.toSize()
else:
wantSize = self.tileset.faceSize.toSize()
if not pmapSize:
pmapSize = wantSize
result = QPixmap(pmapSize)
result.fill(Qt.transparent)
painter = QPainter(result)
if not painter.isActive():
logException('painter is not active. Wanted size: %s' % str(pmapSize))
try:
xScale = float(pmapSize.width()) / wantSize.width()
yScale = float(pmapSize.height()) / wantSize.height()
except ZeroDivisionError:
xScale = 1
yScale = 1
if not withBorders:
painter.scale(*self.tileset.tileFaceRelation())
painter.translate(-self.facePos())
renderer = self.tileset.renderer()
renderer.render(painter, self.elementId())
painter.resetTransform()
self._drawDarkness(painter)
if self.showFace():
faceSize = self.tileset.faceSize.toSize()
faceSize = QSize(faceSize.width() * xScale, faceSize.height() * yScale)
painter.translate(self.facePos())
renderer.render(painter, self.tileset.svgName[self.tile.element.lower()],
QRectF(QPointF(), QSizeF(faceSize)))
return result
示例2: run
def run(driver, driver_info):
"""Convenience method to run command on the given driver"""
cmd = SRCommand(driver_info)
try:
cmd.parse()
cmd.run_statics()
sr = driver(cmd, cmd.sr_uuid)
sr.direct = True
ret = cmd.run(sr)
if ret == None:
print util.return_nil ()
else:
print ret
except (Exception, SR.SRException) as e:
try:
util.logException(driver_info['name'])
except KeyError:
util.SMlog('driver_info does not contain a \'name\' key.')
except:
pass
# If exception is of type SR.SRException,
# pass to xapi, else re-raise.
if isinstance(e, SR.SRException):
print e.toxml()
else:
raise
sys.exit(0)
示例3: fset
def fset(self, lightSource):
"""set active lightSource"""
# pylint: disable=W0212
if self._lightSource != lightSource:
if lightSource not in LIGHTSOURCES:
logException(TileException('lightSource %s illegal' % lightSource))
self._reload(self.tileset, lightSource)
示例4: run
def run(driver, driver_info):
"""Convenience method to run command on the given driver"""
cmd = SRCommand(driver_info)
try:
cmd.parse()
cmd.run_statics()
sr = driver(cmd, cmd.sr_uuid)
sr.direct = True
ret = cmd.run(sr)
if ret == None:
print util.return_nil ()
else:
print ret
except (Exception, SR.SRException) as e:
try:
util.logException(driver_info['name'])
except KeyError:
util.SMlog('driver_info does not contain a \'name\' key.')
except:
pass
# If exception is of type SR.SRException, pass to Xapi.
# If generic python Exception, print a generic xmlrpclib
# dump and pass to XAPI.
if isinstance(e, SR.SRException):
print e.toxml()
else:
print xmlrpclib.dumps(xmlrpclib.Fault(1200, str(e)), "", True)
sys.exit(0)
示例5: playerByName
def playerByName(self, playerName):
"""return None or the matching player"""
if playerName is None:
return None
for myPlayer in self.players:
if myPlayer.name == playerName:
return myPlayer
logException('Move references unknown player %s' % playerName)
示例6: validateDefinition
def validateDefinition(self, prevDefinition):
"""check for validity. If wrong, restore prevDefinition."""
payers = int(self.options.get('payers', 1))
payees = int(self.options.get('payees', 1))
if not 2 <= payers + payees <= 4:
self.definition = prevDefinition
logException(m18nc('%1 can be a sentence', '%4 have impossible values %2/%3 in rule "%1"',
self.name, payers, payees, 'payers/payees'))
示例7: __getitem__
def __getitem__(self, index):
"""allow access by idx or by wind"""
if isinstance(index, basestring) and len(index) == 1:
for player in self:
if player.wind == index:
return player
logException("no player has wind %s" % index)
return list.__getitem__(self, index)
示例8: __init__
def __init__(self, cmdList, args=None, dbHandle=None, silent=False, mayFail=False):
"""we take a list of sql statements. Only the last one is allowed to be
a select statement.
Do prepared queries by passing a single query statement in cmdList
and the parameters in args. If args is a list of lists, execute the
prepared query for every sublist.
If dbHandle is passed, use that for db access.
Else if the default dbHandle (DBHandle.default) is defined, use it."""
# pylint: disable=R0912
# pylint says too many branches
silent |= not Debug.sql
self.dbHandle = dbHandle or DBHandle.default
preparedQuery = not isinstance(cmdList, list) and bool(args)
self.query = QSqlQuery(self.dbHandle)
self.msg = None
self.records = []
if not isinstance(cmdList, list):
cmdList = list([cmdList])
self.cmdList = cmdList
for cmd in cmdList:
retryCount = 0
while retryCount < 100:
self.lastError = None
if preparedQuery:
self.query.prepare(cmd)
if not isinstance(args[0], list):
args = list([args])
for dataSet in args:
if not silent:
_, utf8Args = xToUtf8(u'', dataSet)
logDebug("{cmd} [{args}]".format(cmd=cmd, args=", ".join(utf8Args)))
for value in dataSet:
self.query.addBindValue(QVariant(value))
self.success = self.query.exec_()
if not self.success:
break
else:
if not silent:
logDebug('%s %s' % (self.dbHandle.name, cmd))
self.success = self.query.exec_(cmd)
if self.success or self.query.lastError().number() not in (5, 6):
# 5: database locked, 6: table locked. Where can we get symbols for this?
break
time.sleep(0.1)
retryCount += 1
if not self.success:
self.lastError = unicode(self.query.lastError().text())
self.msg = 'ERROR in %s: %s' % (self.dbHandle.databaseName(), self.lastError)
if mayFail:
if not silent:
logDebug(self.msg)
else:
logException(self.msg)
return
self.records = None
self.fields = None
if self.query.isSelect():
self.retrieveRecords()
示例9: _log_last_triggered
def _log_last_triggered(session, sr_uuid):
try:
sr_ref = session.xenapi.SR.get_by_uuid(sr_uuid)
other_config = session.xenapi.SR.get_other_config(sr_ref)
if other_config.has_key(TRIM_LAST_TRIGGERED_KEY):
session.xenapi.SR.remove_from_other_config(sr_ref, TRIM_LAST_TRIGGERED_KEY)
session.xenapi.SR.add_to_other_config(sr_ref, TRIM_LAST_TRIGGERED_KEY, str(time.time()))
except:
util.logException("Unable to set other-config:%s" % TRIM_LAST_TRIGGERED_KEY)
示例10: initDb
def initDb():
"""open the db, create or update it if needed.
sets DBHandle.default."""
try:
DBHandle() # sets DBHandle.default
except BaseException as exc:
DBHandle.default = None
logException(exc)
return False
return True
示例11: attach_from_config
def attach_from_config(self, sr_uuid, vdi_uuid):
"""Used for HA State-file only. Will not just attach the VDI but
also start a tapdisk on the file"""
util.SMlog("NFSFileVDI.attach_from_config")
try:
self.sr.attach(sr_uuid)
except:
util.logException("NFSFileVDI.attach_from_config")
raise xs_errors.XenError('SRUnavailable', \
opterr='Unable to attach from config')
示例12: attach_from_config
def attach_from_config(self, sr_uuid, vdi_uuid):
util.SMlog("LVHDoISCSIVDI.attach_from_config")
try:
self.sr.iscsi.attach(sr_uuid)
if not self.sr.iscsi._attach_LUN_bySCSIid(self.sr.SCSIid):
raise xs_errors.XenError("InvalidDev")
return LVHDSR.LVHDVDI.attach(self, sr_uuid, vdi_uuid)
except:
util.logException("LVHDoISCSIVDI.attach_from_config")
raise xs_errors.XenError("SRUnavailable", opterr="Unable to attach the heartbeat disk")
示例13: attach_from_config
def attach_from_config(self, sr_uuid, vdi_uuid):
util.SMlog("LVHDoHBAVDI.attach_from_config")
self.sr.hbasr.attach(sr_uuid)
if self.sr.mpath == "true":
self.sr.mpathmodule.refresh(self.sr.SCSIid,0)
try:
return self.attach(sr_uuid, vdi_uuid)
except:
util.logException("LVHDoHBAVDI.attach_from_config")
raise xs_errors.XenError('SRUnavailable', \
opterr='Unable to attach the heartbeat disk')
示例14: attach_from_config
def attach_from_config(self, sr_uuid, vdi_uuid):
util.SMlog("OCFSoISCSIVDI.attach_from_config")
try:
self.sr.iscsi.attach(sr_uuid)
if not self.sr.iscsi._attach_LUN_bySCSIid(self.sr.SCSIid):
raise xs_errors.XenError('InvalidDev')
return OCFSSR.OCFSFileVDI.attach(self, sr_uuid, vdi_uuid)
except:
util.logException("OCFSoISCSIVDI.attach_from_config")
raise xs_errors.XenError('SRUnavailable', \
opterr='Unable to attach the heartbeat disk')
示例15: findFreePort
def findFreePort():
"""find an unused port on the current system.
used when we want to start a local server on windows"""
for port in range(2000, 9000):
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.settimeout(1)
try:
sock.connect(('127.0.0.1', port))
except socket.error:
return port
logException('cannot find a free port')