本文整理汇总了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)
示例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)
示例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'
示例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'
示例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)))
示例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))
示例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"))
示例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)))
示例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
示例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()
示例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
示例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))
示例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)
示例14: logOk
# 需要导入模块: from clint.textui import colored [as 别名]
# 或者: from clint.textui.colored import green [as 别名]
def logOk(text):
puts(colored.green(text))
示例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))