本文整理匯總了Python中click.clear方法的典型用法代碼示例。如果您正苦於以下問題:Python click.clear方法的具體用法?Python click.clear怎麽用?Python click.clear使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類click
的用法示例。
在下文中一共展示了click.clear方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: resources
# 需要導入模塊: import click [as 別名]
# 或者: from click import clear [as 別名]
def resources(cls, jobs_resources):
jobs_resources = to_list(jobs_resources)
click.clear()
data = [["Job", "Mem Usage / Total", "CPU% - CPUs"]]
for job_resources in jobs_resources:
job_resources = ContainerResourcesConfig.from_dict(job_resources)
line = [
job_resources.job_name,
"{} / {}".format(
to_unit_memory(job_resources.memory_used),
to_unit_memory(job_resources.memory_limit),
),
"{} - {}".format(
to_percentage(job_resources.cpu_percentage / 100),
job_resources.n_cpus,
),
]
data.append(line)
click.echo(tabulate(data, headers="firstrow"))
sys.stdout.flush()
示例2: search
# 需要導入模塊: import click [as 別名]
# 或者: from click import clear [as 別名]
def search(ctx, query, num, safe, filetype, imagetype,
imagesize, dominantcolor, download_path, width, height):
search_params = {
'q': query,
'num': num,
'safe': safe,
'fileType': filetype,
'imgType': imagetype,
'imgSize': imagesize,
'imgDominantColor': dominantcolor
}
click.clear()
try:
ctx.obj['object'].search(search_params, download_path, width, height)
for image in ctx.obj['object'].results():
click.echo(image.url)
if image.path:
click.secho(image.path, fg='blue')
if not image.resized:
click.secho('[image is not resized]', fg='red')
else:
click.secho('[image is not download]', fg='red')
click.echo()
except GoogleBackendException:
click.secho('Error occurred trying to fetch '
'images from Google. Please try again.', fg='red')
return
示例3: traverse_json
# 需要導入模塊: import click [as 別名]
# 或者: from click import clear [as 別名]
def traverse_json(data, previous=''):
click.clear()
keys = list(data.keys())
click.echo(create_table(keys, previous))
val = click.prompt("Select Option", type = int, default = 1) - 1
if type(data[keys[val]]) == dict:
traverse_json(data[keys[val]], keys[val])
else:
click.echo(f"Current value: {data[keys[val]]}")
newVal = click.prompt(f"Input new value for {keys[val]}", type = str)
#Normal strings cause an error
try:
newVal = eval(newVal)
except (SyntaxError, NameError) as e:
pass
if type(newVal) != type(data[keys[val]]):
choice = click.confirm(f"{newVal} appears to be of an incorrect type. Continue")
if not choice:
exit()
elif data[keys[val]] is not None:
try:
newVal = type(data[keys[val]])(newVal)
except TypeError:
click.echo(f"'{newVal}' could not be converted to the correct type")
exit()
data[keys[val]] = newVal
示例4: get_ansible_ssh_user
# 需要導入模塊: import click [as 別名]
# 或者: from click import clear [as 別名]
def get_ansible_ssh_user():
click.clear()
message = """
This installation process involves connecting to remote hosts via ssh. Any
account may be used. However, if a non-root account is used, then it must have
passwordless sudo access.
"""
click.echo(message)
return click.prompt('User for ssh access', default='root')
示例5: get_routingconfig_subdomain
# 需要導入模塊: import click [as 別名]
# 或者: from click import clear [as 別名]
def get_routingconfig_subdomain():
click.clear()
message = """
You might want to override the default subdomain used for exposed routes. If you don't know what this is, use the default value.
"""
click.echo(message)
return click.prompt('New default subdomain (ENTER for none)', default='')
示例6: collect_new_nodes
# 需要導入模塊: import click [as 別名]
# 或者: from click import clear [as 別名]
def collect_new_nodes(oo_cfg):
click.clear()
click.echo('*** New Node Configuration ***')
message = """
Add new nodes here
"""
click.echo(message)
new_nodes, _ = collect_hosts(oo_cfg, existing_env=True, masters_set=True, print_summary=False)
return new_nodes
示例7: initialise
# 需要導入模塊: import click [as 別名]
# 或者: from click import clear [as 別名]
def initialise():
click.clear()
click.secho("Enter the User access token", fg="green", bold=True)
token = input()
click.secho(
"Enter the no of result pages for your input.\nBy default it is set to 5.",
fg="green",
bold=True)
try:
val = int(input())
npa = val
except ValueError:
npa = 5
click.secho(
"Enter the no of posts in the output page.\nBy default it is set to 5.",
fg="green",
bold=True)
try:
val = int(input())
npo = val
except ValueError:
npo = 5
click.clear()
click.secho("Data initialised succesfully", fg="green", bold=True)
with open("userdata.json", "w") as outfile:
data = {'token': token, 'npa': npa, 'npo': npo}
json.dump(data, outfile)
# shows the data stored in userdata.json file
示例8: monitor
# 需要導入模塊: import click [as 別名]
# 或者: from click import clear [as 別名]
def monitor(app):
"""Set up application monitoring."""
heroku_app = HerokuApp(dallinger_uid=app)
webbrowser.open(heroku_app.dashboard_url)
webbrowser.open("https://requester.mturk.com/mturk/manageHITs")
heroku_app.open_logs()
check_call(["open", heroku_app.db_uri])
while _keep_running():
summary = get_summary(app)
click.clear()
click.echo(header)
click.echo("\nExperiment {}\n".format(app))
click.echo(summary)
time.sleep(10)
示例9: clear
# 需要導入模塊: import click [as 別名]
# 或者: from click import clear [as 別名]
def clear(ctx):
'''
Clears request, response and error fields.
'''
ctx.obj['manager'].rpcs[ctx.obj['RPC_TYPE']][ctx.obj['RPC_NAME']].clear()
示例10: details
# 需要導入模塊: import click [as 別名]
# 或者: from click import clear [as 別名]
def details(name):
"""
Get details of a domain
"""
_display_domain_details(details_domain(name), clear=False)
示例11: _display_domain_details
# 需要導入模塊: import click [as 別名]
# 或者: from click import clear [as 別名]
def _display_domain_details(domain_details, clear=True):
if clear:
click.clear()
click.echo('Domain: {}'.format(format_text(domain_details['name'], TextStyle.HEADER)))
if domain_details['verified'] is True:
click.echo('\tVerified: {}'.format(format_text("Yes", TextStyle.OKGREEN)))
else:
click.echo('\tVerified: {}'.format(format_text("Yes", TextStyle.FAIL)))
if domain_details.get('certificate', None) is None:
click.echo("\tCertificate: {}".format(format_text("Not requested", TextStyle.OKBLUE)))
else:
certificate_details = domain_details['certificate'].get('details')
status = certificate_details['status']
if status == 'PENDING':
click.echo("\tCertificate: {}".format(format_text('Trying to get a certificate', TextStyle.OKBLUE)))
elif status == 'ERROR':
click.echo("\tCertificate: {}".format(format_text('Getting certificate failed', TextStyle.FAIL)))
elif status == 'READY':
click.echo("\tCertificate: {}".format(format_text('Certificate is ready to use', TextStyle.OKGREEN)))
else:
click.echo('\tCertificate: {}'.format(format_text('Certificate status is unknown', TextStyle.WARNING)))
info = certificate_details.get("info", False)
if info:
click.echo('\tInfo: {}'.format(format_text(info, TextStyle.WARNING)))
if len(certificate_details.get('events', [])) > 0:
click.echo("\tEvents:")
for condition in certificate_details.get("events", []):
click.echo("\t + {}".format(condition))
示例12: resources
# 需要導入模塊: import click [as 別名]
# 或者: from click import clear [as 別名]
def resources(cls, jobs_resources):
jobs_resources = to_list(jobs_resources)
click.clear()
data = [['Job', 'Mem Usage / Total', 'CPU% - CPUs']]
for job_resources in jobs_resources:
job_resources = ContainerResourcesConfig.from_dict(job_resources)
line = [
job_resources.job_name,
'{} / {}'.format(to_unit_memory(job_resources.memory_used),
to_unit_memory(job_resources.memory_limit)),
'{} - {}'.format(to_percentage(job_resources.cpu_percentage / 100),
job_resources.n_cpus)]
data.append(line)
click.echo(tabulate(data, headers="firstrow"))
sys.stdout.flush()
示例13: gpu_resources
# 需要導入模塊: import click [as 別名]
# 或者: from click import clear [as 別名]
def gpu_resources(cls, jobs_resources):
jobs_resources = to_list(jobs_resources)
click.clear()
data = [
['job_name', 'name', 'GPU Usage', 'GPU Mem Usage / Total', 'GPU Temperature',
'Power Draw / Limit']
]
non_gpu_jobs = 0
for job_resources in jobs_resources:
job_resources = ContainerResourcesConfig.from_dict(job_resources)
line = []
if not job_resources.gpu_resources:
non_gpu_jobs += 1
continue
for gpu_resources in job_resources.gpu_resources:
line += [
job_resources.job_name,
gpu_resources.name,
to_percentage(gpu_resources.utilization_gpu / 100),
'{} / {}'.format(
to_unit_memory(gpu_resources.memory_used),
to_unit_memory(gpu_resources.memory_total)),
gpu_resources.temperature_gpu,
'{} / {}'.format(gpu_resources.power_draw, gpu_resources.power_limit),
]
data.append(line)
if non_gpu_jobs == len(jobs_resources):
Printer.print_error(
'No GPU job was found, please run `resources` command without `-g | --gpu` option.')
exit(1)
click.echo(tabulate(data, headers="firstrow"))
sys.stdout.flush()
示例14: optimize_mode
# 需要導入模塊: import click [as 別名]
# 或者: from click import clear [as 別名]
def optimize_mode(start_date: str, finish_date: str):
# clear the screen
click.clear()
print('loading candles...')
click.clear()
# load historical candles and divide them into training
# and testing candles (15% for test, 85% for training)
training_candles, testing_candles = get_training_and_testing_candles(start_date, finish_date)
optimizer = Optimizer(training_candles, testing_candles)
optimizer.run()
# TODO: store hyper parameters into each strategies folder per each Exchange-symbol-timeframe
示例15: clear
# 需要導入模塊: import click [as 別名]
# 或者: from click import clear [as 別名]
def clear(self):
click.clear()