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


Python utils.log_exception函数代码示例

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


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

示例1: read

 def read(self, count):
     try:
         data = self._serial.read(count)
     except Exception, e:
         print "Serial read exception: %s" % e
         utils.log_exception()
         raise DataPathIOError("Failed to read from serial port")
开发者ID:coddingtonbear,项目名称:d-rats,代码行数:7,代码来源:comm.py

示例2: application

def application(environ, start_response):
    status = "200 OK"
    with statsd.timer("services.verify"):

        data = environ["wsgi.input"].read()
        try:
            addon_id = id_re.search(environ["PATH_INFO"]).group("addon_id")
        except AttributeError:
            output = ""
            log_info({"receipt": "%s..." % data[:10], "addon": "empty"}, "Wrong url %s" % environ["PATH_INFO"][:20])
            start_response("500 Internal Server Error", [])
            return [output]

        try:
            verify = Verify(addon_id, data, environ)
            output = verify()
            start_response(status, verify.get_headers(len(output)))
            receipt_cef.log(environ, addon_id, "verify", "Receipt verification")
        except:
            output = ""
            log_exception({"receipt": "%s..." % data[:10], "addon": addon_id})
            receipt_cef.log(environ, addon_id, "verify", "Receipt verification error")
            start_response("500 Internal Server Error", [])

    return [output]
开发者ID:darkwing,项目名称:zamboni,代码行数:25,代码来源:verify.py

示例3: quick_dirty_fallback_geocode

def quick_dirty_fallback_geocode(addr, parse=True):
    """
    Try to get SOME x,y even with bad blocks data,
    by falling back to external geocoders.
    """
    from ebdata.nlp.addresses import parse_addresses
    from ebpub.geocoder import SmartGeocoder
    if parse:
        addrs = parse_addresses(addr)
    else:
        addrs = [addr]
    for addr, unused in addrs:
        try:
            try:
                result = SmartGeocoder().geocode(addr)
                point = result['point']
                logger.debug("internally geocoded %r" % addr)
                return point.x, point.y
            except GeocodingException:
                logger.debug("internal geocoder failed on %r:\n" % addr)
                log_exception(level=logging.DEBUG)
                x,y = None, None
                # XXX Don't bother, external geocoding rarely gives us
                # anything inside Boston now that we have decent
                # blocks data.  But I want to preserve this script for
                # now till we figure out what to do with geocoding
                # more generally
                continue
        except:
            logger.error('uncaught geocoder exception on %r\n' % addr)
            log_exception()

    return None, None
开发者ID:frankk00,项目名称:openblock,代码行数:33,代码来源:geocoder_hack.py

示例4: application

def application(environ, start_response):
    status = '200 OK'
    with statsd.timer('services.verify'):

        data = environ['wsgi.input'].read()
        try:
            addon_id = id_re.search(environ['PATH_INFO']).group('addon_id')
        except AttributeError:
            output = ''
            log_info({'receipt': '%s...' % data[:10], 'addon': 'empty'},
                     'Wrong url %s' % environ['PATH_INFO'][:20])
            start_response('500 Internal Server Error', [])
            return [output]

        try:
            verify = Verify(addon_id, data, environ)
            output = verify()
            start_response(status, verify.get_headers(len(output)))
            receipt_cef.log(environ, addon_id, 'verify',
                            'Receipt verification')
        except:
            output = ''
            log_exception({'receipt': '%s...' % data[:10], 'addon': addon_id})
            receipt_cef.log(environ, addon_id, 'verify',
                            'Receipt verification error')
            start_response('500 Internal Server Error', [])

    return [output]
开发者ID:albre2252,项目名称:zamboni,代码行数:28,代码来源:verify.py

示例5: get_facebook_access_token

def get_facebook_access_token(request):
    if 'error' in request.GET:
        log_exception(
            'Error in get_facebook_access_token',
            extra={'error': request.GET.get('error'),
                   'error_reason': request.GET.get('error_reason'),
                   'error_description': request.GET.get('error_description')})
        raise FacebookError(request.GET['error'])
    if not 'code' in request.GET:
        raise BadRequestError

    code = request.GET.get('code', '')
    if not code:
        raise Exception

    params = {
        'client_id': settings.FACEBOOK_APP_ID,
        'client_secret': settings.FACEBOOK_SECRET_KEY,
        'redirect_uri': absolute_uri(request.path, request),
        'code': code,
    }
    response = urlopen('https://graph.facebook.com/oauth/access_token?'
                       + urlencode(params)).read()

    return parse_qs(response)['access_token'][-1]
