本文整理匯總了Python中click.Abort方法的典型用法代碼示例。如果您正苦於以下問題:Python click.Abort方法的具體用法?Python click.Abort怎麽用?Python click.Abort使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類click
的用法示例。
在下文中一共展示了click.Abort方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: init
# 需要導入模塊: import click [as 別名]
# 或者: from click import Abort [as 別名]
def init(force, project_name, cloud_vendor, folder) -> int:
"""Initializes an agogosml project by creating a manifest file"""
# Check if exists
folder = Path(folder)
outfile = folder / 'manifest.json'
if outfile.is_file():
if force:
click.echo('Overwriting %s' % outfile)
else:
click.echo('Manifest already exists. Use --force to overwrite')
raise click.Abort()
# Create folder if not exists
outfile.parent.mkdir(parents=True, exist_ok=True)
manifest = build_manifest(project_name, cloud_vendor)
with outfile.open('w') as fobj:
json.dump(manifest, fobj, indent=4)
return 0
示例2: handle_cli_exception
# 需要導入模塊: import click [as 別名]
# 或者: from click import Abort [as 別名]
def handle_cli_exception(e: BaseException, exit_code: int = None, traceback_mode: bool = False) -> int:
import sys
if isinstance(e, click.Abort):
print(f'Aborted!')
exit_code = exit_code or 1
elif isinstance(e, click.ClickException):
e.show(file=sys.stderr)
exit_code = exit_code or e.exit_code
elif isinstance(e, OSError):
print(f'OS error: {e}', file=sys.stderr)
exit_code = exit_code or 2
else:
print(f'Internal error: {e}', file=sys.stderr)
exit_code = exit_code or 3
if traceback_mode:
import traceback
traceback.print_exc(file=sys.stderr)
return exit_code
示例3: stream_mapping
# 需要導入模塊: import click [as 別名]
# 或者: from click import Abort [as 別名]
def stream_mapping(infile, outfile, mapping_yaml, sign=True):
sources = []
config = load_mapping_file(mapping_yaml)
for dataset, meta in config.items():
for data in keys_values(meta, 'queries', 'query'):
query = model.make_mapping(data, key_prefix=dataset)
source = StreamSource(query, data)
sources.append((dataset, source))
try:
for record in StreamSource.read_csv(infile):
for (dataset, source) in sources:
ns = Namespace(dataset)
if source.check_filters(record):
entities = source.query.map(record)
for entity in entities.values():
if sign:
entity = ns.apply(entity)
write_object(outfile, entity)
except BrokenPipeError:
raise click.Abort()
示例4: describe
# 需要導入模塊: import click [as 別名]
# 或者: from click import Abort [as 別名]
def describe(all=False, gate=None, trigger=None):
ecode = 0
try:
ret = anchorecli.clients.apiexternal.describe_policy_spec(config)
if ret['success']:
render_payload = ret['payload']
if not gate and not trigger:
print(anchorecli.cli.utils.format_output(config, 'describe_gates', {'all': all}, render_payload))
elif gate and not trigger:
print(anchorecli.cli.utils.format_output(config, 'describe_gate_triggers', {'gate': gate, 'all': all}, render_payload))
elif gate and trigger:
print(anchorecli.cli.utils.format_output(config, 'describe_gate_trigger_params', {'gate': gate, 'trigger': trigger, 'all': all}, render_payload))
else:
raise click.Abort('Trigger can only be specified with --gate as well')
else:
raise Exception(json.dumps(ret['error'], indent=4))
except Exception as err:
print(anchorecli.cli.utils.format_error_output(config, 'describe_policy', {}, err))
if not ecode:
ecode = 2
anchorecli.cli.utils.doexit(ecode)
示例5: main
# 需要導入模塊: import click [as 別名]
# 或者: from click import Abort [as 別名]
def main():
try:
cli.main(standalone_mode=False)
except CalledProcessError as e:
tty.puterr("`{0}` failed with code {1}".format(
" ".join(e.cmd),
e.returncode
))
except ParserError as e:
tty.puterr("Error reading {0} at {1}: {2}".format(
e.filetype,
e.filepath,
e
))
except BrewMissingError as e:
print("Next, install Homebrew (press any key to redirect)")
click.getchar()
urlopen(e.url)
sys.exit(1)
except (CiderException, click.ClickException) as e:
tty.puterr(e, prefix="Error:")
sys.exit(e.exit_code)
except click.Abort:
sys.stderr.write("Aborted!\n")
sys.exit(1)
示例6: panels
# 需要導入模塊: import click [as 別名]
# 或者: from click import Abort [as 別名]
def panels(institute):
"""Show all gene panels in the database"""
LOG.info("Running scout view panels")
adapter = store
panel_objs = [panel for panel in adapter.gene_panels(institute_id=institute)]
if len(panel_objs) == 0:
LOG.info("No panels found")
raise click.Abort()
click.echo("#panel_name\tversion\tnr_genes\tdate")
for panel_obj in panel_objs:
click.echo(
"{0}\t{1}\t{2}\t{3}".format(
panel_obj["panel_name"],
str(panel_obj["version"]),
len(panel_obj["genes"]),
str(panel_obj["date"].strftime("%Y-%m-%d")),
)
)
示例7: compounds
# 需要導入模塊: import click [as 別名]
# 或者: from click import Abort [as 別名]
def compounds(case_id):
"""
Update all compounds for a case
"""
adapter = store
LOG.info("Running scout update compounds")
# Check if the case exists
case_obj = adapter.case(case_id)
if not case_obj:
LOG.warning("Case %s could not be found", case_id)
raise click.Abort()
try:
adapter.update_case_compounds(case_obj)
except Exception as err:
LOG.warning(err)
raise click.Abort()
示例8: panel
# 需要導入模塊: import click [as 別名]
# 或者: from click import Abort [as 別名]
def panel(panel, build, bed, version):
"""Export gene panels to .bed like format.
Specify any number of panels on the command line
"""
LOG.info("Running scout export panel")
adapter = store
# Save all chromosomes found in the collection if panels
chromosomes_found = set()
if not panel:
LOG.warning("Please provide at least one gene panel")
raise click.Abort()
LOG.info("Exporting panels: {}".format(", ".join(panel)))
if bed:
if version:
version = [version]
lines = export_panels(adapter=adapter, panels=panel, versions=version, build=build)
else:
lines = export_gene_panels(adapter=adapter, panels=panel, version=version)
for line in lines:
click.echo(line)
示例9: hpo_genes
# 需要導入模塊: import click [as 別名]
# 或者: from click import Abort [as 別名]
def hpo_genes(hpo_term):
"""Export a list of genes based on hpo terms"""
LOG.info("Running scout export hpo_genes")
adapter = store
header = ["#Gene_id\tCount"]
if not hpo_term:
LOG.warning("Please use at least one hpo term")
raise click.Abort()
for line in header:
click.echo(line)
for term in adapter.generate_hpo_gene_list(*hpo_term):
click.echo("{0}\t{1}".format(term[0], term[1]))
示例10: destroy
# 需要導入模塊: import click [as 別名]
# 或者: from click import Abort [as 別名]
def destroy(deployment_id, **kwargs):
"""
Destroys the deployment(s) named DEPLOYMENT_SPEC -- where DEPLOYMENT_SPEC might
be either a literal deployment ID or a glob ("octopus_*") -- by destroying the
VMs and deleting the deployment directory.
"""
interactive = not (kwargs.get('non_interactive', False) or kwargs.get('force', False))
destroy_networks = kwargs.get('destroy_networks', False)
matching_deployments = _maybe_glob_deps(deployment_id)
cluster_word = _cluster_singular_or_plural(matching_deployments)
if interactive:
really_want_to = click.confirm(
'Do you really want to destroy {} {}'.format(len(matching_deployments), cluster_word),
default=True,
)
if not really_want_to:
raise click.Abort()
for dep in matching_deployments:
logger.debug("destroy deployment: '%s', destroy networks: %s",
deployment_id,
destroy_networks)
dep.destroy(_print_log, destroy_networks)
click.echo("Deployment {} destroyed!".format(dep.dep_id))
示例11: redeploy
# 需要導入模塊: import click [as 別名]
# 或者: from click import Abort [as 別名]
def redeploy(deployment_id, **kwargs):
"""
Destroys the VMs of the deployment DEPLOYMENT_ID and deploys again the cluster
from scratch with the same configuration.
"""
interactive = not (kwargs.get('non_interactive', False) or kwargs.get('force', False))
if interactive:
really_want_to = True
if interactive:
really_want_to = click.confirm(
'Do you want to continue with the deployment?',
default=True,
)
if not really_want_to:
raise click.Abort()
dep = Deployment.load(deployment_id)
dep.destroy(_print_log)
dep = Deployment.create(deployment_id, dep.settings)
dep.start(_print_log)
示例12: cli
# 需要導入模塊: import click [as 別名]
# 或者: from click import Abort [as 別名]
def cli(*args, **kwargs):
"""
CSVtoTable commandline utility.
"""
# Convert CSV file
content = convert.convert(kwargs["input_file"], **kwargs)
# Serve the temporary file in browser.
if kwargs["serve"]:
convert.serve(content)
# Write to output file
elif kwargs["output_file"]:
# Check if file can be overwrite
if (not kwargs["overwrite"] and
not prompt_overwrite(kwargs["output_file"])):
raise click.Abort()
convert.save(kwargs["output_file"], content)
click.secho("File converted successfully: {}".format(
kwargs["output_file"]), fg="green")
else:
# If its not server and output file is missing then raise error
raise click.BadOptionUsage("Missing argument \"output_file\".")
示例13: _ask_for_username
# 需要導入模塊: import click [as 別名]
# 或者: from click import Abort [as 別名]
def _ask_for_username(self):
'''
Process is repeated until username becomes valid.
If so, it assignes the vaule to the ORM object.
'''
valid_username_provided = False
while not valid_username_provided:
try:
username = click.prompt('[1/4] UNIX username', type=str)
self.new_user.username = username
except click.Abort:
raise
except Exception as e:
click.echo('Invalid username: {reason}.'.format(reason=e))
else:
valid_username_provided = True
示例14: _ask_for_password
# 需要導入模塊: import click [as 別名]
# 或者: from click import Abort [as 別名]
def _ask_for_password(self):
# Useful aliases
prompt_for_password = lambda message: click.prompt(message, type=str, hide_input=True)
password_length_requirement = 'at least {} characters'.format(self.new_user.min_password_length)
first_password_message = '[3/4] password ({})'.format(password_length_requirement)
repeated_password_message = '[3/4] repeat password'
valid_password_provided = False
while not valid_password_provided:
try:
password1 = prompt_for_password(message=first_password_message)
self.new_user.password = password1
password2 = prompt_for_password(message=repeated_password_message)
assert password1 == password2, 'Passwords don\'t match, please try again.'
except click.Abort:
raise
except Exception as error_msg:
click.echo(str(error_msg))
else:
valid_password_provided = True
示例15: build_end_callback
# 需要導入模塊: import click [as 別名]
# 或者: from click import Abort [as 別名]
def build_end_callback(ctx,sub_command_returns,keep,report):
# Catch the case where no subcommands have been issued and offer a default build
if not sub_command_returns:
if click.confirm("No build stages specified, would you like to run a default sequence using all the build stages?", abort=True):
do_default_build(ctx)
ctx.obj.file.write("exit" + "\n")
ctx.obj.file.close()
# Call the Vivado HLS process
returncode = subprocess.call(["vivado_hls -f run_hls.tcl"],shell=True)
# Check return status of the HLS process.
if returncode < 0:
raise click.Abort()
elif returncode > 0:
click.echo("Warning: HLS Process returned an error, skipping report opening!")
raise click.Abort()
else:
do_end_build_stuff(ctx,sub_command_returns,report)
# csim subcommand