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


Python log.exception函数代码示例

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


在下文中一共展示了exception函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: perform

    def perform(self, req):
        """General operation handler for posted operations.
        For operation 'foo' looks for a method op_foo and calls
        it with op_foo(op, req). Replies with code 500 if op_foo
        is not found.

        The method must return a list when req.use_sxp is true
        and an HTML string otherwise (or list).
        Methods may also return a ThreadRequest (for incomplete processing).

        req request
        """
        op = req.args.get('op')
        if op is None or len(op) != 1:
            req.setResponseCode(http.NOT_ACCEPTABLE, "Invalid request")
            return ''
        op = op[0]
        op_method = self.get_op_method(op)
        if op_method is None:
            req.setResponseCode(http.NOT_IMPLEMENTED, "Operation not implemented: " + op)
            req.setHeader("Content-Type", "text/plain")
            req.write("Operation not implemented: " + op)
            return ''
        else:
            try:
                return op_method(op, req)
            except Exception, exn:
                req.setResponseCode(http.INTERNAL_SERVER_ERROR, "Request failed: " + op)
                log.exception("Request %s failed.", op)
                if req.useSxp():
                    return ['xend.err', str(exn)]
                else:
                    return "<p>%s</p>" % str(exn)
开发者ID:Angel666,项目名称:android_hardware_intel,代码行数:33,代码来源:SrvBase.py

示例2: set_CPU_Affinity

    def set_CPU_Affinity(self, vcpu, cpumap):
        domid = self.xend_domain_instance.getDomid()
        dominfo = self.xend_domain_instance
        if not dominfo:
            raise XendInvalidDomain(str(domid))

        # if vcpu is keyword 'all', apply the cpumap to all vcpus
        if str(vcpu).lower() == "all":
            vcpus = range(0, int(dominfo.getVCpuCount()))
        else:
            vcpus = [int(vcpu)]

        # set the same cpumask for all vcpus
        rc = 0
        cpus = dominfo.getCpus()
        cpumap = map(int, cpumap.split(","))
        for v in vcpus:
            try:
                if dominfo._stateGet() in (DOM_STATE_RUNNING,
                                           DOM_STATE_PAUSED):
                    rc = xc.vcpu_setaffinity(domid, v, cpumap)
                cpus[v] = cpumap
            except Exception, ex:
                log.exception(ex)
                raise XendError("Cannot pin vcpu: %d to cpu: %s - %s" % \
                                (v, cpumap, str(ex)))
开发者ID:Hearen,项目名称:OnceServer,代码行数:26,代码来源:XendCPUQoS.py

示例3: restore

def restore(xd, fd, dominfo = None, paused = False, relocating = False):
    try:
        if not os.path.isdir("/var/lib/xen"):
            os.makedirs("/var/lib/xen")
    except Exception, exn:
        log.exception("Can't create directory '/var/lib/xen'")
        raise XendError("Can't create directory '/var/lib/xen'")
开发者ID:Angel666,项目名称:android_hardware_intel,代码行数:7,代码来源:XendCheckpoint.py

示例4: run

    def run(self):
        """Runs the method and stores the result for later access.

        Is invoked by threading.Thread.start().
        """

        self.thread_id = thread.get_ident()
        self.task_progress_lock.acquire()
        try:
            self.task_progress[self.thread_id] = {}
            self.progress = 0         
            self.created = now()   
        finally:
            self.task_progress_lock.release()

        try:
            result = self.func(*self.args)
            if result['Status'] == 'Success':
                self.result = result['Value']
                self.set_status(XEN_API_TASK_STATUS_TYPE[1])
            else:
                self.error_info = result['ErrorDescription']
                self.set_status(XEN_API_TASK_STATUS_TYPE[2])                
        except Exception, e:
            log.exception('Error running Async Task')
            self.error_info = ['INTERNAL ERROR', str(e)]
            self.set_status(XEN_API_TASK_STATUS_TYPE[2])
开发者ID:Hearen,项目名称:OnceServer,代码行数:27,代码来源:XendTask.py

示例5: run

    def run(self, status):
        try:
            log.info("Xend Daemon started")

            xc = xen.lowlevel.xc.xc()
            xinfo = xc.xeninfo()
            log.info("Xend changeset: %s.", xinfo['xen_changeset'])
            del xc

            try:
                from xen import VERSION
                log.info("Xend version: %s", VERSION)
            except ImportError:
                log.info("Xend version: Unknown.")

            relocate.listenRelocation()
            servers = SrvServer.create()
            servers.start(status)
            del servers
            
        except Exception, ex:
            print >>sys.stderr, 'Exception starting xend:', ex
            if XEND_DEBUG:
                traceback.print_exc()
            log.exception("Exception starting xend (%s)" % ex)
            if status:
                status.write('1')
                status.close()
            sys.exit(1)
