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


Python click.confirm方法代码示例

本文整理汇总了Python中click.confirm方法的典型用法代码示例。如果您正苦于以下问题:Python click.confirm方法的具体用法?Python click.confirm怎么用?Python click.confirm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在click的用法示例。


在下文中一共展示了click.confirm方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: save

# 需要导入模块: import click [as 别名]
# 或者: from click import confirm [as 别名]
def save(settings, path):
    cst = setup_cast(settings["device"], prep="control")
    if not cst.save_capability or cst.is_streaming_local_file:
        raise CliError("Saving state of this kind of content is not supported")
    elif cst.save_capability == "partial":
        echo_warning("Please be advised that playlist data will not be saved")

    echo_status(cst.media_info)
    if path and path.is_file():
        click.confirm("File already exists. Overwrite?", abort=True)
    click.echo("Saving...")
    if path:
        state = CastState(path, StateMode.ARBI)
        cc_name = "*"
    else:
        state = CastState(STATE_PATH, StateMode.CONF)
        cc_name = cst.cc_name
    state.set_data(cc_name, {"controller": cst.name, "data": cst.media_info}) 
开发者ID:skorokithakis,项目名称:catt,代码行数:20,代码来源:cli.py

示例2: remove

# 需要导入模块: import click [as 别名]
# 或者: from click import confirm [as 别名]
def remove(watson, id, force):
    """
    Remove a frame. You can specify the frame either by id or by position
    (ex: `-1` for the last frame).
    """
    frame = get_frame_from_argument(watson, id)
    id = frame.id

    if not force:
        click.confirm(
            u"You are about to remove frame "
            u"{project}{tags} from {start} to {stop}, continue?".format(
                project=style('project', frame.project),
                tags=(" " if frame.tags else "") + style('tags', frame.tags),
                start=style('time', '{:HH:mm}'.format(frame.start)),
                stop=style('time', '{:HH:mm}'.format(frame.stop))
            ),
            abort=True
        )

    del watson.frames[id]

    watson.save()
    click.echo("Frame removed.") 
开发者ID:TailorDev,项目名称:Watson,代码行数:26,代码来源:cli.py

示例3: nmap

# 需要导入模块: import click [as 别名]
# 或者: from click import confirm [as 别名]
def nmap():
    try:
        project_config = VcmProjectConfig()
        project_config.read_project_vcm()
    except ValueError as ex:
        print(ex)
        return

    # We only need the netloc of the full url - strip the rest out
    nmap_targets = []
    for t in project_config.targets:
        nmap_targets.append(urlparse(t).netloc)

    if not click.confirm('Run nmap against the following targets: %s' % ', '.join(nmap_targets)):
        return

    args = ["nmap"]
    args.extend(DEFAULT_NMAP_SETTINGS)

    for t in nmap_targets:
        args.append(t)

    args.append("-oA")
    args.append(os.path.join(project_config.artifacts_folder, f'nmap_{time.time()}'))
    call(args) 
开发者ID:willasaywhat,项目名称:vcm,代码行数:27,代码来源:vcm.py

示例4: nikto

# 需要导入模块: import click [as 别名]
# 或者: from click import confirm [as 别名]
def nikto():
    try:
        project_config = VcmProjectConfig()
        project_config.read_project_vcm()
    except ValueError as ex:
        print(ex)
        return

    if not click.confirm('Run nikto against the following targets: %s' % ', '.join(project_config.targets)):
        return

    # Nikto takes multiple hosts from a file
    # BUT bear in mind advice from: https://github.com/sullo/nikto/wiki/Basic-Testing
    # ie run scans separately so that memory is freed each time.
    for t in project_config.targets:
        output_filename = os.path.join(project_config.artifacts_folder,
                                       f"nikto_{urlparse(t).netloc}_{time.time()}.html")
        try:
            # nikto -h https://www.test.com -ssl -Format html -output .
            args = ["nikto", "-h", t, '-ssl', '-Format', 'html', '-output', output_filename]

            print(args)
            call(args)
        except Exception as ex:
            print(f"Error writing nikto output to: {output_filename} : {ex}") 
开发者ID:willasaywhat,项目名称:vcm,代码行数:27,代码来源:vcm.py

示例5: stop

# 需要导入模块: import click [as 别名]
# 或者: from click import confirm [as 别名]
def stop(id):
    """
    Stop a running job.
    """
    try:
        experiment = ExperimentClient().get(normalize_job_name(id))
    except FloydException:
        experiment = ExperimentClient().get(id)

    if experiment.state not in ["queued", "queue_scheduled", "running"]:
        floyd_logger.info("Job in {} state cannot be stopped".format(experiment.state))
        sys.exit(1)

    if not ExperimentClient().stop(experiment.id):
        floyd_logger.error("Failed to stop job")
        sys.exit(1)

    floyd_logger.info("Experiment shutdown request submitted. Check status to confirm shutdown") 
