How to use the click.echo function in click

To help you get started, we’ve selected a few click examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github oracle / oci-cli / services / streaming / src / oci_cli_stream_admin / generated / streamadmin_cli.py View on Github external
# will result in an exception that reflects a HTTP 404. In this case, we can exit with success (rather than raising
                # the exception) since this would have been the behaviour in the waiter anyway (as for delete we provide the argument
                # succeed_on_not_found=True to the waiter).
                #
                # Any non-404 should still result in the exception being thrown.
                if e.status == 404:
                    pass
                else:
                    raise
            except oci.exceptions.MaximumWaitTimeExceeded as e:
                # If we fail, we should show an error, but we should still provide the information to the customer
                click.echo('Failed to wait until the resource entered the specified state. Please retrieve the resource to find its current state', file=sys.stderr)
                cli_util.render_response(result, ctx)
                sys.exit(2)
            except Exception:
                click.echo('Encountered error while waiting for resource to enter the specified state. Outputting last known resource state', file=sys.stderr)
                cli_util.render_response(result, ctx)
                raise
        else:
            click.echo('Unable to wait for the resource to enter the specified state', file=sys.stderr)
    cli_util.render_response(result, ctx)
github polyaxon / polyaxon / polyaxon / cli / tensorboard.py View on Github external
"""
    user, project_name = get_project_or_local(ctx.obj.get("project"))
    group = ctx.obj.get("group")
    experiment = ctx.obj.get("experiment")

    if experiment:
        obj = "experiment `{}`".format(experiment)
    elif group:
        obj = "group `{}`".format(group)
    else:
        obj = "project `{}/{}`".format(user, project_name)

    if not yes and not click.confirm(
        "Are sure you want to stop tensorboard " "for {}".format(obj)
    ):
        click.echo("Existing without stopping tensorboard.")
        sys.exit(1)

    if experiment:
        try:
            PolyaxonClient().experiment.stop_tensorboard(
                username=user, project_name=project_name, experiment_id=experiment
            )
            Printer.print_success("Tensorboard is being deleted")
        except (
            PolyaxonHTTPError,
            PolyaxonShouldExitError,
            PolyaxonClientException,
        ) as e:
            Printer.print_error("Could not stop tensorboard {}.".format(obj))
            Printer.print_error("Error message `{}`.".format(e))
            sys.exit(1)
github ShahriyarR / MySQL-AutoXtraBackup / autoxtrabackup.py View on Github external
def print_version(ctx, param, value):
    if not value or ctx.resilient_parsing:
        return
    click.echo(
        "Developed by Shahriyar Rzayev from Azerbaijan MUG(http://mysql.az)")
    click.echo("Link : https://github.com/ShahriyarR/MySQL-AutoXtraBackup")
    click.echo("Email: rzayev.shahriyar@yandex.com")
    click.echo(
        "Based on Percona XtraBackup: https://github.com/percona/percona-xtrabackup/")
    click.echo('MySQL-AutoXtraBackup Version: 1.5.5')
    ctx.exit()
github SFDO-Tooling / CumulusCI / cumulusci / cli / cci.py View on Github external
except ScratchOrgException as e:
            exception = click.ClickException(
                'ScratchOrgException: {}'.format(e.message)
            )
            handle_exception_debug(config, debug, e, throw_exception=exception)
        except Exception as e:
            handle_exception_debug(config, debug, e, no_prompt=no_prompt)

    # Delete the scratch org if --delete-org was set
    if delete_org:
        try:
            org_config.delete_org()
        except Exception as e:
            click.echo(
                'Scratch org deletion failed.  Ignoring the error below to complete the flow:')
            click.echo(e.message)

    if exception:
        handle_sentry_event(config, no_prompt)
        raise exception
github oracle / oci-cli / src / oci_cli / generated / database_cli.py View on Github external
client = cli_util.build_client('database', ctx)
    result = client.update_db_system(
        db_system_id=db_system_id,
        update_db_system_details=details,
        **kwargs
    )
    if wait_for_state:
        if hasattr(client, 'get_db_system') and callable(getattr(client, 'get_db_system')):
            try:
                wait_period_kwargs = {}
                if max_wait_seconds is not None:
                    wait_period_kwargs['max_wait_seconds'] = max_wait_seconds
                if wait_interval_seconds is not None:
                    wait_period_kwargs['max_interval_seconds'] = wait_interval_seconds

                click.echo('Action completed. Waiting until the resource has entered state: {}'.format(wait_for_state), file=sys.stderr)
                result = oci.wait_until(client, client.get_db_system(result.data.id), 'lifecycle_state', wait_for_state, **wait_period_kwargs)
            except Exception as e:
                # If we fail, we should show an error, but we should still provide the information to the customer
                click.echo('Failed to wait until the resource entered the specified state. Outputting last known resource state', file=sys.stderr)
        else:
            click.echo('Unable to wait for the resource to enter the specified state', file=sys.stderr)
    cli_util.render_response(result, ctx)
github dataletsch / dribdat / dribdat / commands.py View on Github external
def clean():
    """Remove *.pyc and *.pyo files recursively starting at current directory.

    Borrowed from Flask-Script, converted to use Click.
    """
    for dirpath, dirnames, filenames in os.walk('.'):
        for filename in filenames:
            if filename.endswith('.pyc') or filename.endswith('.pyo'):
                full_pathname = os.path.join(dirpath, filename)
                click.echo('Removing {}'.format(full_pathname))
                os.remove(full_pathname)
github SamSchott / maestral-dropbox / maestral / cli.py View on Github external
def account_info(config_name: str, running: bool):
    """Prints your Dropbox account information."""

    if _is_maestral_linked(config_name):
        from maestral.config.main import CONF
        email = CONF.get("account", "email")
        account_type = CONF.get("account", "type").capitalize()
        usage = CONF.get("account", "usage")
        path = CONF.get("main", "path")
        click.echo("")
        click.echo("Email:             {}".format(email))
        click.echo("Account-type:      {}".format(account_type))
        click.echo("Usage:             {}".format(usage))
        click.echo("Dropbox location:  '{}'".format(path))
        click.echo("")
github steemit / sbds / contrib / blockr.py View on Github external
def put_ops(ctx, steemd_url, start, end):
    s3_resource = ctx.obj['s3_resource']
    bucket = ctx.obj['bucket']
    for block_num in range(start, end+1):
        try:
            raw, ops = fetch(steemd_url, block_num, 'get_ops_in_block')
            ops_key = '/'.join([str(block_num), 'ops.json'])
            ops = ops['result']
            _, ops_result = put_json(s3_resource, bucket, ops_key, ops)
            click.echo('{block_num}: ops result:{ops_result}'.format(block_num=block_num,ops_result=ops_result), err=True)
        except Exception as e:
            click.echo(str(e),err=True)
github debrouwere / google-analytics / googleanalytics / commands / query.py View on Github external
"""

    if realtime:
        description['type'] = 'realtime'

    if blueprint:
        queries = from_blueprint(scope, blueprint)
    else:
        if not isinstance(scope, ga.account.Profile):
            raise ValueError("Account and webproperty needed for query.")

        queries = from_args(scope, **description)

    for query in queries:
        if debug:
            click.echo(query.build())

        report = query.serialize(format=output, with_metadata=with_metadata)
        click.echo(report)
github skorokithakis / catt / catt / cli.py View on Github external
def print_status(status):
    if status.get("title"):
        click.echo("Title: {}".format(status["title"]))

    if status.get("current_time"):
        current = human_time(status["current_time"])
        if status.get("duration"):
            duration = human_time(status["duration"])
            remaining = human_time(status["remaining"])
            click.echo("Time: {} / {} ({}%)".format(current, duration, status["progress"]))
            click.echo("Remaining time: {}".format(remaining))
        else:
            click.echo("Time: {}".format(current))

    if status.get("player_state"):
        click.echo("State: {}".format(status["player_state"]))

    if status.get("volume_level"):
        click.echo("Volume: {}".format(status["volume_level"]))