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


Python colored.red方法代码示例

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


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

示例1: __call__

# 需要导入模块: from clint.textui import colored [as 别名]
# 或者: from clint.textui.colored import red [as 别名]
def __call__(self, *args, **kwargs):
        from docopt import docopt
        arguments = docopt(*args, **kwargs)

        from ..config import load as config_load
        from ..config import ConfigFileNotFound

        try:
            config_load(arguments['-c'])
        except ConfigFileNotFound as e:
            if not arguments['config']:
                puts(colored.red(str(e)))
                sys.exit(1)

        for patterns, function in self._functions.items():
            if all(arguments[pattern] for pattern in patterns):
                function(**self._kwargify(arguments))
                return
        raise DispatchError('None of dispatch conditions %s is triggered'
                            % self._formated_patterns) 
开发者ID:rtshome,项目名称:pgrepup,代码行数:22,代码来源:docopt_dispatch.py

示例2: update

# 需要导入模块: from clint.textui import colored [as 别名]
# 或者: from clint.textui.colored import red [as 别名]
def update(user, password, lang=None):
    langs = getlangs(lang)
    puts(u"Updating %s" % ', '.join(langs))
    for loc in langs:
        with indent(2):
            puts(u"Downloading PO for %s" % loc)
        url = (u'https://www.transifex.com/projects/p/formhub/'
               u'resource/django/l/%(lang)s/download/for_use/' % {'lang': loc})
        try:
            tmp_po_file = download_with_login(url, TX_LOGIN_URL,
                                              login=user, password=password,
                                              ext='po',
                                              username_field='identification',
                                              password_field='password',
                                              form_id=1)
            po_file = os.path.join(REPO_ROOT, 'locale', loc,
                                   'LC_MESSAGES', 'django.po')
            with indent(2):
                puts(u"Copying downloaded file to %s" % po_file)
            shutil.move(tmp_po_file, po_file)
        except Exception as e:
            puts(colored.red(u"Unable to update %s "
                             u"from Transifex: %r" % (loc, e)))
        puts(colored.green("sucesssfuly retrieved %s" % loc))
    compile_mo(langs) 
开发者ID:awemulya,项目名称:kobo-predict,代码行数:27,代码来源:i18ntool.py

示例3: fix_check

# 需要导入模块: from clint.textui import colored [as 别名]
# 或者: from clint.textui.colored import red [as 别名]
def fix_check(klass, buckets, dry_run, fix_args={}):
    for bucket in fetch_buckets(buckets):
        check = klass(bucket)
        check.perform()

        if check.status == 'passed':
            message = colored.green('already ' + check.pass_message)
        elif check.status == 'denied':
            message = colored.red('access denied')
        else:
            if dry_run:
                message = colored.yellow('to be ' + check.pass_message)
            else:
                try:
                    check.fix(fix_args)
                    message = colored.blue('just ' + check.pass_message)
                except botocore.exceptions.ClientError as e:
                    message = colored.red(str(e))

        puts(bucket.name + ' ' + message) 
开发者ID:ankane,项目名称:s3tk,代码行数:22,代码来源:__init__.py

示例4: scan_object

# 需要导入模块: from clint.textui import colored [as 别名]
# 或者: from clint.textui.colored import red [as 别名]
def scan_object(bucket_name, key):
    obj = s3().Object(bucket_name, key)
    str_key = unicode_key(key)

    try:
        mode = determine_mode(obj.Acl())

        if mode == 'private':
            puts(str_key + ' ' + colored.green(mode))
        else:
            puts(str_key + ' ' + colored.yellow(mode))

        return mode
    except (botocore.exceptions.ClientError, botocore.exceptions.NoCredentialsError) as e:
        puts(str_key + ' ' + colored.red(str(e)))
        return 'error' 
开发者ID:ankane,项目名称:s3tk,代码行数:18,代码来源:__init__.py

示例5: delete_unencrypted_version

# 需要导入模块: from clint.textui import colored [as 别名]
# 或者: from clint.textui.colored import red [as 别名]
def delete_unencrypted_version(bucket_name, key, id, dry_run):
    object_version = s3().ObjectVersion(bucket_name, key, id)

    try:
        obj = object_version.get()
        if obj.get('ServerSideEncryption') or obj.get('SSECustomerAlgorithm'):
            puts(key + ' ' + id + ' ' + colored.green('encrypted'))
            return 'encrypted'
        else:
            if dry_run:
                puts(key + ' ' + id + ' ' + colored.blue('to be deleted'))
                return 'to be deleted'
            else:
                puts(key + ' ' + id + ' ' + colored.blue('deleted'))
                object_version.delete()
                return 'deleted'
    except (botocore.exceptions.ClientError, botocore.exceptions.NoCredentialsError) as e:
        puts(key + ' ' + id + ' ' + colored.red(str(e)))
        return 'error' 