开发者ID:floydhub,项目名称:floyd-cli,代码行数:20,代码来源:experiment.py

示例6: index_json

# 需要导入模块: import click [as 别名]
# 或者: from click import confirm [as 别名]
def index_json(filenames, force):
    """Index JSON-based vocabularies in Elasticsearch."""
    if not force:
        click.confirm(
            "Are you sure you want to index the vocabularies?",
            abort=True
        )
    source = "json"
    index_count = 0
    for filename in filenames:
        click.echo('indexing vocabularies in {}...'.format(filename))
        vocabularies = load_vocabularies(source, filename)
        cfg = current_app.config["RECORDS_REST_ENDPOINTS"][VOCABULARY_PID_TYPE]
        indexer = cfg["indexer_class"]()
        with click.progressbar(vocabularies) as bar:
            for vocabulary in bar:
                indexer.index(vocabulary)
        index_count += len(vocabularies)
    click.echo('indexed {} vocabularies'.format(index_count)) 
开发者ID:inveniosoftware,项目名称:invenio-app-ils,代码行数:21,代码来源:cli.py

示例7: index_opendefinition

# 需要导入模块: import click [as 别名]
# 或者: from click import confirm [as 别名]
def index_opendefinition(loader, path, whitelist_status, force):
    """Index JSON-based vocabularies in Elasticsearch."""
    if not force:
        click.confirm(
            "Are you sure you want to index the vocabularies?",
            abort=True
        )
    index_count = 0
    click.echo('indexing licenses from loader {} and path {}...'.format(
        loader,
        path
    ))
    if whitelist_status:
        whitelist_status = whitelist_status.split(",")
    vocabularies = load_vocabularies(
        "opendefinition", loader, path, whitelist_status
    )
    cfg = current_app.config["RECORDS_REST_ENDPOINTS"][VOCABULARY_PID_TYPE]
    indexer = cfg["indexer_class"]()
    with click.progressbar(vocabularies) as bar:
        for vocabulary in bar:
            indexer.index(vocabulary)
    index_count += len(vocabularies)
    click.echo('indexed {} licenses'.format(index_count)) 
开发者ID:inveniosoftware,项目名称:invenio-app-ils,代码行数:26,代码来源:cli.py

示例8: delete

# 需要导入模块: import click [as 别名]
# 或者: from click import confirm [as 别名]
def delete(type, force, key):
    """Delete indexed vocabularies."""
    count = delete_vocabulary_from_index(type=type, force=force, key=key)

    if not force:
        if count == 0:
            click.secho("No vocabularies found. Exiting.")
            exit(1)
        if click.confirm(
            "You are about to delete {} vocabularies of type '{}'. "
            "Do you want to continue?".format(count, type),
            abort=True
        ):
            count = delete_vocabulary_from_index(
                type=type, force=True, key=key)

    click.echo('deleted {} vocabularies'.format(count)) 
开发者ID:inveniosoftware,项目名称:invenio-app-ils,代码行数:19,代码来源:cli.py

示例9: setUpClass

# 需要导入模块: import click [as 别名]
# 或者: from click import confirm [as 别名]
def setUpClass(cls):
        if cls.portToUse is None:
            try:
                cls.portToUse = CompilerUploader.construct(cls.__get_platform_to_use()).get_port()
            except:
                cls.portToUse = -1
        cls.platform_to_use = cls.__get_platform_to_use()
        log.info("""\n\n
        #######################################
        Remember to connect a {} board
        #######################################\n""".format(cls.platform_to_use))

        def click_confirm(message):
            print message
            return True

        click.confirm = click_confirm 
开发者ID:bq,项目名称:web2board,代码行数:19,代码来源:testCompilerUploader.py

示例10: _autoinstall_libs

# 需要导入模块: import click [as 别名]
# 或者: from click import confirm [as 别名]
def _autoinstall_libs(ctx, libids_list):
    require_libs = [int(l.strip()) for l in libids_list.split(",")]
    installed_libs = [
        l['id'] for l in LibraryManager().get_installed().values()
    ]

    not_intalled_libs = set(require_libs) - set(installed_libs)
    if not require_libs or not not_intalled_libs:
        return

    if (not app.get_setting("enable_prompts") or
            click.confirm(
                "The libraries with IDs '%s' have not been installed yet. "
                "Would you like to install them now?" %
                ", ".join([str(i) for i in not_intalled_libs])
            )):
        ctx.invoke(cmd_lib_install, libid=not_intalled_libs) 
开发者ID:bq,项目名称:web2board,代码行数:19,代码来源:run.py

