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


Python console.colorize函数代码示例

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


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

示例1: test_acceptance

def test_acceptance(options):
    """
    Run the acceptance tests for the either lms or cms
    """
    opts = {
        'fasttest': getattr(options, 'fasttest', False),
        'system': getattr(options, 'system', None),
        'default_store': getattr(options, 'default_store', None),
        'verbosity': getattr(options, 'verbosity', 3),
        'extra_args': getattr(options, 'extra_args', ''),
        'pdb': getattr(options, 'pdb', False),
    }

    if opts['system'] not in ['cms', 'lms']:
        msg = colorize(
            'red',
            'No system specified, running tests for both cms and lms.'
        )
        print msg
    if opts['default_store'] not in ['draft', 'split']:
        msg = colorize(
            'red',
            'No modulestore specified, running tests for both draft and split.'
        )
        print msg

    suite = AcceptanceTestSuite('{} acceptance'.format(opts['system']), **opts)
    suite.run()
开发者ID:andela-ijubril,项目名称:edx-platform,代码行数:28,代码来源:acceptance_test.py

示例2: format_message

def format_message(status):
    sender = console.colorize('red', '@%s' % status.GetSenderScreenName())
    recipient = console.colorize('red', '@%s' % status.GetRecipientScreenName())
    date = console.colorize('blue', '\t\t%s' % status.GetCreatedAt())
    arrow = console.colorize('darkgray', ' -> ')
    text = console.colorize('black', '\t%s' % format_text(status.GetText()))
    return '\n'.join([sender + arrow + recipient + date, text])
开发者ID:PepeGuerrero,项目名称:LearningPython,代码行数:7,代码来源:tuitpy.py

示例3: __enter__

    def __enter__(self):
        super(BokChoyTestSuite, self).__enter__()

        # Ensure that we have a directory to put logs and reports
        self.log_dir.makedirs_p()
        self.har_dir.makedirs_p()
        self.report_dir.makedirs_p()
        test_utils.clean_reports_dir()

        if not (self.fasttest or self.skip_clean):
            test_utils.clean_test_files()

        msg = colorize('green', "Checking for mongo, memchache, and mysql...")
        print msg
        bokchoy_utils.check_services()

        if not self.testsonly:
            self.prepare_bokchoy_run()

        msg = colorize('green', "Confirming servers have started...")
        print msg
        bokchoy_utils.wait_for_test_servers()
        try:
            # Create course in order to seed forum data underneath. This is
            # a workaround for a race condition. The first time a course is created;
            # role permissions are set up for forums.
            CourseFixture('foobar_org', '1117', 'seed_forum', 'seed_foo').install()
            print 'Forums permissions/roles data has been seeded'
        except FixtureError:
            # this means it's already been done
            pass

        if self.serversonly:
            self.run_servers_continuously()
开发者ID:Certific-NET,项目名称:edx-platform,代码行数:34,代码来源:bokchoy_suite.py

示例4: __init__

    def __init__(self, *args, **kwargs):
        super(SystemTestSuite, self).__init__(*args, **kwargs)
        self.test_id = kwargs.get('test_id', self._default_test_id)
        self.fasttest = kwargs.get('fasttest', False)

        self.processes = kwargs.get('processes', None)
        self.randomize = kwargs.get('randomize', None)
        self.settings = kwargs.get('settings', Env.TEST_SETTINGS)

        if self.processes is None:
            # Don't use multiprocessing by default
            self.processes = 0

        self.processes = int(self.processes)

        if self.randomize is None:
            self.randomize = self.root == 'lms'

        if self.processes != 0 and self.verbosity > 1:
            print colorize(
                'red',
                "The TestId module and multiprocessing module can't be run "
                "together in verbose mode. Disabling TestId for {} tests.".format(self.root)
            )
            self.use_ids = False
开发者ID:Lektorium-LLC,项目名称:edx-platform,代码行数:25,代码来源:nose_suite.py

