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


Python Monitor.track方法代码示例

本文整理汇总了Python中monitor.Monitor.track方法的典型用法代码示例。如果您正苦于以下问题:Python Monitor.track方法的具体用法?Python Monitor.track怎么用?Python Monitor.track使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在monitor.Monitor的用法示例。


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

示例1: FrontController

# 需要导入模块: from monitor import Monitor [as 别名]
# 或者: from monitor.Monitor import track [as 别名]
class FrontController(object):
    """
    Error catching midleware. Intended to provide debug output - traceback.
    If the exception is throwed with exc_info tuple as an additional argument
    it is root cause and that is showed too.
    """
    
    def __init__(self, controllers, **kw):

        self._debug = kw.get('debug', False)
        
        self._init_exc_info = None
        self._worker = None
        # TODO: following is shit...
        #try:
        if kw.has_key('loggers'):
            for name, data in kw.get('loggers').items():                   
                file = data.get('file')
                fname = file.get('name')
                size = file.get('size')
                count = file.get('count')
                set_logger(name, fname, max_bytes = size, backup_count = count)
        
        if kw.has_key('exc_wrapper'):
            exc_wrapper = kw.get('exc_wrapper')
            log_setup = ExcInfoWrapper._logging
            log_setup['init'] = exc_wrapper.get('init', log_setup['init'])
            log_setup['call'] = exc_wrapper.get('call', log_setup['call'])


        if kw.has_key('monitor'):
            monitor = kw.get('monitor')
            force_restart = monitor.get('force_restart', True)
            self._monitor = Monitor(force_restart=force_restart)
            for i in monitor.get('track_files', []):
                self._monitor.track(i)
            self._monitor.start()
        
        
        #except:
        #    self._init_exc_info = ExcInfoWrapper()

        if FrontControllerWorker is None:
            self._init_exc_info = init_exc_info
        else:
            try:
                self._worker = FrontControllerWorker(**controllers)
            except:
                self._init_exc_info = ExcInfoWrapper()
    
    def __call__(self, environ, start_resp):
        try:
            try:

                if self._worker is not None:
                    return self._worker(environ, start_resp)
                else:
                    raise NotInitializedProperly('Front controller worker is missing.', exc_info = self._init_exc_info)

            except HTTPOk:
                raise HTTPInternalServerError('HTTPOk raised but not properly processed.', exc_info = True)

            except HTTPRedirection:
                exc_info = ExcInfoWrapper()
                return exc_info(environ, start_resp, self._debug)

            except HTTPError:
                exc_info = ExcInfoWrapper()
                return exc_info(environ, start_resp, self._debug)
            
            except Exception:
                raise HTTPInternalServerError('Exceptional state detected.', exc_info = True)
            

        except HTTPError:
            exc_info = ExcInfoWrapper()
            return exc_info(environ, start_resp, self._debug)
开发者ID:pborky,项目名称:pywef,代码行数:79,代码来源:controller.py


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