示例11: follow

# 需要导入模块: import click [as 别名]
# 或者: from click import confirm [as 别名]
def follow(ctx, nick, url, force):
    """Add a new source to your followings."""
    source = Source(nick, url)
    sources = ctx.obj['conf'].following

    if not force:
        if source.nick in (source.nick for source in sources):
            click.confirm("➤ You’re already following {0}. Overwrite?".format(
                click.style(source.nick, bold=True)), default=False, abort=True)

        _, status = get_remote_status([source])[0]
        if not status or status.status_code != 200:
            click.confirm("➤ The feed of {0} at {1} is not available. Follow anyway?".format(
                click.style(source.nick, bold=True),
                click.style(source.url, bold=True)), default=False, abort=True)

    ctx.obj['conf'].add_source(source)
    click.echo("✓ You’re now following {0}.".format(
        click.style(source.nick, bold=True))) 
开发者ID:buckket,项目名称:twtxt,代码行数:21,代码来源:cli.py

示例12: validate_text

# 需要导入模块: import click [as 别名]
# 或者: from click import confirm [as 别名]
def validate_text(ctx, param, value):
    conf = click.get_current_context().obj["conf"]
    if isinstance(value, tuple):
        value = " ".join(value)

    if not value and not sys.stdin.isatty():
        value = click.get_text_stream("stdin").read()

    if value:
        value = value.strip()
        if conf.character_warning and len(value) > conf.character_warning:
            click.confirm("✂ Warning: Tweet is longer than {0} characters. Are you sure?".format(
                conf.character_warning), abort=True)
        return value
    else:
        raise click.BadArgumentUsage("Text can’t be empty.") 
开发者ID:buckket,项目名称:twtxt,代码行数:18,代码来源:helper.py

示例13: do_tag

# 需要导入模块: import click [as 别名]
# 或者: from click import confirm [as 别名]
def do_tag(config, force, src, requirement, yes, dry_run=False):
    tag = config.version
    if not yes:
        click.confirm("Tag project with {}?".format(tag), abort=True)
    if force:
        force_cmd = ["-f"]
    else:
        force_cmd = []
    if call(["git", "diff", "--exit-code"]) != 0:
        raise click.ClickException("Please commit first.")
    if call(["git", "diff", "--exit-code", "--cached"]) != 0:
        raise click.ClickException("Please commit first.")
    out = check_output(
        ["git", "ls-files", "--other", "--exclude-standard", "--directory"]
    )
    if out:
        click.echo(out)
        raise click.ClickException("Please commit first.")
    do_tag_requirements(config, src, requirement, yes=True, dry_run=dry_run)
    click.echo("placing tag {tag} on origin".format(**locals()))
    if not dry_run:
        check_call(["git", "tag"] + force_cmd + [tag])
        check_call(["git", "push", "-q"] + force_cmd + ["origin", "tag", tag]) 
开发者ID:acsone,项目名称:acsoo,代码行数:25,代码来源:tag.py

示例14: apply

# 需要导入模块: import click [as 别名]
# 或者: from click import confirm [as 别名]
def apply(config_file, var, only, dry_run, yes, debug, force):
    global_config.debug = debug
    provided_variables = get_variables(var)
    if not config_file:
        config_file = detect_yml_file("dcos")
    runner = DeploymentRunner(config_file, provided_variables)
    if only:
        if runner.partial_dry_run(only, force=force) and not dry_run:
            if yes or click.confirm("Do you want to apply these changes?", default=False):
                runner.run_partial_deployment(only, force=force)
            else:
                echo("Not doing anything")
    else:
        if runner.dry_run() and not dry_run:
            if yes or click.confirm("Do you want to apply these changes?", default=False):
                runner.run_deployment(force=force)
            else:
                echo("Not doing anything") 
开发者ID:MaibornWolff,项目名称:dcos-deploy,代码行数:20,代码来源:apply.py

示例15: delete

# 需要导入模块: import click [as 别名]
# 或者: from click import confirm [as 别名]
def delete(config_file, var, only, dry_run, yes):
    provided_variables = get_variables(var)
    if not config_file:
        config_file = detect_yml_file("dcos")
    runner = DeletionRunner(config_file, provided_variables)
    if only:
        if runner.partial_dry_run(only) and not dry_run:
            if yes or click.confirm("Do you want to apply these changes?", default=False):
                runner.run_partial_deletion(only)
            else:
                echo("Not doing anything")
    else:
        if runner.dry_run() and not dry_run:
            if yes or click.confirm("Do you want to apply these changes?", default=False):
                runner.run_deletion()
            else:
                echo("Not doing anything") 
开发者ID:MaibornWolff,项目名称:dcos-deploy,代码行数:19,代码来源:delete.py


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