示例5: get_test_course

    def get_test_course(self):
        """
        Fetches the test course.
        """
        self.imports_dir.makedirs_p()
        zipped_course = self.imports_dir + 'demo_course.tar.gz'

        msg = colorize('green', "Fetching the test course from github...")
        print msg

        sh(
            'wget {tar_gz_file} -O {zipped_course}'.format(
                tar_gz_file=self.tar_gz_file,
                zipped_course=zipped_course,
            )
        )

        msg = colorize('green', "Uncompressing the test course...")
        print msg

        sh(
            'tar zxf {zipped_course} -C {courses_dir}'.format(
                zipped_course=zipped_course,
                courses_dir=self.imports_dir,
            )
        )
开发者ID:AndreySonetico,项目名称:edx-platform,代码行数:26,代码来源:bokchoy_suite.py

示例6: __init__

    def __init__(self, *args, **kwargs):
        super(SystemTestSuite, self).__init__(*args, **kwargs)
        self.test_id = kwargs.get('test_id', self._default_test_id)
        self.fasttest = kwargs.get('fasttest', False)

        self.processes = kwargs.get('processes', None)
        self.randomize = kwargs.get('randomize', None)

        if self.processes is None:
            # Use one process per core for LMS tests, and no multiprocessing
            # otherwise.
            self.processes = 0

        self.processes = int(self.processes)

        if self.randomize is None:
            self.randomize = False

        if self.processes != 0 and self.verbosity > 1:
            print colorize(
                'red',
                "The TestId module and multiprocessing module can't be run "
                "together in verbose mode. Disabling TestId for {} tests.".format(self.root)
            )
            self.use_ids = False
开发者ID:Rosivania,项目名称:edx-platform,代码行数:25,代码来源:nose_suite.py

示例7: generate_optimized_static_assets

 def generate_optimized_static_assets(self):
     """
     Collect static assets using test_static_optimized.py which generates
     optimized files to a dedicated test static root.
     """
     print colorize("green", "Generating optimized static assets...")
     sh("paver update_assets --settings=test_static_optimized")
开发者ID:sigberto,项目名称:edx-platform,代码行数:7,代码来源:suite.py

示例8: report_test_results

    def report_test_results(self):
        """
        Writes a list of failed_suites to sys.stderr
        """
        if self.failed_suites:
            msg = colorize('red', "\n\n{bar}\nTests failed in the following suites:\n* ".format(bar="=" * 48))
            msg += colorize('red', '\n* '.join([s.root for s in self.failed_suites]) + '\n\n')
        else:
            msg = colorize('green', "\n\n{bar}\nNo test failures ".format(bar="=" * 48))

        print msg
开发者ID:TeachAtTUM,项目名称:edx-platform,代码行数:11,代码来源:suite.py

示例9: report_test_results

    def report_test_results(self):
        """
        Writes a list of failed_suites to sys.stderr
        """
        if len(self.failed_suites) > 0:
            msg = colorize("red", "\n\n{bar}\nTests failed in the following suites:\n* ".format(bar="=" * 48))
            msg += colorize("red", "\n* ".join([s.root for s in self.failed_suites]) + "\n\n")
        else:
            msg = colorize("green", "\n\n{bar}\nNo test failures ".format(bar="=" * 48))

        print (msg)
开发者ID:sigberto,项目名称:edx-platform,代码行数:11,代码来源:suite.py

示例10: __init__

 def __init__(self, **options):
     Formatter.__init__(self, **options)
     self.compress = get_choice_opt(options, 'compress',
                                    ['', 'none', 'gz', 'bz2'], '')
     self.error_color = options.get('error_color', None)
     if self.error_color is True:
         self.error_color = 'red'
     if self.error_color is not None:
         try:
             colorize(self.error_color, '')
         except KeyError:
             raise ValueError("Invalid color %r specified" %
                              self.error_color)
开发者ID:mbialon,项目名称:yashapp,代码行数:13,代码来源:other.py

