• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python termstyle.red函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_path_stripping_in_test_failure_last_line

    def test_path_stripping_in_test_failure_last_line(self):
        f = io.StringIO()
        r = TerminalReporter(watch_path='/path/to/watch',
                             build_path='/path/to/build',
                             terminal=Terminal(stream=f))

        failures = [[
                        'core.ok',
                        [
                            '/path/to/watch/test/test_core.cc:12: Failure',
                            'Value of: 2',
                            'Expected: ok()',
                            'Which is: 42',
                        ], [], FAILED
                    ]]
        r.report_failures(failures)
        expected = [
            '================================== FAILURES ==================================', # noqa
            termstyle.bold(termstyle.red(
            '__________________________________ core.ok ___________________________________' # noqa
            )),
            '/path/to/watch/test/test_core.cc:12: Failure',
            'Value of: 2',
            'Expected: ok()',
            'Which is: 42',
            termstyle.bold(termstyle.red(
            '____________________________ test/test_core.cc:12 ____________________________', # noqa
            )),
            ]
        actual = f.getvalue().splitlines()
        assert actual == expected
开发者ID:yerejm,项目名称:ttt,代码行数:31,代码来源:test_reporter.py


示例2: test_report_multiple_failed

    def test_report_multiple_failed(self):
        f = io.StringIO()
        r = TerminalReporter(watch_path='/path',
                             build_path=None,
                             terminal=Terminal(stream=f))

        results = {
                'total_runtime': 2.09,
                'total_passed': 0,
                'total_failed': 2,
                'failures': [
                    [
                        'fail1',
                        [
                             '/path/to/file:12: blah',
                             'results line 2',
                             'results line 3',
                             'results line 4',
                        ], [], FAILED
                    ],
                    [
                        'fail2',
                        [
                             '/path/to/file:102: blah',
                             'results line 2',
                             'results line 3',
                             'results line 4',
                        ], [], FAILED
                    ],
                ]
            }
        r.report_results(results)
        expected = [
            '================================== FAILURES ==================================', # noqa
            termstyle.bold(termstyle.red(
            '___________________________________ fail1 ____________________________________' # noqa
            )),
            '/path/to/file:12: blah',
            'results line 2',
            'results line 3',
            'results line 4',
            termstyle.bold(termstyle.red(
            '_________________________________ to/file:12 _________________________________' # noqa
            )),
            termstyle.bold(termstyle.red(
            '___________________________________ fail2 ____________________________________' # noqa
            )),
            '/path/to/file:102: blah',
            'results line 2',
            'results line 3',
            'results line 4',
            termstyle.bold(termstyle.red(
            '________________________________ to/file:102 _________________________________' # noqa
            )),
            termstyle.bold(termstyle.red(
            '===================== 2 failed, 0 passed in 2.09 seconds =====================' # noqa
            )),
            ]
        actual = f.getvalue().splitlines()
        assert actual == expected
开发者ID:yerejm,项目名称:ttt,代码行数:60,代码来源:test_reporter.py


示例3: dump_info

def dump_info(fname):
    info = red('unknwon error')
    if not os.path.getsize(fname):
        info = red('empty file')
    else:
        try:
            handle = open(fname, 'rt')
        except OSError as exc:
            info = red('unable to open file: {!s}'.format(exc))
        else:
            try:
                content = json.load(handle)
            except ValueError as exc:
                info = red('unable to load JSON: {!s}'.format(exc))
            else:
                try:
                    info = "{!s} dumps".format(len(content.keys()))
                except AttributeError as exc:
                    info = red("unable to count dumps: {!s}".format(exc))
        finally:
            try:
                handle.close()
            except NameError:
                pass
    return info
开发者ID:Dognaedis,项目名称:intelmq,代码行数:25,代码来源:intelmqdump.py


示例4: do_start_and_return

 def do_start_and_return (self, line):
     """Start TRex run and once in 'Running' mode, return to cmd prompt"""
     print termstyle.green("*** Starting TRex run, wait until in 'Running' state ***")
     try:
         ret = self.trex.start_trex(**self.run_params)
         print termstyle.green("*** End of scenario (TRex is probably still running!) ***")
     except TRexException as inst:
         print termstyle.red(inst)