开发者ID:ankane,项目名称:s3tk,代码行数:21,代码来源:__init__.py

示例6: activate

# 需要导入模块: from clint.textui import colored [as 别名]
# 或者: from clint.textui.colored import red [as 别名]
def activate(self, instance_name=None):
        if not hasattr(self, 'mechfiles'):
            self.mechfiles = {}
        if instance_name:
            instance = utils.settle_instance(instance_name)
            path = instance.get('path')
            if not path:
                puts_err(colored.red(textwrap.fill("Cannot find a valid path for '{}' instance".format(instance_name))))
                sys.exit(1)
            path = os.path.abspath(os.path.expanduser(path))
            os.chdir(path)
            self.activate_mechfile(path)
        else:
            path = os.getcwd()
            self.activate_mechfile(path)
            instance_name = self.active_mechfile.get('name') or os.path.basename(path)  # Use the Mechfile's name if available
        return instance_name 
开发者ID:mechboxes,项目名称:mech,代码行数:19,代码来源:mech.py

示例7: update

# 需要导入模块: from clint.textui import colored [as 别名]
# 或者: from clint.textui.colored import red [as 别名]
def update(self, arguments):
        """
        Update the box that is in use in the current mech environment.

        Usage: mech box update [options] [<name>]

        Notes:
            Only if there any updates available. This does not destroy/recreate
            the machine, so you'll have to do that to see changes.

        Options:
            -f, --force                      Overwrite an existing box if it exists
                --insecure                   Do not validate SSL certificates
                --cacert FILE                CA certificate for SSL download
                --capath DIR                 CA certificate directory for SSL download
                --cert FILE                  A client SSL cert, if needed
            -h, --help                       Print this help
        """
        puts_err(colored.red("Not implemented!")) 
开发者ID:mechboxes,项目名称:mech,代码行数:21,代码来源:mech.py

示例8: delete

# 需要导入模块: from clint.textui import colored [as 别名]
# 或者: from clint.textui.colored import red [as 别名]
def delete(self, arguments):
        """
        Delete a snapshot taken previously with snapshot save.

        Usage: mech snapshot delete [options] <name> [<instance>]

        Options:
            -h, --help                       Print this help
        """
        name = arguments['<name>']

        instance_name = arguments['<instance>']
        instance_name = self.activate(instance_name)

        vmrun = VMrun(self.vmx, user=self.user, password=self.password)
        if vmrun.deleteSnapshot(name) is None:
            puts_err(colored.red("Cannot delete name"))
        else:
            puts_err(colored.green("Snapshot {} deleted".format(name))) 
开发者ID:mechboxes,项目名称:mech,代码行数:21,代码来源:mech.py

示例9: push

# 需要导入模块: from clint.textui import colored [as 别名]
# 或者: from clint.textui.colored import red [as 别名]
def push(self, arguments):
        """
        Push a snapshot of the current state of the machine.

        Usage: mech snapshot push [options] [<instance>]

        Notes:
            Take a snapshot of the current state of the machine and 'push'
            it onto the stack of states. You can use `mech snapshot pop`
            to restore back to this state at any time.

            If you use `mech snapshot save` or restore at any point after
            a push, pop will still bring you back to this pushed state.

        Options:
            -h, --help                       Print this help
        """
        puts_err(colored.red("Not implemented!")) 
开发者ID:mechboxes,项目名称:mech,代码行数:20,代码来源:mech.py

示例10: down

# 需要导入模块: from clint.textui import colored [as 别名]
# 或者: from clint.textui.colored import red [as 别名]
def down(self, arguments):
        """
        Stops the Mech machine.

        Usage: mech down [options] [<instance>]

        Options:
                --force                      Force a hard stop
            -h, --help                       Print this help
        """
        force = arguments['--force']

        instance_name = arguments['<instance>']
        instance_name = self.activate(instance_name)

        vmrun = VMrun(self.vmx, user=self.user, password=self.password)
        if not force and vmrun.installedTools():
            stopped = vmrun.stop()
        else:
            stopped = vmrun.stop(mode='hard')
        if stopped is None:
            puts_err(colored.red("Not stopped", vmrun))
        else:
            puts_err(colored.green("Stopped", vmrun)) 