开发者ID:mikesun,项目名称:xen-cow-checkpointing,代码行数:29,代码来源:SrvDaemon.py

示例6: destroyDeviceModel

 def destroyDeviceModel(self):
     if self.device_model is None:
         return
     if self.pid:
         self.sentinel_lock.acquire()
         try:
             try:
                 os.kill(self.pid, signal.SIGHUP)
             except OSError, exn:
                 log.exception(exn)
             try:
                 # Try to reap the child every 100ms for 10s. Then SIGKILL it.
                 for i in xrange(100):
                     (p, rv) = os.waitpid(self.pid, os.WNOHANG)
                     if p == self.pid:
                         break
                     time.sleep(0.1)
                 else:
                     log.warning("DeviceModel %d took more than 10s "
                                 "to terminate: sending SIGKILL" % self.pid)
                     os.kill(self.pid, signal.SIGKILL)
                     os.waitpid(self.pid, 0)
             except OSError, exn:
                 # This is expected if Xend has been restarted within the
                 # life of this domain.  In this case, we can kill the process,
                 # but we can't wait for it because it's not our child.
                 # We just make really sure it's going away (SIGKILL) first.
                 os.kill(self.pid, signal.SIGKILL)
             state = xstransact.Remove("/local/domain/0/device-model/%i"
                                       % self.vm.getDomid())
开发者ID:astrofimov,项目名称:vgallium,代码行数:30,代码来源:image.py

示例7: destroyXenPaging

 def destroyXenPaging(self):
     if self.actmem == "0":
         return
     if self.xenpaging_pid:
         try:
             os.kill(self.xenpaging_pid, signal.SIGHUP)
         except OSError, exn:
             log.exception(exn)
         for i in xrange(100):
             try:
                 (p, rv) = os.waitpid(self.xenpaging_pid, os.WNOHANG)
                 if p == self.xenpaging_pid:
                     break
             except OSError:
                 # This is expected if Xend has been restarted within
                 # the life of this domain.  In this case, we can kill
                 # the process, but we can't wait for it because it's
                 # not our child. We continue this loop, and after it is
                 # terminated make really sure the process is going away
                 # (SIGKILL).
                 pass
             time.sleep(0.1)
         else:
             log.warning("xenpaging %d took more than 10s "
                         "to terminate: sending SIGKILL" % self.xenpaging_pid)
             try:
                 os.kill(self.xenpaging_pid, signal.SIGKILL)
                 os.waitpid(self.xenpaging_pid, 0)
             except OSError:
                 # This happens if the process doesn't exist.
                 pass
开发者ID:changliwei,项目名称:suse_xen,代码行数:31,代码来源:image.py

示例8: prepareEnvironment

    def prepareEnvironment(self):
        """Prepare the environment for the execution of the domain. This
        method is called before any devices are set up."""

        domid = self.vm.getDomid()

        # Delete left-over pipes
        try:
            os.unlink("/var/run/tap/qemu-read-%d" % domid)
            os.unlink("/var/run/tap/qemu-write-%d" % domid)
        except:
            pass

        # No device model, don't create pipes
        if self.device_model is None:
            return

        if platform.system() != "SunOS":
            # If we use a device model, the pipes for communication between
            # blktapctrl and ioemu must be present before the devices are
            # created (blktapctrl must access them for new block devices)

            try:
                os.makedirs("/var/run/tap", 0755)
            except:
                pass

            try:
                os.mkfifo("/var/run/tap/qemu-read-%d" % domid, 0600)
                os.mkfifo("/var/run/tap/qemu-write-%d" % domid, 0600)
            except OSError, e:
                log.warn("Could not create blktap pipes for domain %d" % domid)
                log.exception(e)
                pass
开发者ID:raininja,项目名称:android_hardware_intel,代码行数:34,代码来源:image.py

示例9: save

def save(fd, dominfo, network, live, dst, checkpoint=False, node=-1):
    try:
        if not os.path.isdir("/var/lib/xen"):
            os.makedirs("/var/lib/xen")
    except Exception, exn:
        log.exception("Can't create directory '/var/lib/xen'")
        raise XendError("Can't create directory '/var/lib/xen'")
开发者ID:a2k2,项目名称:xen-unstable,代码行数:7,代码来源:XendCheckpoint.py

示例10: _loadConfig

