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


Python colored.blue方法代码示例

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


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

示例1: fix_check

# 需要导入模块: from clint.textui import colored [as 别名]
# 或者: from clint.textui.colored import blue [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

示例2: reset_object

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

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

        if mode == acl:
            puts(str_key + ' ' + colored.green('ACL already ' + acl))
            return 'ACL already ' + acl
        elif dry_run:
            puts(str_key + ' ' + colored.yellow('ACL to be updated to ' + acl))
            return 'ACL to be updated to ' + acl
        else:
            obj_acl.put(ACL=acl)
            puts(str_key + ' ' + colored.blue('ACL updated to ' + acl))
            return 'ACL updated to ' + acl

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

示例3: delete_unencrypted_version

# 需要导入模块: from clint.textui import colored [as 别名]
# 或者: from clint.textui.colored import blue [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

示例4: menu

# 需要导入模块: from clint.textui import colored [as 别名]
# 或者: from clint.textui.colored import blue [as 别名]
def menu():
    print ""
    print colored.yellow("################")
    print colored.yellow("##### IPTV #####")
    print colored.yellow("##### v" + cr.version + " ###")
    print colored.yellow("################")
    print ""
    print colored.blue("Menu")
    print "0 - Exit"
    print "1 - Search for some Servers"
    print "2 - Look at the servers list"
    print "3 - Select language, default is Italian"
    print "4 - Brute force all server from the list"
    print "5 - Brute force random server from the list"
    print "6 - Brute force specific server from the list"
    print "7 - Provide a random server to attack"
    print "" 
开发者ID:Pirate-Crew,项目名称:IPTV,代码行数:19,代码来源:iptv.py

示例5: __init__

# 需要导入模块: from clint.textui import colored [as 别名]
# 或者: from clint.textui.colored import blue [as 别名]
def __init__(self, message, parent_exception=None):
        self.message = message
        if parent_exception and hasattr(parent_exception, 'user_description'):
            vals = {
                "original": self.message,
                "type_description": parent_exception.user_description,
                "message": str(parent_exception),
            }
            self.message = "".join([str(colored.blue("{original}\n\n")),
                                    "-" * 30,
                                    "\n{type_description}:\n",
                                    str(colored.yellow("{message}\n"))]
                                    ).format(**vals)

        super(DatacatsError, self).__init__(message) 
开发者ID:datacats,项目名称:datacats,代码行数:17,代码来源:error.py

示例6: pretty_print

# 需要导入模块: from clint.textui import colored [as 别名]
# 或者: from clint.textui.colored import blue [as 别名]
def pretty_print(self):
        """
        Print the error message to stdout with colors and borders
        """
        print colored.blue("-" * 40)
        print colored.red("datacats: problem was encountered:")
        print self.message
        print colored.blue("-" * 40) 
开发者ID:datacats,项目名称:datacats,代码行数:10,代码来源:error.py

示例7: reload