开发者ID:mechboxes,项目名称:mech,代码行数:26,代码来源:mech.py

示例11: suspend

# 需要导入模块: from clint.textui import colored [as 别名]
# 或者: from clint.textui.colored import red [as 别名]
def suspend(self, arguments):
        """
        Suspends the machine.

        Usage: mech suspend [options] [<instance>]

        Options:
            -h, --help                       Print this help
        """
        instance_name = arguments['<instance>']
        instance_name = self.activate(instance_name)

        vmrun = VMrun(self.vmx, user=self.user, password=self.password)
        if vmrun.suspend() is None:
            puts_err(colored.red("Not suspended", vmrun))
        else:
            puts_err(colored.green("Suspended", vmrun)) 
开发者ID:mechboxes,项目名称:mech,代码行数:19,代码来源:mech.py

示例12: ip

# 需要导入模块: from clint.textui import colored [as 别名]
# 或者: from clint.textui.colored import red [as 别名]
def ip(self, arguments):
        """
        Outputs ip of the Mech machine.

        Usage: mech ip [options] [<instance>]

        Options:
            -h, --help                       Print this help
        """
        instance_name = arguments['<instance>']
        instance_name = self.activate(instance_name)

        vmrun = VMrun(self.vmx, user=self.user, password=self.password)
        lookup = self.get("enable_ip_lookup", False)
        ip = vmrun.getGuestIPAddress(lookup=lookup)
        if ip:
            puts_err(colored.green(ip))
        else:
            puts_err(colored.red("Unknown IP address")) 
开发者ID:mechboxes,项目名称:mech,代码行数:21,代码来源:mech.py

示例13: port

# 需要导入模块: from clint.textui import colored [as 别名]
# 或者: from clint.textui.colored import red [as 别名]
def port(self, arguments):
        """
        Displays information about guest port mappings.

        Usage: mech port [options] [<instance>]

        Options:
                --guest PORT                 Output the host port that maps to the given guest port
                --machine-readable           Display machine-readable output
            -h, --help                       Print this help
        """
        instance_name = arguments['<instance>']
        instance_name = self.activate(instance_name)

        vmrun = VMrun(self.vmx, user=self.user, password=self.password)
        for network in vmrun.listHostNetworks().split('\n'):
            network = network.split()
            if len(network) > 2 and network[2] == 'nat':
                print(vmrun.listPortForwardings(network[1]))
                break
        else:
            puts_err(colored.red("Cannot find a nat network")) 
开发者ID:mechboxes,项目名称:mech,代码行数:24,代码来源:mech.py

示例14: resolve_reference_genome

# 需要导入模块: from clint.textui import colored [as 别名]
# 或者: from clint.textui.colored import red [as 别名]
def resolve_reference_genome(loc):
    """
        Resolve location of reference genome file.
    """

    if loc is None:
        message("You must specify a genome:")
        output_genome_list()
        exit()

    if os.path.exists(loc):
        return loc
    else:
        if loc in get_genome_list():
            reference_location = "{gd}/{loc}/{loc}.fa.gz".format(gd = get_genome_directory(), loc = loc)
            with indent(4):
                puts_err(colored.green("\nUsing reference located at %s\n" % reference_location))
            return reference_location
        else:
            with indent(4):
                exit(puts_err(colored.red("\nGenome '%s' does not exist\n" % loc))) 
开发者ID:AndersenLab,项目名称:VCF-kit,代码行数:23,代码来源:reference.py

示例15: confirm

# 需要导入模块: from clint.textui import colored [as 别名]
# 或者: from clint.textui.colored import red [as 别名]
def confirm(user_prompt=DEFAULT_PROMPT, default=None):
    if default is True:
        prompt_to_use = user_prompt + ' [Y/n]: '
    elif default is False:
        prompt_to_use = user_prompt + ' [y/N]: '
    elif default is None:
        prompt_to_use = user_prompt + ': '
    else:
        raise Exception('Bad Default Value: %s' % default)
    user_input = raw_input(prompt_to_use).strip()
    if not user_input:
        return default
    elif user_input.lower() == 'y':
        return True
    elif user_input.lower() == 'n':
        return False
    else:
        puts(colored.red('`%s` is not a valid entry. Please enter either Y or N.' % user_input))
        return confirm(user_prompt=user_prompt, default=default) 
开发者ID:blockcypher,项目名称:bcwallet,代码行数:21,代码来源:cl_utils.py


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