Python distutils.log.set_threshold() Examples
The following are 30
code examples of distutils.log.set_threshold().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
distutils.log
, or try the search function
.
Example #1
Source File: test_config.py From datafari with Apache License 2.0 | 6 votes |
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)
Example #2
Source File: test_config.py From Fluid-Designer with GNU General Public License v3.0 | 6 votes |
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)
Example #3
Source File: test_config.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 6 votes |
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)
Example #4
Source File: test_log.py From Fluid-Designer with GNU General Public License v3.0 | 6 votes |
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
Example #5
Source File: test_log.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 6 votes |
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
Example #6
Source File: test_config.py From Imogen with MIT License | 6 votes |
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)
Example #7
Source File: test_config.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 6 votes |
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)
Example #8
Source File: test_config.py From oss-ftp with MIT License | 6 votes |
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)
Example #9
Source File: test_config.py From setuptools with MIT License | 6 votes |
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)
Example #10
Source File: test_config.py From Computable with MIT License | 6 votes |
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)
Example #11
Source File: test_config.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 6 votes |
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)
Example #12
Source File: test_config.py From ironpython3 with Apache License 2.0 | 6 votes |
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)
Example #13
Source File: test_log.py From ironpython3 with Apache License 2.0 | 6 votes |
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
Example #14
Source File: test_config.py From android_universal with MIT License | 6 votes |
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)
Example #15
Source File: test_config.py From ironpython2 with Apache License 2.0 | 6 votes |
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)
Example #16
Source File: support.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def tearDown(self): log.set_threshold(self.threshold) log.Log._log = self._old_log super(LoggingSilencer, self).tearDown()
Example #17
Source File: system_info.py From coffeegrindsize with MIT License | 5 votes |
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))
Example #18
Source File: support.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
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 = []
Example #19
Source File: system_info.py From Splunking-Crime with GNU Affero General Public License v3.0 | 5 votes |
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))
Example #20
Source File: support.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def setUp(self): super().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 = []
Example #21
Source File: test_manifest.py From setuptools with MIT License | 5 votes |
def teardown_method(self, method): log.set_threshold(self.threshold) log.Log._log = self._old_log super(TestFileListTest, self).teardown_method(method)
Example #22
Source File: test_manifest.py From setuptools with MIT License | 5 votes |
def setup_method(self, method): super(TestFileListTest, self).setup_method(method) self.threshold = log.set_threshold(log.FATAL) self._old_log = log.Log._log log.Log._log = self._log self.logs = []
Example #23
Source File: test_log.py From setuptools with MIT License | 5 votes |
def test_non_ascii(self): # Issues #8663, #34421: test that non-encodable text is escaped with # backslashreplace error handler and encodable non-ASCII text is # output as is. for errors in ('strict', 'backslashreplace', 'surrogateescape', 'replace', 'ignore'): with self.subTest(errors=errors): stdout = io.TextIOWrapper(io.BytesIO(), encoding='cp437', errors=errors) stderr = io.TextIOWrapper(io.BytesIO(), encoding='cp437', errors=errors) old_threshold = log.set_threshold(log.DEBUG) try: with swap_attr(sys, 'stdout', stdout), \ swap_attr(sys, 'stderr', stderr): log.debug('Dεbug\tMėssãge') log.fatal('Fαtal\tÈrrōr') finally: log.set_threshold(old_threshold) stdout.seek(0) self.assertEqual(stdout.read().rstrip(), 'Dεbug\tM?ss?ge' if errors == 'replace' else 'Dεbug\tMssge' if errors == 'ignore' else 'Dεbug\tM\\u0117ss\\xe3ge') stderr.seek(0) self.assertEqual(stderr.read().rstrip(), 'Fαtal\t?rr?r' if errors == 'replace' else 'Fαtal\trrr' if errors == 'ignore' else 'Fαtal\t\\xc8rr\\u014dr')
Example #24
Source File: test_config.py From datafari with Apache License 2.0 | 5 votes |
def tearDown(self): """Removes the patch.""" set_threshold(self.old_threshold) super(PyPIRCCommandTestCase, self).tearDown()
Example #25
Source File: support.py From setuptools with MIT License | 5 votes |
def tearDown(self): log.set_threshold(self.threshold) log.Log._log = self._old_log super().tearDown()
Example #26
Source File: support.py From datafari with Apache License 2.0 | 5 votes |
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 = []
Example #27
Source File: support.py From datafari with Apache License 2.0 | 5 votes |
def tearDown(self): log.set_threshold(self.threshold) log.Log._log = self._old_log super(LoggingSilencer, self).tearDown()
Example #28
Source File: support.py From setuptools with MIT License | 5 votes |
def setUp(self): super().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 = []
Example #29
Source File: test_config.py From setuptools with MIT License | 5 votes |
def tearDown(self): """Removes the patch.""" set_threshold(self.old_threshold) super(BasePyPIRCCommandTestCase, self).tearDown()
Example #30
Source File: test_core.py From setuptools with MIT License | 5 votes |
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)