當前位置: 首頁>>代碼示例>>Python>>正文


Python colored.green方法代碼示例

本文整理匯總了Python中clint.textui.colored.green方法的典型用法代碼示例。如果您正苦於以下問題:Python colored.green方法的具體用法?Python colored.green怎麽用?Python colored.green使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在clint.textui.colored的用法示例。


在下文中一共展示了colored.green方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: update

# 需要導入模塊: from clint.textui import colored [as 別名]
# 或者: from clint.textui.colored import green [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

示例2: fix_check

# 需要導入模塊: from clint.textui import colored [as 別名]
# 或者: from clint.textui.colored import green [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

示例3: scan_object

# 需要導入模塊: from clint.textui import colored [as 別名]
# 或者: from clint.textui.colored import green [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

示例4: reset_object

# 需要導入模塊: from clint.textui import colored [as 別名]
# 或者: from clint.textui.colored import green [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

示例5: delete

# 需要導入模塊: from clint.textui import colored [as 別名]
# 或者: from clint.textui.colored import green [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

示例6: suspend

# 需要導入模塊: from clint.textui import colored [as 別名]
# 或者: from clint.textui.colored import green [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

示例7: ip

# 需要導入模塊: from clint.textui import colored [as 別名]
# 或者: from clint.textui.colored import green [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

示例8: resolve_reference_genome

# 需要導入模塊: from clint.textui import colored [as 別名]
# 或者: from clint.textui.colored import green [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

示例9: seq_type

# 需要導入模塊: from clint.textui import colored [as 別名]
# 或者: from clint.textui.colored import green [as 別名]
def seq_type(filename):
    """
        Resolves sequence filetype using extension.
    """
    filename, ext = os.path.splitext(filename.lower())
    if ext in [".fasta", ".fa"]:
        extension = 'fasta'
    elif ext in [".fastq",".fq"]:
        extension = 'fastq'
    elif ext in [".ab1", '.abi']:
        extension = 'abi'
    else:
        raise Exception("Unknown sequence file type: " + filename)

    with indent(4):
        puts_err(colored.green("\nReading sequences as %s\n" % extension.upper()))
    return extension 
開發者ID:AndersenLab,項目名稱:VCF-kit,代碼行數:19,代碼來源:call.py

示例10: main_loop

# 需要導入模塊: from clint.textui import colored [as 別名]
# 或者: from clint.textui.colored import green [as 別名]
def main_loop():
    """
    The command handler loop for the main menu. Commands will be sent to the processor and the prompt will be displayed.
    :return: None
    """
    try:
        command = ''
        while command == '':
            try:
                readline.set_completer_delims(' \t\n;')
                readline.parse_and_bind("tab: complete")
                readline.set_completer(maincomplete)
                command = raw_input('barq '+color('main', 'green')+' > ')
            except Exception as e:
                exit()
            #command = prompt.query('aws sheller main> ', validators=[])
        command = str(command)
        process_main_command(command)
    except KeyboardInterrupt as k:
        print(color("CTRL+C pressed. Exiting...", 'red'))
        exit() 
開發者ID:Voulnet,項目名稱:barq,代碼行數:23,代碼來源:barq.py

示例11: output_cli_result

# 需要導入模塊: from clint.textui import colored [as 別名]
# 或者: from clint.textui.colored import green [as 別名]
def output_cli_result(result, compensation=0):
    if isinstance(result, bool):
        text = colored.green('OK') if result else colored.red('KO')
    else:
        text = colored.yellow(result)

    return '.' * (80 - this.current_position - len(text) - compensation) + text 
開發者ID:rtshome,項目名稱:pgrepup,代碼行數:9,代碼來源:ui.py

示例12: fix

# 需要導入模塊: from clint.textui import colored [as 別名]
# 或者: from clint.textui.colored import green [as 別名]
def fix():

    # Shortcut to ask master password before output Configuration message
    decrypt(config().get('Source', 'password'))

    output_cli_message("Find Source cluster's databases with tables without primary key/unique index...", color='cyan')
    print

    db_conn = connect('Source')
    with indent(4, quote=' >'):
        for db in get_cluster_databases(db_conn):
            output_cli_message(db)
            s_db_conn = connect('Source', db_name=db)
            tables_without_unique = False
            with indent(4, quote=' '):
                for table in get_database_tables(s_db_conn):
                    t_r = table_has_primary_key(s_db_conn, table['schema'], table['table'])
                    if not t_r:
                        tables_without_unique = True
                        print
                        output_cli_message("Found %s.%s without primary key" % (table['schema'], table['table']))
                        result = add_table_unique_index(s_db_conn, table['schema'], table['table'])
                        print(output_cli_result(
                            colored.green('Added %s field' % get_unique_field_name()) if result else False,
                            compensation=4
                        ))

            if not tables_without_unique:
                print(output_cli_result(True)) 
開發者ID:rtshome,項目名稱:pgrepup,代碼行數:31,代碼來源:fix.py

示例13: main

# 需要導入模塊: from clint.textui import colored [as 別名]
# 或者: from clint.textui.colored import green [as 別名]
def main():
    puts(colored.green("Pgrepup %s" % __version__))
    try:
        dispatch(__doc__)
    except KeyboardInterrupt:
        puts("\n" + colored.red('Execution aborted'))
        exit(0) 
開發者ID:rtshome,項目名稱:pgrepup,代碼行數:9,代碼來源:cli.py

示例14: logOk

# 需要導入模塊: from clint.textui import colored [as 別名]
# 或者: from clint.textui.colored import green [as 別名]
def logOk(text):
    puts(colored.green(text)) 
開發者ID:nfd,項目名稱:spi-flash-programmer,代碼行數:4,代碼來源:spi_flash_programmer_client.py

示例15: add

# 需要導入模塊: from clint.textui import colored [as 別名]
# 或者: from clint.textui.colored import green [as 別名]
def add(lang):
    langs = getlangs(lang)
    puts(u"Adding %s" % ', '.join(langs))
    for loc in langs:
        with indent(2):
            puts(u"Generating PO for %s" % loc)
        shell_call(u"django-admin.py makemessages -l %(lang)s "
                   u"-e py,html,email,txt" % {'lang': loc})
        for app in I18N_APPS:
            with indent(4):
                puts(u"Generating PO for app %s" % app)
            with chdir(os.path.join(REPO_ROOT, app)):
                shell_call(u"django-admin.py makemessages "
                           u"-d djangojs -l %(lang)s" % {'lang': loc})
        puts(colored.green("sucesssfuly generated %s" % loc)) 
開發者ID:awemulya,項目名稱:kobo-predict,代碼行數:17,代碼來源:i18ntool.py


注:本文中的clint.textui.colored.green方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。