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


Python log.set_threshold方法代码示例

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


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

示例1: setUp

# 需要导入模块: from distutils import log [as 别名]
# 或者: from distutils.log import set_threshold [as 别名]
def setUp(self):
        """Patches the environment."""
        super(PyPIRCCommandTestCase, self).setUp()
        self.tmp_dir = self.mkdtemp()
        os.environ['HOME'] = self.tmp_dir
        self.rc = os.path.join(self.tmp_dir, '.pypirc')
        self.dist = Distribution()

        class command(PyPIRCCommand):
            def __init__(self, dist):
                PyPIRCCommand.__init__(self, dist)
            def initialize_options(self):
                pass
            finalize_options = initialize_options

        self._cmd = command
        self.old_threshold = set_threshold(WARN) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:19,代码来源:test_config.py

示例2: test_non_ascii

# 需要导入模块: from distutils import log [as 别名]
# 或者: from distutils.log import set_threshold [as 别名]
def test_non_ascii(self):
        # Issue #8663: test that non-ASCII text is escaped with
        # backslashreplace error handler (stream use ASCII encoding and strict
        # error handler)
        old_stdout = sys.stdout
        old_stderr = sys.stderr
        old_threshold = log.set_threshold(log.DEBUG)
        try:
            with NamedTemporaryFile(mode="w+", encoding='ascii') as stdout, \
                 NamedTemporaryFile(mode="w+", encoding='ascii') as stderr:
                sys.stdout = stdout
                sys.stderr = stderr
                log.debug("debug:\xe9")
                log.fatal("fatal:\xe9")
                stdout.seek(0)
                self.assertEqual(stdout.read().rstrip(), "debug:\\xe9")
                stderr.seek(0)
                self.assertEqual(stderr.read().rstrip(), "fatal:\\xe9")
        finally:
            log.set_threshold(old_threshold)
            sys.stdout = old_stdout
            sys.stderr = old_stderr 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:24,代码来源:test_log.py

示例3: setUp

# 需要导入模块: from distutils import log [as 别名]
# 或者: from distutils.log import set_threshold [as 别名]
def setUp(self):
        """Patches the environment."""
        super(BasePyPIRCCommandTestCase, self).setUp()
        self.tmp_dir = self.mkdtemp()
        os.environ['HOME'] = self.tmp_dir
        self.rc = os.path.join(self.tmp_dir, '.pypirc')
        self.dist = Distribution()

        class command(PyPIRCCommand):
            def __init__(self, dist):
                PyPIRCCommand.__init__(self, dist)
            def initialize_options(self):
                pass
            finalize_options = initialize_options

        self._cmd = command
        self.old_threshold = set_threshold(WARN) 
开发者ID:CedricGuillemet,项目名称:Imogen,代码行数:19,代码来源:test_config.py

示例4: setUp

# 需要导入模块: from distutils import log [as 别名]
# 或者: from distutils.log import set_threshold [as 别名]
def setUp(self):
        """Patches the environment."""
        super(BasePyPIRCCommandTestCase, self).setUp()
        self.tmp_dir = self.mkdtemp()
        os.environ['HOME'] = self.tmp_dir
        os.environ['USERPROFILE'] = self.tmp_dir
        self.rc = os.path.join(self.tmp_dir, '.pypirc')
        self.dist = Distribution()

        class command(PyPIRCCommand):
            def __init__(self, dist):
                PyPIRCCommand.__init__(self, dist)
            def initialize_options(self):
                pass
            finalize_options = initialize_options

        self._cmd = command
        self.old_threshold = set_threshold(WARN) 
开发者ID:pypa,项目名称:setuptools,代码行数:20,代码来源:test_config.py

示例5: show_all

# 需要导入模块: from distutils import log [as 别名]
# 或者: from distutils.log import set_threshold [as 别名]
def show_all(argv=None):
    import inspect
    if argv is None:
        argv = sys.argv
    opts, args = parseCmdLine(argv)
    if opts.verbose:
        log.set_threshold(log.DEBUG)
    else:
        log.set_threshold(log.INFO)
    show_only = []
    for n in args:
        if n[-5:] != '_info':
            n = n + '_info'
        show_only.append(n)
    show_all = not show_only
    _gdict_ = globals().copy()
    for name, c in _gdict_.items():
        if not inspect.isclass(c):
            continue
        if not issubclass(c, system_info) or c is system_info:
            continue
        if not show_all:
            if name not in show_only:
                continue
            del show_only[show_only.index(name)]
        conf = c()
        conf.verbosity = 2
        # FIXME: r not used
        r = conf.get_info()
    if show_only:
        log.info('Info classes not defined: %s', ','.join(show_only)) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:33,代码来源:system_info.py

示例6: show_all

# 需要导入模块: from distutils import log [as 别名]
# 或者: from distutils.log import set_threshold [as 别名]
def show_all(argv=None):
    import inspect
    if argv is None:
        argv = sys.argv
    opts, args = parseCmdLine(argv)
    if opts.verbose:
        log.set_threshold(log.DEBUG)
    else:
        log.set_threshold(log.INFO)
    show_only = []
    for n in args:
        if n[-5:] != '_info':
            n = n + '_info'
        show_only.append(n)
    show_all = not show_only
    _gdict_ = globals().copy()
    for name, c in _gdict_.items():
        if not inspect.isclass(c):
            continue
        if not issubclass(c, system_info) or c is system_info:
            continue
        if not show_all:
            if name not in show_only:
                continue
            del show_only[show_only.index(name)]
        conf = c()
        conf.verbosity = 2
        r = conf.get_info()
    if show_only:
        log.info('Info classes not defined: %s', ','.join(show_only)) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:32,代码来源:system_info.py

示例7: setUp

# 需要导入模块: from distutils import log [as 别名]
# 或者: from distutils.log import set_threshold [as 别名]
def setUp(self):
        super(CoreTestCase, self).setUp()
        self.old_stdout = sys.stdout
        self.cleanup_testfn()
        self.old_argv = sys.argv, sys.argv[:]
        self.addCleanup(log.set_threshold, log._global_log.threshold) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:8,代码来源:test_core.py

示例8: tearDown

# 需要导入模块: from distutils import log [as 别名]
# 或者: from distutils.log import set_threshold [as 别名]
def tearDown(self):
        """Removes the patch."""
        set_threshold(self.old_threshold)
        super(PyPIRCCommandTestCase, self).tearDown() 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:6,代码来源:test_config.py

示例9: setUp

# 需要导入模块: from distutils import log [as 别名]
# 或者: from distutils.log import set_threshold [as 别名]
def setUp(self):
        super(LoggingSilencer, self).setUp()
        self.threshold = log.set_threshold(log.FATAL)
        # catching warnings
        # when log will be replaced by logging
        # we won't need such monkey-patch anymore
        self._old_log = log.Log._log
        log.Log._log = self._log
        self.logs = [] 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:11,代码来源:support.py

示例10: tearDown

# 需要导入模块: from distutils import log [as 别名]
# 或者: from distutils.log import set_threshold [as 别名]
def tearDown(self):
        log.set_threshold(self.threshold)
        log.Log._log = self._old_log
        super(LoggingSilencer, self).tearDown() 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:6,代码来源:support.py


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