# 需要导入模块: from clint.textui import colored [as 别名]
# 或者: from clint.textui.colored import blue [as 别名]
def reload(self, arguments):
        """
        Restarts Mech machine, loads new Mechfile configuration.

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

        Options:
                --provision                  Enable provisioning
            -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)

        puts_err(colored.blue("Reloading machine..."))
        started = vmrun.reset()
        if started is None:
            puts_err(colored.red("VM not restarted"))
        else:
            time.sleep(3)
            puts_err(colored.blue("Getting IP address..."))
            lookup = self.get("enable_ip_lookup", False)
            ip = vmrun.getGuestIPAddress(lookup=lookup)
            if ip:
                if started:
                    puts_err(colored.green("VM started on {}".format(ip)))
                else:
                    puts_err(colored.yellow("VM already was started on {}".format(ip)))
            else:
                if started:
                    puts_err(colored.green("VM started on an unknown IP address"))
                else:
                    puts_err(colored.yellow("VM already was started on an unknown IP address")) 
开发者ID:mechboxes,项目名称:mech,代码行数:36,代码来源:mech.py

示例8: init_box

# 需要导入模块: from clint.textui import colored [as 别名]
# 或者: from clint.textui.colored import blue [as 别名]
def init_box(name, version, force=False, save=True, requests_kwargs={}):
    if not locate('.mech', '*.vmx'):
        name_version_box = add_box(name, name=name, version=version, force=force, save=save, requests_kwargs=requests_kwargs)
        if not name_version_box:
            puts_err(colored.red("Cannot find a valid box with a VMX file in it"))
            sys.exit(1)
        name, version, box = name_version_box
        # box = locate(os.path.join(*filter(None, (HOME, 'boxes', name, version))), '*.box')

        puts_err(colored.blue("Extracting box '{}'...".format(name)))
        makedirs('.mech')
        if sys.platform == 'win32':
            cmd = tar_cmd('-xf', box, force_local=True)
        else:
            cmd = tar_cmd('-xf', box)
        if cmd:
            startupinfo = None
            if os.name == "nt":
                startupinfo = subprocess.STARTUPINFO()
                startupinfo.dwFlags |= subprocess.SW_HIDE | subprocess.STARTF_USESHOWWINDOW
            proc = subprocess.Popen(cmd, cwd='.mech', startupinfo=startupinfo)
            if proc.wait():
                puts_err(colored.red("Cannot extract box"))
                sys.exit(1)
        else:
            tar = tarfile.open(box, 'r')
            tar.extractall('.mech')

        if not save and box.startswith(tempfile.gettempdir()):
            os.unlink(box)

    vmx = get_vmx()

    update_vmx(vmx)

    return vmx 
开发者ID:mechboxes,项目名称:mech,代码行数:38,代码来源:utils.py

示例9: add_box_file

# 需要导入模块: from clint.textui import colored [as 别名]
# 或者: from clint.textui.colored import blue [as 别名]
def add_box_file(name, version, filename, url=None, force=False, save=True):
    puts_err(colored.blue("Checking box '{}' integrity...".format(name)))

    if sys.platform == 'win32':
        cmd = tar_cmd('-tf', filename, '*.vmx', wildcards=True, fast_read=True, force_local=True)
    else:
        cmd = tar_cmd('-tf', filename, '*.vmx', wildcards=True, fast_read=True)
    if cmd:
        startupinfo = None
        if os.name == "nt":
            startupinfo = subprocess.STARTUPINFO()
            startupinfo.dwFlags |= subprocess.SW_HIDE | subprocess.STARTF_USESHOWWINDOW
        proc = subprocess.Popen(cmd, startupinfo=startupinfo)
        valid_tar = not proc.wait()
    else:
        tar = tarfile.open(filename, 'r')
        files = tar.getnames()
        valid_tar = False
        for i in files:
            if i.endswith('vmx'):
                valid_tar = True
                break
            if i.startswith('/') or i.startswith('..'):
                puts_err(colored.red(textwrap.fill(
                    "This box is comprised of filenames starting with '/' or '..' "
                    "Exiting for the safety of your files."
                )))
                sys.exit(1)

    if valid_tar:
        if save:
            boxname = os.path.basename(url if url else filename)
            box = os.path.join(*filter(None, (HOME, 'boxes', name, version, boxname)))
            path = os.path.dirname(box)
            makedirs(path)
            if not os.path.exists(box) or force:
                copyfile(filename, box)
        else:
            box = filename
        return name, version, box 
开发者ID:mechboxes,项目名称:mech,代码行数:42,代码来源:utils.py

示例10: message

# 需要导入模块: from clint.textui import colored [as 别名]
# 或者: from clint.textui.colored import blue [as 别名]
def message(message, n_indent = 4, color = "blue"):
    with indent(n_indent):
        if color == "blue":
            puts_err(colored.blue('\n' + message + '\n'))
        elif color == "red":
            puts_err(colored.blue('\n' + message + '\n')) 
开发者ID:AndersenLab,项目名称:VCF-kit,代码行数:8,代码来源:__init__.py

示例11: download_genomes

# 需要导入模块: from clint.textui import colored [as 别名]
# 或者: from clint.textui.colored import blue [as 别名]
def download_genomes(genome_db):
    if os.path.isfile(genome_db):
        fileTime = os.path.getmtime(genome_db)
    else:
        fileTime = 0
    if (time() - fileTime) > (3 * 30 * 24 * 60 * 60) or is_non_zero_file(genome_db) is False:
        with indent(2):
            puts(colored.blue('\nDownloading list of reference genomes\n'))
        r = requests.get("http://ftp.ncbi.nlm.nih.gov/genomes/ASSEMBLY_REPORTS/assembly_summary_refseq.txt")
        genome_file = open(genome_db, "w")
        with genome_file as f:
            f.write(r.text.encode('utf-8').strip()) 
开发者ID:AndersenLab,项目名称:VCF-kit,代码行数:14,代码来源:genome.py

示例12: print_containers

# 需要导入模块: from clint.textui import colored [as 别名]
# 或者: from clint.textui.colored import blue [as 别名]
def print_containers(containers, to_json=False):
    containers = sorted(containers, key=lambda c: c.name)

    if to_json:
        d = [c.to_dict() for c in containers]
        puts(json.dumps(d, indent=2, sort_keys=True, separators=(',', ': ')))

    else:
        puts(colored.blue(columns(["NODE",               15],
                                  ["CONTAINER ID",       15],
                                  ["STATUS",              7],
                                  ["IP",                 15],
                                  ["NETWORK",            10],
                                  ["PARTITION",          10])))

        def partition_label(c):
            if c.holy:
                return "H"
            elif c.partition:
                if c.neutral:
                    return str(c.partition) + " [N]"
                else:
                    return str(c.partition)
            elif c.neutral:
                return "N"
            else:
                return ""

        for container in containers:
            puts(columns([container.name,                15],
                         [container.container_id[:12],   15],
                         [container.status,               7],
                         [container.ip_address or "",    15],
                         [container.network_state,       10],
                         [partition_label(container),    10])) 
开发者ID:worstcase,项目名称:blockade,代码行数:37,代码来源:cli.py

示例13: cmd_events

# 需要导入模块: from clint.textui import colored [as 别名]
# 或者: from clint.textui.colored import blue [as 别名]
def cmd_events(opts):
    """Get the event log for a given blockade
    """
    config = load_config(opts.config)
    b = get_blockade(config, opts)

    if opts.json:
        outf = None
        _write = puts
        if opts.output is not None:
            outf = open(opts.output, "w")
            _write = outf.write
        try:
            delim = ""
            logs = b.get_audit().read_logs(as_json=False)
            _write('{"events": [')
            _write(os.linesep)
            for l in logs:
                _write(delim + l)
                delim = "," + os.linesep
            _write(os.linesep)
            _write(']}')
        finally:
            if opts.output is not None:
                outf.close()
    else:
        puts(colored.blue(columns(["EVENT",         10],
                                  ["TARGET",        16],
                                  ["STATUS",         8],
                                  ["TIME",          16],
                                  ["MESSAGE",       25])))

        logs = b.get_audit().read_logs(as_json=True)
        for l in logs:
            puts(columns([l['event'],                          10],
                         [str([str(t) for t in l['targets']]), 16],
                         [l['status'],                          8],
                         [str(l['timestamp']),                 16],
                         [l['message'],                        25])) 
开发者ID:worstcase,项目名称:blockade,代码行数:41,代码来源:cli.py

示例14: action_pp

# 需要导入模块: from clint.textui import colored [as 别名]
# 或者: from clint.textui.colored import blue [as 别名]
def action_pp(state):
    actions = state.actions.hardcopy
    for a in actions:
        if isinstance(a, SimActionExit):
            print(blue("[%#08x] ===> %s %s" % (a.ins_addr, a.exit_type, a.target)))
        elif isinstance(a, SimActionData):
            print("[%#08x] %s %s: %s" % (a.ins_addr, a.action, str(a.tmp), a.data))
        elif isinstance(a, SimActionOperation):
            print(red("[%#08x] %s %s" % (a.ins_addr, a.op, ", ".join([str(e) for e in a.exprs])))) 
开发者ID:angr,项目名称:angr-platforms,代码行数:11,代码来源:action_pp.py

示例15: encrypt_object

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

    try:
        if customer_key:
            obj.load(SSECustomerAlgorithm='AES256', SSECustomerKey=customer_key)

        encrypted = None
        if customer_key:
            encrypted = obj.sse_customer_algorithm is not None
        elif kms_key_id:
            encrypted = obj.server_side_encryption == 'aws:kms'
        else:
            encrypted = obj.server_side_encryption == 'AES256'

        if encrypted:
            puts(str_key + ' ' + colored.green('already encrypted'))
            return 'already encrypted'
        else:
            if dry_run:
                puts(str_key + ' ' + colored.yellow('to be encrypted'))
                return 'to be encrypted'
            else:
                copy_source = {'Bucket': bucket_name, 'Key': obj.key}

                # TODO support going from customer encryption to other forms
                if kms_key_id:
                    obj.copy_from(
                        CopySource=copy_source,
                        ServerSideEncryption='aws:kms',
                        SSEKMSKeyId=kms_key_id
                    )
                elif customer_key:
                    obj.copy_from(
                        CopySource=copy_source,
                        SSECustomerAlgorithm='AES256',
                        SSECustomerKey=customer_key
                    )
                else:
                    obj.copy_from(
                        CopySource=copy_source,
                        ServerSideEncryption='AES256'
                    )

                puts(str_key + ' ' + colored.blue('just encrypted'))
                return 'just encrypted'

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


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