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


Python Collector.stop方法代码示例

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


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

示例1: PeriodicLog

# 需要导入模块: from collector import Collector [as 别名]
# 或者: from collector.Collector import stop [as 别名]
class PeriodicLog(Log):
    __module__ = __name__

    def __init__(self):
        self._r_env = _create_shared_env()
        Log.__init__(self)
        self.collector = None
        self.trigger = None

    def get_environment(self):
        return self._r_env

    def configure(self, config):
        if config.has_key("trigger"):
            self.trigger = config["trigger"]
        set_attribute(self, "period", REQUIRED, config, int)
        Log.configure(self, config)

    def configuration(self):
        config = Log.configuration(self)
        get_attribute(self, "period", config, str)
        if self.trigger:
            get_attribute(self, "trigger", config, str)
        return config

    def _add_child(self, node):
        Log._add_child(self, node)

    def _column_names(self):
        name_list = []
        for child in self.collector.columns:
            name_list.append(child.name)

        return name_list

    def get_range(self, column_name, start, end, extended=0):
        if self.debug:
            msg = "Package: /mpx/services/logger\n"
            msg = msg + "Class: PeriodicLog\n"
            msg = msg + "Method: get_range\n"
            msg = ((msg + "column_name= ") + str(column_name)) + "\n"
            msg = ((msg + "start= ") + str(start)) + "\n"
            msg = ((msg + "end= ") + str(end)) + "\n"
            mpx.lib.msglog.log("broadway", mpx.lib.msglog.types.DB, msg)
        return self.log.get_range(column_name, start, end, extended)

    def get_slice_on_interval(self, column, start, end, interval, extended=0):
        stream = self.log.get_slice(column, start, end, extended)
        return _IntervalStreamFilter(interval, stream)

    def get_slice(self, column, start, stop, extended=0):
        return self.log.get_slice(column, start, stop, extended)

    def get_last_record(self):
        return self.log.get_last_record()

    def get_first_record(self):
        return self.log.get_first_record()

    def get_last_logged_value(self, column_name):
        last_record = self.log.get_last_record()
        if last_record:
            if last_record.has_key(column_name):
                rtValue = last_record[column_name]
            else:
                rtValue = None
        else:
            rtvalue = None
        return rtValue

    def get_first_logged_value(self, column):
        first_record = self.log.get_first_record()
        if first_record:
            return first_record[column]
        return None

    def get_columns(self):
        return self.log.get_columns()

    def get_column_names(self):
        return self._column_names()

    def describe_columns(self):
        return self.log.describe_columns()

    def get_column_name(self, column_index):
        return self.log.get_column_name(column_index)

    def trim_ge(self, column_name, value):
        if self.debug:
            msg = (("calling trim_ge on LOG: COLUMN: " + str(column_name)) + " VALUE: ") + str(value)
            mpx.lib.msglog.log("broadway", mpx.lib.msglog.types.DB, msg)
        self.log.trim_ge(column_name, value)

    def trim_gt(self, column_name, value):
        if self.debug:
            msg = (("calling trim_gt on LOG: COLUMN: " + str(column_name)) + " VALUE: ") + str(value)
            mpx.lib.msglog.log("broadway", mpx.lib.msglog.types.DB, msg)
        self.log.trim_gt(column_name, value)

#.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:103,代码来源:

示例2: coverage

# 需要导入模块: from collector import Collector [as 别名]
# 或者: from collector.Collector import stop [as 别名]
class coverage:
    """Programmatic access to Coverage.

    To use::
    
        from coverage import coverage
        
        cov = coverage()
        cov.start()
        #.. blah blah (run your code) blah blah
        cov.stop()
        cov.html_report(directory='covhtml')

    """
    def __init__(self, data_file=None, data_suffix=False, cover_pylib=False,
                auto_data=False):
        """Create a new coverage measurement context.
        
        `data_file` is the base name of the data file to use, defaulting to
        ".coverage".  `data_suffix` is appended to `data_file` to create the
        final file name.  If `data_suffix` is simply True, then a suffix is
        created with the machine and process identity included.
        
        `cover_pylib` is a boolean determining whether Python code installed
        with the Python interpreter is measured.  This includes the Python
        standard library and any packages installed with the interpreter.
        
        If `auto_data` is true, then any existing data file will be read when
        coverage measurement starts, and data will be saved automatically when
        measurement stops.
        
        """
        self.cover_pylib = cover_pylib
        self.auto_data = auto_data
        
        self.exclude_re = ""
        self.exclude_list = []
        
        self.file_locator = FileLocator()
        
        self.collector = Collector(self._should_trace)

        # Create the data file.
        if data_suffix:
            if not isinstance(data_suffix, basestring):
                # if data_suffix=True, use .machinename.pid
                data_suffix = ".%s.%s" % (socket.gethostname(), os.getpid())
        else:
            data_suffix = None

        self.data = CoverageData(
            basename=data_file, suffix=data_suffix,
            collector="coverage v%s" % __version__
            )

        # The default exclude pattern.
        self.exclude('# *pragma[: ]*[nN][oO] *[cC][oO][vV][eE][rR]')

        # The prefix for files considered "installed with the interpreter".
        if not self.cover_pylib:
            os_file = self.file_locator.canonical_filename(os.__file__)
            self.pylib_prefix = os.path.split(os_file)[0]

        here = self.file_locator.canonical_filename(__file__)
        self.cover_prefix = os.path.split(here)[0]

    def _should_trace(self, filename, frame):
        """Decide whether to trace execution in `filename`
        
        Returns a canonicalized filename if it should be traced, False if it
        should not.
        
        """
        if filename == '<string>':
            # There's no point in ever tracing string executions, we can't do
            # anything with the data later anyway.
            return False

        # Compiled Python files have two filenames: frame.f_code.co_filename is
        # the filename at the time the .pyc was compiled.  The second name
        # is __file__, which is where the .pyc was actually loaded from.  Since
        # .pyc files can be moved after compilation (for example, by being
        # installed), we look for __file__ in the frame and prefer it to the
        # co_filename value.
        dunder_file = frame.f_globals.get('__file__')
        if dunder_file:
            if not dunder_file.endswith(".py"):
                if dunder_file[-4:-1] == ".py":
                    dunder_file = dunder_file[:-1]
            filename = dunder_file

        canonical = self.file_locator.canonical_filename(filename)

        # If we aren't supposed to trace installed code, then check if this is
        # near the Python standard library and skip it if so.
        if not self.cover_pylib:
            if canonical.startswith(self.pylib_prefix):
                return False

        # We exclude the coverage code itself, since a little of it will be
#.........这里部分代码省略.........
开发者ID:luipir,项目名称:qgis-remote-debug,代码行数:103,代码来源:control.py


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