开发者ID:Pojen-Huang,项目名称:trex-core,代码行数:8,代码来源:client_interactive_example.py


示例5: do_stop_trex

 def do_stop_trex (self, line):
     """Try to stop TRex run (if TRex is currently running)"""
     print termstyle.green("*** Starting TRex termination ***")
     try:
         ret = self.trex.stop_trex()
         print termstyle.green("*** End of scenario (TRex is not running now) ***")
     except TRexException as inst:
         print termstyle.red(inst)
开发者ID:Pojen-Huang,项目名称:trex-core,代码行数:8,代码来源:client_interactive_example.py


示例6: do_kill_indiscriminately

 def do_kill_indiscriminately (self, line):
     """Force killing of running TRex process (if exists) on the server."""
     print termstyle.green("*** Starting TRex termination ***")
     ret = self.trex.force_kill()
     if ret:
         print termstyle.green("*** End of scenario (TRex is not running now) ***")
     elif ret is None:
         print termstyle.magenta("*** End of scenario (TRex termination aborted) ***")
     else:
         print termstyle.red("*** End of scenario (TRex termination failed) ***")
开发者ID:Pojen-Huang,项目名称:trex-core,代码行数:10,代码来源:client_interactive_example.py


示例7: do_reserve_trex

 def do_reserve_trex (self, user):
     """Reserves the usage of TRex to a certain user"""
     try:
         if not user:
             ret = self.trex.reserve_trex()
         else:
             ret = self.trex.reserve_trex(user.split(' ')[0])
         print termstyle.green("*** TRex reserved successfully ***")
     except TRexException as inst:
         print termstyle.red(inst)
开发者ID:Pojen-Huang,项目名称:trex-core,代码行数:10,代码来源:client_interactive_example.py


示例8: do_cancel_reservation

 def do_cancel_reservation (self, user):
     """Cancels a current reservation of TRex to a certain user"""
     try:
         if not user:
             ret = self.trex.cancel_reservation()
         else:
             ret = self.trex.cancel_reservation(user.split(' ')[0])
         print termstyle.green("*** TRex reservation canceled successfully ***")
     except TRexException as inst:
         print termstyle.red(inst)
开发者ID:Pojen-Huang,项目名称:trex-core,代码行数:10,代码来源:client_interactive_example.py


示例9: do_poll_once

 def do_poll_once (self, line):
     """Performs a single poll of TRex current data dump (if TRex is running) and prompts and short version of latest result_obj"""
     print termstyle.green("*** Trying TRex single poll ***")
     try:
         last_res = dict()
         if self.trex.is_running(dump_out = last_res):
             obj = self.trex.get_result_obj()
             print obj
         else:
             print termstyle.magenta("TRex isn't currently running.")
         print termstyle.green("*** End of scenario (TRex is posssibly still running!) ***")
     except TRexException as inst:
         print termstyle.red(inst)
开发者ID:Pojen-Huang,项目名称:trex-core,代码行数:13,代码来源:client_interactive_example.py


示例10: do_run_until_finish

    def do_run_until_finish (self, sample_rate):
        """Starts TRex and sample server until run is done."""
        print termstyle.green("*** Starting TRex run_until_finish scenario ***")

        if not sample_rate: # use default sample rate if not passed
            sample_rate = 5
        try:
            sample_rate = int(sample_rate)
            ret = self.trex.start_trex(**self.run_params)
            self.trex.sample_to_run_finish(sample_rate)
            print termstyle.green("*** End of TRex run ***")
        except ValueError as inst:
            print termstyle.magenta("Provided illegal sample rate value. Please try again.\n[", inst,"]")
        except TRexException as inst:
            print termstyle.red(inst)
开发者ID:Pojen-Huang,项目名称:trex-core,代码行数:15,代码来源:client_interactive_example.py