def _loadConfig(servers, root, reload):
    if xoptions.get_xend_http_server():
        servers.add(HttpServer(root,
                               xoptions.get_xend_address(),
                               xoptions.get_xend_port()))
    if  xoptions.get_xend_unix_server():
        path = xoptions.get_xend_unix_path()
        log.info('unix path=' + path)
        servers.add(UnixHttpServer(root, path))

    api_cfg = xoptions.get_xen_api_server()
    if api_cfg:
        try:
            for server_cfg in api_cfg:
                # Parse the xen-api-server config
                
                ssl_key_file = None
                ssl_cert_file = None
                auth_method = XendAPI.AUTH_NONE
                hosts_allowed = None
                
                host_addr = server_cfg[0].split(':', 1)
                if len(host_addr) == 1:
                    if host_addr[0].lower() == 'unix':
                        use_tcp = False
                        host = 'localhost'
                        port = 0
                    else:
                        use_tcp = True
                        host = ''
                        port = int(host_addr[0])
                else:
                    use_tcp = True
                    host = str(host_addr[0])
                    port = int(host_addr[1])

                if len(server_cfg) > 1:
                    if server_cfg[1] in [XendAPI.AUTH_PAM, XendAPI.AUTH_NONE]:
                        auth_method = server_cfg[1]

                if len(server_cfg) > 2 and len(server_cfg[2]):
                    hosts_allowed = map(re.compile, server_cfg[2].split(' '))

                if len(server_cfg) > 4:
                    # SSL key and cert file
                    ssl_key_file = server_cfg[3]
                    ssl_cert_file = server_cfg[4]


                servers.add(XMLRPCServer(auth_method, True, use_tcp = use_tcp,
                                         ssl_key_file = ssl_key_file,
                                         ssl_cert_file = ssl_cert_file,
                                         host = host, port = port,
                                         path = XEN_API_SOCKET,
                                         hosts_allowed = hosts_allowed))

        except (ValueError, TypeError), exn:
            log.exception('Xen API Server init failed')
            log.error('Xen-API server configuration %s is invalid.', api_cfg)
开发者ID:a2k2,项目名称:xen-unstable,代码行数:59,代码来源:SrvServer.py

示例11: save

def save(fd, dominfo, network, live, dst, checkpoint=False, node=-1, sock=None, name=None, diskonly=False):
    from xen.xend import XendDomain

    try:
        if not os.path.isdir("/var/lib/xen"):
            os.makedirs("/var/lib/xen")
    except Exception, exn:
        log.exception("Can't create directory '/var/lib/xen'")
        raise XendError("Can't create directory '/var/lib/xen'")
开发者ID:changliwei,项目名称:suse_xen,代码行数:9,代码来源:XendCheckpoint.py

示例12: watchMain

def watchMain():
    while True:
        try:
            we = xs.read_watch()
            watch = we[1]
            res = watch.fn(we[0], *watch.args, **watch.kwargs)
            if not res:
                watch.unwatch()
        except:
            log.exception("read_watch failed")
开发者ID:andreiw,项目名称:xen3-arm-tegra,代码行数:10,代码来源:xswatch.py

示例13: unwatchAerState

 def unwatchAerState(self):
     """Remove the watch on the domain's aerState node, if any."""
     try:
         try:
             if self.aerStateWatch:
                 self.aerStateWatch.unwatch()
         finally:
             self.aerStateWatch = None
     except:
         log.exception("Unwatching aerState failed.")
开发者ID:CrazyXen,项目名称:XEN_CODE,代码行数:10,代码来源:pciif.py

示例14: unregister_shutdown_watch

    def unregister_shutdown_watch(self):
        """Remove the watch on the control/shutdown, if any. Nothrow
        guarantee."""

        try:
            if self.shutdownWatch:
                self.shutdownWatch.unwatch()
        except:
            log.exception("Unwatching hvm shutdown watch failed.")
        self.shutdownWatch = None
        log.debug("hvm shutdown watch unregistered")
开发者ID:andreiw,项目名称:xen3-arm-tegra,代码行数:11,代码来源:image.py

示例15: domain_restore_fd

    def domain_restore_fd(self, fd):
        """Restore a domain from the given file descriptor."""

        try:
            return XendCheckpoint.restore(self, fd)
        except:
            # I don't really want to log this exception here, but the error
            # handling in the relocation-socket handling code (relocate.py) is
            # poor, so we need to log this for debugging.
            log.exception("Restore failed")
            raise
开发者ID:andreiw,项目名称:xen3-arm-tegra,代码行数:11,代码来源:XendDomain.py


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