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


Python click.Abort方法代码示例

本文整理汇总了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 
开发者ID:microsoft,项目名称:agogosml,代码行数:19,代码来源:init.py

示例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 
开发者ID:dcs4cop,项目名称:xcube,代码行数:20,代码来源:common.py

示例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() 
开发者ID:alephdata,项目名称:followthemoney,代码行数:23,代码来源:mapping.py

示例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) 
开发者ID:anchore,项目名称:anchore-cli,代码行数:27,代码来源:policy.py

示例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) 
开发者ID:msanders,项目名称:cider,代码行数:27,代码来源:_cli.py

示例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")),
            )
        ) 
开发者ID:Clinical-Genomics,项目名称:scout,代码行数:22,代码来源:panels.py

示例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() 
开发者ID:Clinical-Genomics,项目名称:scout,代码行数:20,代码来源:compounds.py

示例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) 
开发者ID:Clinical-Genomics,项目名称:scout,代码行数:26,代码来源:panel.py

示例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])) 
开发者ID:Clinical-Genomics,项目名称:scout,代码行数:18,代码来源:hpo.py

示例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)) 
开发者ID:SUSE,项目名称:sesdev,代码行数:25,代码来源:__init__.py

示例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) 
开发者ID:SUSE,项目名称:sesdev,代码行数:21,代码来源:__init__.py

示例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\".") 
开发者ID:vividvilla,项目名称:csvtotable,代码行数:25,代码来源:cli.py

示例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 
开发者ID:roscisz,项目名称:TensorHive,代码行数:18,代码来源:AccountCreator.py

示例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 
开发者ID:roscisz,项目名称:TensorHive,代码行数:22,代码来源:AccountCreator.py

示例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 
开发者ID:benjmarshall,项目名称:hlsclt,代码行数:21,代码来源:build_commands.py


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