开发者ID:osiloke,项目名称:FamilyFeed,代码行数:25,代码来源:fb.py

示例6: parse_blocks

    def parse_blocks(self):
        while ddt2.ENCODED_HEADER in self.inbuf and \
                ddt2.ENCODED_TRAILER in self.inbuf:
            s = self.inbuf.index(ddt2.ENCODED_HEADER)
            e = self.inbuf.index(ddt2.ENCODED_TRAILER) + \
                len(ddt2.ENCODED_TRAILER)

            if e < s:
                # Excise the extraneous end
                _tmp = self.inbuf[:e-len(ddt2.ENCODED_TRAILER)] + \
                    self.inbuf[e:]
                self.inbuf = _tmp
                continue

            block = self.inbuf[s:e]
            self.inbuf = self.inbuf[e:]

            f = ddt2.DDT2EncodedFrame()
            try:
                if f.unpack(block):
                    print "Got a block: %s" % f
                    self._handle_frame(f)
                elif self.compat:
                    self._send_text_block(block)
                else:
                    print "Found a broken block (S:%i E:%i len(buf):%i" % (\
                        s, e, len(self.inbuf))
                    utils.hexprint(block)
            except Exception, e:
                print "Failed to process block:"
                utils.log_exception()
开发者ID:coddingtonbear,项目名称:d-rats,代码行数:31,代码来源:transport.py

示例7: __init__

    def __init__(self, config):
        fn = config.ship_obj_fn("ui/mainwindow.glade")
        if not os.path.exists(fn):
            print fn
            raise Exception("Unable to load UI file")
        wtree = gtk.glade.XML(fn, "srcs_dialog", "D-RATS")

        self.__config = config
        self.__dialog = wtree.get_widget("srcs_dialog")
        self.__view = wtree.get_widget("srcs_view")
        addbtn = wtree.get_widget("srcs_add")
        editbtn = wtree.get_widget("srcs_edit")
        delbtn = wtree.get_widget("srcs_delete")

        self._setup_view()
        typesel = self._setup_typesel(wtree)

        addbtn.connect("clicked", self._add, typesel)
        editbtn.connect("clicked", self._edit)
        delbtn.connect("clicked", self._rem)

        for stype, (edclass, srcclass) in SOURCE_TYPES.items():
            for key in srcclass.enumerate(self.__config):
                try:
                    src = srcclass.open_source_by_name(self.__config, key)
                    sed = edclass(self.__config, src)
                    self.__store.append((stype,
                                         sed.get_source().get_name(),
                                         sed))
                except Exception, e:
                    utils.log_exception()
                    print "Failed to open source %s:%s" % (stype, key)
开发者ID:coddingtonbear,项目名称:d-rats,代码行数:32,代码来源:map_source_editor.py

示例8: __init__

    def __init__(self):
        utils.log("Started service")

        revision = utils.get_revision()
        utils.log("Board revision: {}".format(revision))
        if revision is not None:
            utils.set_property_setting('revision', revision)

        max_ram = utils.get_max_ram()
        utils.log("RAM size: {}MB".format(max_ram))
        utils.set_property_setting('max_ram', max_ram)

        board_type = utils.get_type()
        utils.log("Board type: {}".format(board_type))
        if board_type is not None:
            utils.set_property_setting('type', board_type)

        try:
            utils.maybe_init_settings()
        except IOError:
            utils.log_exception()

        self.monitor = MyMonitor(updated_settings_callback=self.apply_config)
        
        while (not xbmc.abortRequested):
            xbmc.sleep(1000)
开发者ID:EPiC-APOC,项目名称:repository.xvbmc,代码行数:26,代码来源:service.py

示例9: application

def application(environ, start_response):
    """
    Developing locally?

        gunicorn -b 0.0.0.0:7000 -w 12 -k sync -t 90 --max-requests 5000 \
            -n gunicorn-theme_update services.wsgi.theme_update:application

    """

    status = '200 OK'
    with statsd.timer('services.theme_update'):
        data = environ['wsgi.input'].read()
        try:
            locale, id_ = url_re.match(environ['PATH_INFO']).groups()
            locale = (locale or 'en-US').lstrip('/')
            id_ = int(id_)
        except AttributeError:  # URL path incorrect.
            start_response('404 Not Found', [])
            return ['']

        try:
            update = ThemeUpdate(locale, id_, environ.get('QUERY_STRING'))
            output = update.get_json()
            if not output:
                start_response('404 Not Found', [])
                return ['']
            start_response(status, update.get_headers(len(output)))
        except:
            log_exception(data)
            raise

    return [output]