示例11: _summarize

	def _summarize(self):
		"""summarize all tests - the number of failures, errors and successes"""
		self._line(termstyle.black)
		self._out("%s test%s run in %0.1f seconds" % (
			self.total,
			self._plural(self.total),
			time.time() - self.start_time))
		if self.total > self.success:
			self._outln(". ")
			additionals = []
			if self.failure > 0:
				additionals.append(termstyle.red("%s FAILED" % (
					self.failure,)))
			if self.error > 0:
				additionals.append(termstyle.yellow("%s error%s" % (
					self.error,
					self._plural(self.error) )))
			if self.skip > 0:
				additionals.append(termstyle.blue("%s skipped" % (
					self.skip)))
			self._out(', '.join(additionals))

		self._out(termstyle.green(" (%s test%s passed)" % (
			self.success,
			self._plural(self.success) )))
		self._outln()
开发者ID:gdyuldin,项目名称:rednose,代码行数:26,代码来源:rednose.py


示例12: test_report_with_stdout_and_stderr_in_additional_output

    def test_report_with_stdout_and_stderr_in_additional_output(self):
        f = io.StringIO()
        r = TerminalReporter(watch_path='/path',
                             build_path=None,
                             terminal=Terminal(stream=f))

        results = {
                'total_runtime': 2.09,
                'total_passed': 0,
                'total_failed': 1,
                'failures': [
                    [
                        'fail1',
                        [
                            'extra line 1',
                            'extra line 2',
                            '/path/to/file:12: blah',
                            'results line 1',
                            'results line 2',
                            'results line 3',
                        ], [], FAILED
                    ],
                ]
            }
        r.report_results(results)
        expected = [
            '================================== FAILURES ==================================', # noqa
            termstyle.bold(termstyle.red(
            '___________________________________ fail1 ____________________________________' # noqa
            )),
            '/path/to/file:12: blah',
            'results line 1',
            'results line 2',
            'results line 3',
            '----------------------------- Additional output ------------------------------', # noqa
            'extra line 1',
            'extra line 2',
            termstyle.bold(termstyle.red(
            '_________________________________ to/file:12 _________________________________' # noqa
            )),
            termstyle.bold(termstyle.red(
            '===================== 1 failed, 0 passed in 2.09 seconds =====================' # noqa
            )),
            ]
        actual = f.getvalue().splitlines()
        assert actual == expected
开发者ID:yerejm,项目名称:ttt,代码行数:46,代码来源:test_reporter.py


示例13: test_writeln_decorator

    def test_writeln_decorator(self):
        f = io.StringIO()
        t = Terminal(stream=f)
        t.writeln('hello', decorator=[bold])
        assert f.getvalue() == bold('hello') + linesep

        f = io.StringIO()
        t = Terminal(stream=f)
        t.writeln('hello', decorator=[bold, red])
        assert f.getvalue() == red(bold('hello')) + linesep
开发者ID:yerejm,项目名称:ttt,代码行数:10,代码来源:test_terminal.py


示例14: do_run_until_condition

    def do_run_until_condition (self, sample_rate):
        """Starts TRex and sample server until condition is satisfied."""
        print termstyle.green("*** Starting TRex run until condition is satisfied scenario ***")

        def condition (result_obj):
                return result_obj.get_current_tx_rate()['m_tx_pps'] > 200000

        if not sample_rate: # use default sample rate if not passed
            sample_rate = 5
        try:
            sample_rate = int(sample_rate)
            ret = self.trex.start_trex(**self.run_params)
            ret_val = self.trex.sample_until_condition(condition, sample_rate)
            print ret_val
            print termstyle.green("*** End of TRex run ***")
        except ValueError as inst:
            print termstyle.magenta("Provided illegal sample rate value. Please try again.\n[", inst,"]")
        except TRexException as inst:
            print termstyle.red(inst)
开发者ID:Pojen-Huang,项目名称:trex-core,代码行数:19,代码来源:client_interactive_example.py


示例15: start_master_daemon