示例11: generate_optimized_static_assets

 def generate_optimized_static_assets(self, log_dir=None):
     """
     Collect static assets using test_static_optimized.py which generates
     optimized files to a dedicated test static root. Optionally use
     a log directory for collectstatic output.
     """
     print colorize('green', "Generating optimized static assets...")
     if not log_dir:
         sh("paver update_assets --settings=test_static_optimized")
     else:
         sh("paver update_assets --settings=test_static_optimized --collect-log={log_dir}".format(
             log_dir=log_dir
         ))
开发者ID:fangqian,项目名称:edx-platform,代码行数:13,代码来源:suite.py

示例12: __exit__

    def __exit__(self, exc_type, exc_value, traceback):
        super(BokChoyTestSuite, self).__exit__(exc_type, exc_value, traceback)

        # Using testsonly will leave all fixtures in place (Note: the db will also be dirtier.)
        if self.testsonly:
            msg = colorize('green', 'Running in testsonly mode... SKIPPING database cleanup.')
            print msg
        else:
            # Clean up data we created in the databases
            msg = colorize('green', "Cleaning up databases...")
            print msg
            sh("./manage.py lms --settings bok_choy flush --traceback --noinput")
            bokchoy_utils.clear_mongo()
开发者ID:AndreySonetico,项目名称:edx-platform,代码行数:13,代码来源:bokchoy_suite.py

示例13: __init__

 def __init__(self, **options):
     Formatter.__init__(self, **options)
     if self.encoding:
         raise OptionError("the raw formatter does not support the " "encoding option")
     self.encoding = "utf-8"  # let pygments.format() do the right thing
     self.compress = get_choice_opt(options, "compress", ["", "none", "gz", "bz2"], "")
     self.error_color = options.get("error_color", None)
     if self.error_color is True:
         self.error_color = "red"
     if self.error_color is not None:
         try:
             colorize(self.error_color, "")
         except KeyError:
             raise ValueError("Invalid color %r specified" % self.error_color)
开发者ID:robby31,项目名称:PythonQt,代码行数:14,代码来源:other.py

示例14: restart

    def restart(self):
        self.cls()
        print "%s" % console.reset_color()
        self.cls()

        op = raw_input(console.colorize('green', 'Timing again? ') +
                       console.colorize('turquoise', '(y/n)') +
                       console.colorize('green', ': '))
        if op in ("y", "Y"):
            self.clocking()
        elif op in ("n", "N"):
            print console.reset_color()
            self.cls()
            sys.exit(EXIT)
        else:
            self.restart()
开发者ID:FabianoZNC,项目名称:dotfiles,代码行数:16,代码来源:termtimer.py

示例15: generate_pr_table

def generate_pr_table(start_ref, end_ref):
    """
    Return a UTF-8 string corresponding to a pull request table to embed in Confluence.
    """
    header = "|| Merged By || Author || Title || PR || JIRA || Release Notes? || Verified? ||"
    pr_link = "[#{num}|https://github.com/edx/edx-platform/pull/{num}]"
    user_link = "[@{user}|https://github.com/{user}]"
    rows = [header]
    prbe = prs_by_email(start_ref, end_ref)
    for email, pull_requests in prbe.items():
        for i, pull_request in enumerate(pull_requests):
            try:
                pr_info = get_pr_info(pull_request)
                title = pr_info["title"] or ""
                body = pr_info["body"] or ""
                author = pr_info["user"]["login"]
            except requests.exceptions.RequestException as e:
                message = (
                    "Warning: could not fetch data for #{num}: "
                    "{message}".format(num=pull_request, message=e.message)
                )
                print(colorize("red", message), file=sys.stderr)
                title = "?"
                body = "?"
                author = ""
            rows.append("| {merged_by} | {author} | {title} | {pull_request} | {jira} | {release_notes} | {verified} |".format(
                merged_by=email if i == 0 else "",
                author=user_link.format(user=author) if author else "",
                title=title.replace("|", "\|").replace('{', '\{').replace('}', '\}'),
                pull_request=pr_link.format(num=pull_request),
                jira=", ".join(parse_ticket_references(body)),
                release_notes="",
                verified="",
            ))
    return "\n".join(rows).encode("utf8")
开发者ID:ammerender,项目名称:edx-platform,代码行数:35,代码来源:release.py


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