开发者ID:abdellah-bn,项目名称:olympia,代码行数:32,代码来源:theme_update.py

示例10: get_folderandprefix

 def get_folderandprefix(self):
     '''get the current folder and prefix'''
     cur_folder = ""
     cont_prefix = ""
     try:
         widget_container = self.win.getProperty("SkinHelper.WidgetContainer").decode('utf-8')
         if xbmc.getCondVisibility("Window.IsActive(movieinformation)"):
             cont_prefix = ""
             cur_folder = xbmc.getInfoLabel(
                 "movieinfo-$INFO[Container.FolderPath]"
                 "$INFO[Container.NumItems]"
                 "$INFO[Container.Content]").decode('utf-8')
         elif widget_container:
             cont_prefix = "Container(%s)." % widget_container
             cur_folder = xbmc.getInfoLabel(
                 "widget-%s-$INFO[Container(%s).NumItems]-$INFO[Container(%s).ListItemAbsolute(1).Label]" %
                 (widget_container, widget_container, widget_container)).decode('utf-8')
         else:
             cont_prefix = ""
             cur_folder = xbmc.getInfoLabel(
                 "$INFO[Container.FolderPath]$INFO[Container.NumItems]$INFO[Container.Content]").decode(
                 'utf-8')
     except Exception as exc:
         log_exception(__name__, exc)
         cur_folder = ""
         cont_prefix = ""
     return (cur_folder, cont_prefix)
开发者ID:marcelveldt,项目名称:script.skin.helper.service,代码行数:27,代码来源:listitem_monitor.py

示例11: write

 def write(self, buf):
     try:
         self._serial.write(buf)
     except Exception ,e:
         print "Serial write exception: %s" % e
         utils.log_exception()
         raise DataPathIOError("Failed to write to serial port")
开发者ID:coddingtonbear,项目名称:d-rats,代码行数:7,代码来源:comm.py

示例12: application

def application(environ, start_response):
    """
    Developing locally?

        gunicorn -b 0.0.0.0:7000 -w 12 -k sync -t 90 --max-requests 5000 \
            -n gunicorn-theme_update services.wsgi.theme_update:application

    """

    status = "200 OK"
    with statsd.timer("services.theme_update"):
        data = environ["wsgi.input"].read()
        try:
            locale, id_ = url_re.match(environ["PATH_INFO"]).groups()
            locale = (locale or "en-US").lstrip("/")
            id_ = int(id_)
        except AttributeError:  # URL path incorrect.
            start_response("404 Not Found", [])
            return [""]

        try:
            update = ThemeUpdate(locale, id_, environ.get("QUERY_STRING"))
            output = update.get_json()
            if not output:
                start_response("404 Not Found", [])
                return [""]
            start_response(status, update.get_headers(len(output)))
        except:
            log_exception(environ["PATH_INFO"])
            raise

    return [output]
开发者ID:peterkinalex,项目名称:olympia,代码行数:32,代码来源:theme_update.py

示例13: explore

 def explore(self, user):
     if not self.can_explore(user):
         raise utils.MyException("Cannot explore")
     try:
         ev = utils.random_chance(self.events, lambda ev: ev.get_chance(user))
         user.event_happened(ev)
     except:
         utils.log_exception()
开发者ID:alexbft,项目名称:Karty-RPG,代码行数:8,代码来源:zone.py

示例14: run

 def run(self):
     '''called to start our webservice'''
     log_msg("WebService - start helper webservice on port %s" % PORT, xbmc.LOGNOTICE)
     try:
         server = StoppableHttpServer(('127.0.0.1', PORT), StoppableHttpRequestHandler)
         server.artutils = self.artutils
         server.serve_forever()
     except Exception as exc:
         log_exception(__name__, exc)
开发者ID:marcelveldt,项目名称:script.skin.helper.service,代码行数:9,代码来源:webservice.py

示例15: do_update

 def do_update(self):
     print "[River %s] Doing update..." % self.__site
     if  not self.__have_site:
         try:
             self.__parse_site()
             self.__have_site = True
         except Exception, e:
             utils.log_exception()
             print "[River %s] Failed to parse site: %s" % (self.__site, e)
             self.set_name("Invalid river %s" % self.__site)
开发者ID:coddingtonbear,项目名称:d-rats,代码行数:10,代码来源:map_sources.py


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