def start_master_daemon():
    if master_daemon.is_running():
        raise Exception('Master daemon is already running')
    proc = multiprocessing.Process(target = start_master_daemon_func)
    proc.daemon = True
    proc.start()
    for i in range(50):
        if master_daemon.is_running():
            return True
        sleep(0.1)
    fail(termstyle.red('Master daemon failed to run. Please look in log: %s' % logging_file))
开发者ID:wwwatm,项目名称:trex-core,代码行数:11,代码来源:master_daemon.py


示例16: start_master_daemon

def start_master_daemon():
    if master_daemon.is_running():
        raise Exception('Master daemon is already running')
    proc = multiprocessing.Process(target = start_master_daemon_func)
    proc.daemon = True
    proc.start()
    for i in range(50):
        if master_daemon.is_running():
            print(termstyle.green('Master daemon is started'))
            os._exit(0)
        sleep(0.1)
    fail(termstyle.red('Master daemon failed to run'))
开发者ID:Pojen-Huang,项目名称:trex-core,代码行数:12,代码来源:master_daemon.py


示例17: do_run_and_poll

 def do_run_and_poll (self, sample_rate):
     """Starts TRex and sample server manually until run is done."""
     print termstyle.green("*** Starting TRex run and manually poll scenario ***")
     if not sample_rate: # use default sample rate if not passed
         sample_rate = 5
     try:
         sample_rate = int(sample_rate)
         ret = self.trex.start_trex(**self.run_params)
         last_res = dict()
         while self.trex.is_running(dump_out = last_res):
             obj = self.trex.get_result_obj()
             if (self.verbose):
                 print obj
             # do WHATEVER here
             time.sleep(sample_rate)
             
         print termstyle.green("*** End of TRex run ***")
     except ValueError as inst:
         print termstyle.magenta("Provided illegal sample rate value. Please try again.\n[", inst,"]")
     except TRexException as inst:
         print termstyle.red(inst)
开发者ID:Pojen-Huang,项目名称:trex-core,代码行数:21,代码来源:client_interactive_example.py


示例18: dump_info

def dump_info(fname, file_descriptor=None):
    info = red('unknown error')
    if not os.path.getsize(fname):
        info = red('empty file')
    else:
        try:
            if file_descriptor is None:
                handle = open(fname, 'rt')
                fcntl.flock(handle, fcntl.LOCK_EX | fcntl.LOCK_NB)
            else:
                handle = file_descriptor
        except BlockingIOError:
            info = red('Dump file is locked.')
        except OSError as exc:
            info = red('unable to open file: {!s}'.format(exc))
        else:
            try:
                content = json.load(handle)
            except ValueError as exc:
                info = red('unable to load JSON: {!s}'.format(exc))
            else:
                try:
                    info = "{!s} dumps".format(len(content.keys()))
                except AttributeError as exc:
                    info = red("unable to count dumps: {!s}".format(exc))
        finally:
            try:
                if file_descriptor is None:
                    handle.close()
            except NameError:
                pass
    return info
开发者ID:certtools,项目名称:intelmq,代码行数:32,代码来源:intelmqdump.py


示例19: test_report_watchstate

    def test_report_watchstate(self):
        f = io.StringIO()
        r = TerminalReporter(watch_path=None,
                             build_path=None,
                             terminal=Terminal(stream=f))

        r.report_watchstate(
            WatchState(['create'], ['delete'], ['modify'], 1.0)
        )
        assert f.getvalue() == os.linesep.join([
                termstyle.green('# CREATED create'),
                termstyle.yellow('# MODIFIED modify'),
                termstyle.red('# DELETED delete'),
                '### Scan time:      1.000s',
                ]) + os.linesep
开发者ID:yerejm,项目名称:ttt,代码行数:15,代码来源:test_reporter.py


示例20: red

 def red(self, text):
     self._restoreColor()
     return termstyle.red(text)
开发者ID:MinchinWeb,项目名称:green,代码行数:3,代码来源:output.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python terrain.Terrain类代码示例发布时间:2022-05-27
下一篇:
Python termstyle.green函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap