• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python util.logException函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中util.logException函数的典型用法代码示例。如果您正苦于以下问题:Python logException函数的具体用法?Python logException怎么用?Python logException使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了logException函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
开发者ID:ospalh,项目名称:kajongg-fork,代码行数:35,代码来源:uitile.py


示例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)
开发者ID:letsboogey,项目名称:sm,代码行数:31,代码来源:SRCommand.py


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


示例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)
开发者ID:chandrikas,项目名称:sm,代码行数:32,代码来源:SRCommand.py


示例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)
开发者ID:ospalh,项目名称:kajongg-fork,代码行数:8,代码来源:game.py


示例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'))
开发者ID:ospalh,项目名称:kajongg-fork,代码行数:8,代码来源:rule.py


示例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)
开发者ID:ospalh,项目名称:kajongg-fork,代码行数:8,代码来源:player.py


示例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()
开发者ID:ospalh,项目名称:kajongg-fork,代码行数:58,代码来源:query.py


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


示例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
开发者ID:ospalh,项目名称:kajongg-fork,代码行数:10,代码来源:query.py


示例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')
开发者ID:BobBall,项目名称:sm,代码行数:10,代码来源:NFSSR.py


示例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")
开发者ID:falaa,项目名称:sm,代码行数:10,代码来源:LVHDoISCSISR.py


示例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')
开发者ID:letsboogey,项目名称:sm,代码行数:11,代码来源:LVHDoHBASR.py


示例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')
开发者ID:BobBall,项目名称:sm,代码行数:11,代码来源:OCFSoISCSISR.py


示例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')
开发者ID:ospalh,项目名称:kajongg-fork,代码行数:11,代码来源:login.py


示例16: run

 def run(self, sr):
     try:
         return self._run_locked(sr)
     except (util.SMException, XenAPI.Failure), e:
         util.logException(self.cmd)
         msg = str(e)
         if isinstance(e, util.CommandException):
             msg = "Command %s failed (%s): %s" % (e.cmd, e.code, e.reason)
         excType = EXCEPTION_TYPE.get(self.cmd)
         if not excType:
             excType = "SMGeneral"
         raise xs_errors.XenError(excType, opterr=msg)
开发者ID:amscanne,项目名称:xcp-storage-managers,代码行数:12,代码来源:SRCommand.py


示例17: wrapper

 def wrapper(self, *args):
     if not self.initialized:
         util.SMlog("LVMCache: will initialize now")
         self.refresh()
         #util.SMlog("%s(%s): %s" % (op, args, self.toString()))
     try:
         ret = op(self, *args)
     except KeyError:
         util.logException("LVMCache")
         util.SMlog("%s(%s): %s" % (op, args, self.toString()))
         raise
     return ret
开发者ID:BobBall,项目名称:sm,代码行数:12,代码来源:lvmcache.py


示例18: create

    def create(self, sr_uuid, size):
        try:

            # attach the device
            util.SMlog("Trying to attach iscsi disk")

            self.iscsi.attach(sr_uuid)
            if not self.iscsi.attached:
                raise xs_errors.XenError('SRNotAttached')

            util.SMlog("Attached iscsi disk at %s \n" % self.iscsi.path)

            try:

                # generate new UUIDs for VG and LVs
                old_vg_name = self._getVgName(self.dconf['device'])

                lvm_config_dict = self._getLvmInfo(old_vg_name)
                lvUuidMap = {}  # Maps old lv uuids to new uuids

                for lv_name in lvm_config_dict[old_vg_name]['logical_volumes']:
                    if lv_name == MDVOLUME_NAME:
                        continue
                    oldUuid = lv_name[4:]  # remove the VHD-
                    lvUuidMap[oldUuid] = util.gen_uuid()

                new_vg_name = VG_PREFIX + sr_uuid

                self._resignLvm(sr_uuid, old_vg_name, lvUuidMap, lvm_config_dict)

                # causes creation of nodes and activates the lvm volumes
                LVHDSR.LVHDSR.load(self, sr_uuid)

                new_vdi_info = self._resignSrMetadata(new_vg_name, self.uuid, lvUuidMap)
                self._resignVdis(new_vg_name, lvUuidMap)
                self._deleteAllSnapshots(new_vdi_info)


                # Detach LVM
                self.lvmCache.deactivateNoRefcount(MDVOLUME_NAME)
                for newUuid in lvUuidMap.values():
                    new_lv_name = self.LV_VHD_PREFIX + newUuid
                    self.lvmCache.deactivateNoRefcount(new_lv_name)

            except:
                util.logException("RESIGN_CREATE")
                raise

        finally:
            iscsilib.logout(self.iscsi.target, self.iscsi.targetIQN, all=True)

        raise xs_errors.XenError("The SR has been successfully resigned. Use the lvmoiscsi type to attach it")
开发者ID:cloudops,项目名称:ReLVHDoISCSISR,代码行数:52,代码来源:ReLVHDoISCSISR.py


示例19: attach

 def attach(self, sr_uuid, vdi_uuid):
     try:
         vdi_ref = self.sr.srcmd.params['vdi_ref']
         self.session.xenapi.VDI.remove_from_xenstore_data(vdi_ref, \
                                                           "vdi-type")
         self.session.xenapi.VDI.remove_from_xenstore_data(vdi_ref, \
                                                           "storage-type")
         self.session.xenapi.VDI.add_to_xenstore_data(vdi_ref, \
                                                      "storage-type", "nfs")
     except:
         util.logException("NFSSR:attach")
         pass
     return super(NFSFileVDI, self).attach(sr_uuid, vdi_uuid)
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:13,代码来源:NFSSR.py


示例20: attach_from_config

 def attach_from_config(self, sr_uuid, vdi_uuid):
     """
     Attach and activate a VDI using config generated by
     vdi_generate_config above. This is used for cases such as
     the HA state-file and the redo-log.
     """
     util.SMlog("FileVDI.attach_from_config")
     try:
         if not util.pathexists(self.sr.path):
             self.sr.attach(sr_uuid)
     except:
         util.logException("FileVDI.attach_from_config")
         raise xs_errors.XenError("SRUnavailable", opterr="Unable to attach from config")
开发者ID:MarkSymsCtx,项目名称:sm,代码行数:13,代码来源:FileSR.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python util.logger_assert函数代码示例发布时间:2022-05-26
下一篇:
Python util.logDebug函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap