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


Python click.echo方法代码示例

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


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

示例1: get_params

# 需要导入模块: import click [as 别名]
# 或者: from click import echo [as 别名]
def get_params(self, name):
        def show_help(ctx, param, value):
            if value and not ctx.resilient_parsing:
                click.echo(ctx.get_help(), color=ctx.color)
                ctx.exit()

        return [
            click.version_option(version=self.version, message="%(version)s"),
            click.option(
                "-h",
                "--help",
                is_flag=True,
                is_eager=True,
                expose_value=False,
                callback=show_help,
                help="Show this message and exit.",
            ),
        ] + self.common_options 
开发者ID:GaretJax,项目名称:django-click,代码行数:20,代码来源:adapter.py

示例2: task_builddata

# 需要导入模块: import click [as 别名]
# 或者: from click import echo [as 别名]
def task_builddata(ctx, task_id=None, output='yaml'):
    """Show builddata assoicated with ``task_id``."""
    if not task_id:
        ctx.fail('The task id must be specified by --task-id')

    task_bd = TaskBuildData(ctx.obj['CLIENT'], task_id=task_id).invoke()

    if output == 'json':
        click.echo(json.dumps(task_bd))
    else:
        if output != 'yaml':
            click.echo(
                'Invalid output format {}, defaulting to YAML.'.format(output))
        click.echo(
            yaml.safe_dump(
                task_bd, allow_unicode=True, default_flow_style=False)) 
开发者ID:airshipit,项目名称:drydock,代码行数:18,代码来源:commands.py

示例3: main

# 需要导入模块: import click [as 别名]
# 或者: from click import echo [as 别名]
def main(raw_filepath, process_phase, interim_filepath, datetime, processed_path):
    """ Runs data processing scripts to turn raw data from (../raw) into
        cleaned data ready to be analyzed (saved in ../processed).
    """
    logger = logging.getLogger(__name__)

    if process_phase == 'testA':
        file_name='ai_challenger_wf2018_testa1_20180829-20180924.nc'

    elif process_phase == 'testB':
        file_name='ai_challenger_weather_testingsetB_20180829-20181015.nc'

    elif process_phase == 'OnlineEveryDay':
        file_name='ai_challenger_wf2018_testb1_20180829-20181028.nc'
        #click.echo('Error! process_phase must be (testA, testB or OnlineEveryDay)')

    interim_file_name = netCDF2TheLastDay(raw_filepath+file_name, process_phase, interim_filepath, datetime)
    process_outlier_and_stack(interim_filepath, interim_file_name, process_phase, datetime, processed_path) 
开发者ID:BruceBinBoxing,项目名称:Deep_Learning_Weather_Forecasting,代码行数:20,代码来源:make_TestOnlineData_from_nc.py

示例4: validate

# 需要导入模块: import click [as 别名]
# 或者: from click import echo [as 别名]
def validate(ctx):
    """
    Validate the paradrop.yaml file.

    A note about versions: this command validates the chute configuration
    against the current rules for the installed version of pdtools. If
    the chute is to be installed on a Paradrop node running a different
    version, then this command may not be reliable for determining
    compatibility.
    """
    with open('paradrop.yaml', 'r') as source:
        chute = yaml.safe_load(source)

    schema_path = pkg_resources.resource_filename('pdtools', 'schemas/chute.json')
    with open(schema_path, 'r') as source:
        schema = json.load(source)

    validator = jsonschema.Draft4Validator(schema)
    for error in sorted(validator.iter_errors(chute), key=str):
        click.echo(error.message) 
开发者ID:ParadropLabs,项目名称:Paradrop,代码行数:22,代码来源:chute.py

示例5: generate_configuration

# 需要导入模块: import click [as 别名]
# 或者: from click import echo [as 别名]
def generate_configuration(ctx, format):
    """
    Generate a new node configuration based on detected hardware.

    The new configuration is not automatically applied.  Rather, you can
    save it to file and use the import-configuration command to apply it.
    """
    client = ctx.obj['client']
    result = client.generate_config()

    format = format.lower()
    if format == 'json':
        click.echo(json.dumps(result, indent=4))
    elif format == 'yaml':
        click.echo(yaml.safe_dump(result, default_flow_style=False))
    else:
        click.echo("Unrecognized format: {}".format(format))
    return result 
开发者ID:ParadropLabs,项目名称:Paradrop,代码行数:20,代码来源:node.py

示例6: login

# 需要导入模块: import click [as 别名]
# 或者: from click import echo [as 别名]
def login(ctx):
    """
    Interactively log in using the local admin password.

    Authenticate with the node using the local username and
    password. Typically, the username will be "paradrop". The password
    can be set with the set-password command.
    """
    client = ctx.obj['client']
    token = client.login()
    if token is None:
        click.echo("Login attempt failed.")
        return False
    else:
        click.echo("Login successful.")
        return True 
开发者ID:ParadropLabs,项目名称:Paradrop,代码行数:18,代码来源:node.py

示例7: remove_chute_network_client

# 需要导入模块: import click [as 别名]
# 或者: from click import echo [as 别名]
def remove_chute_network_client(ctx, chute, network, client):
    """
    Remove a connected client from the chute's network.

    CHUTE must be the name of an installed chute.  NETWORK must be the
    name of one of the chute's configured networks. Typically, this
    will be "wifi".  CLIENT identifies the network client, such as a
    MAC address.

    Only implemented for wireless clients, this effectively kicks the
    client off the network.
    """
    pdclient = ctx.obj['client']
    result = pdclient.remove_chute_client(chute, network, client)
    click.echo(util.format_result(result))
    return result 
开发者ID:ParadropLabs,项目名称:Paradrop,代码行数:18,代码来源:node.py

示例8: set_source_volume

# 需要导入模块: import click [as 别名]
# 或者: from click import echo [as 别名]
def set_source_volume(ctx, source, volume):
    """
    Configure audio source volume.

    SOURCE must be the name of a PulseAudio source. VOLUME should be one
    (applied to all channels) or multiple (one for each channel) floating
    point values between 0 and 1.
    """
    client = ctx.obj['client']

    # Convert to a list of floats. Be aware: the obvious approach
    # list(volume) behaves strangely.
    data = [float(vol) for vol in volume]

    result = client.set_source_volume(source, data)
    click.echo(util.format_result(result))
    return result 
开发者ID:ParadropLabs,项目名称:Paradrop,代码行数:19,代码来源:node.py

示例9: set_password

# 需要导入模块: import click [as 别名]
# 或者: from click import echo [as 别名]
def set_password(ctx):
    """
    Change the local admin password.

    Set the password required by `pdtools node login` and the local
    web-based administration page.
    """
    username = builtins.input("Username: ")
    while True:
        password = getpass.getpass("New password: ")
        confirm = getpass.getpass("Confirm password: ")

        if password == confirm:
            break
        else:
            print("Passwords do not match.")

    click.echo("Next, if prompted, you should enter the current username and password.")
    client = ctx.obj['client']
    result = client.set_password(username, password)
    click.echo(util.format_result(result))
    return result 
开发者ID:ParadropLabs,项目名称:Paradrop,代码行数:24,代码来源:node.py

示例10: watch_chute_logs

# 需要导入模块: import click [as 别名]
# 或者: from click import echo [as 别名]
def watch_chute_logs(ctx, chute):
    """
    Stream log messages from a running chute.

    CHUTE must be the name of a running chute.
    """
    url = "ws://{}/sockjs/logs/{}".format(ctx.obj['target'], chute)

    def on_message(ws, message):
        data = json.loads(message)
        time = arrow.get(data['timestamp']).to('local').datetime
        msg = data['message'].rstrip()
        service = data.get("service", chute)
        click.echo("[{}] {}: {}".format(service, time, msg))

    client = ctx.obj['client']
    client.ws_request(url, on_message=on_message) 
开发者ID:ParadropLabs,项目名称:Paradrop,代码行数:19,代码来源:node.py

示例11: create_version

# 需要导入模块: import click [as 别名]
# 或者: from click import echo [as 别名]
def create_version(ctx):
    """
    Push a new version of the chute to the store.
    """
    if not os.path.exists("paradrop.yaml"):
        raise Exception("No paradrop.yaml file found in working directory.")

    with open('paradrop.yaml', 'r') as source:
        chute = yaml.safe_load(source)

    name = chute_find_field(chute, 'name')
    source = chute_find_field(chute, 'source')
    config = chute.get('config', {})

    chute_resolve_source(source, config)

    client = ControllerClient()
    result = client.find_chute(name)
    if result is None:
        raise Exception("Could not find ID for chute {} - is it registered?".format(name))

    result = client.create_version(name, config)
    click.echo(util.format_result(result))
    return result 
开发者ID:ParadropLabs,项目名称:Paradrop,代码行数:26,代码来源:store.py

示例12: install_chute

# 需要导入模块: import click [as 别名]
# 或者: from click import echo [as 别名]
def install_chute(ctx, chute, node, follow, version):
    """
    Install a chute from the store.

    CHUTE must be the name of a chute in the store. NODE must be the
    name of a node that you control.
    """
    client = ControllerClient()
    result = client.install_chute(chute, node, select_version=version)
    click.echo(util.format_result(result))

    if follow:
        result2 = client.follow_chute(chute, node)
        click.echo(util.format_result(result2))

    click.echo("Streaming messages until the update has completed.")
    click.echo("Ending output with Ctrl+C will not cancel the update.\n")

    ctx.invoke(watch_update_messages, node_id=result['router_id'], update_id=result['_id'])
    return result 
开发者ID:ParadropLabs,项目名称:Paradrop,代码行数:22,代码来源:store.py

示例13: list_chutes

# 需要导入模块: import click [as 别名]
# 或者: from click import echo [as 别名]
def list_chutes(ctx):
    """
    List chutes in the store that you own or have access to.
    """
    client = ControllerClient()
    result = client.list_chutes()
    if len(result) > 0:
        click.echo("Name                             Ver Description")
    for chute in sorted(result, key=operator.itemgetter('name')):
        # Show the summary if available. This is intended to be
        # a shorter description than the description field.
        summary = chute.get('summary', None)
        if summary is None:
            summary = chute.get('description', '')
        click.echo("{:32s} {:3d} {}".format(chute['name'],
            chute['current_version'], summary))
    return result 
开发者ID:ParadropLabs,项目名称:Paradrop,代码行数:19,代码来源:store.py

示例14: list_versions

# 需要导入模块: import click [as 别名]
# 或者: from click import echo [as 别名]
def list_versions(ctx, name):
    """
    List versions of a chute in the store.

    NAME must be the name of a chute in the store.
    """
    client = ControllerClient()
    result = client.list_versions(name)
    if len(result) > 0:
        click.echo("Version GitCheckout")
    for version in sorted(result, key=operator.itemgetter('version')):
        try:
            code = version['config']['download']['checkout']
        except:
            code = "N/A"
        click.echo("{:7s} {}".format(str(version['version']), code))
    return result 
开发者ID:ParadropLabs,项目名称:Paradrop,代码行数:19,代码来源:store.py

示例15: claim_node

# 需要导入模块: import click [as 别名]
# 或者: from click import echo [as 别名]
def claim_node(ctx, token, name):
    """
    Take ownership of a node by using a claim token.

    TOKEN is a hard-to-guess string that the previous owner would have
    configured when setting the node's status as orphaned.
    """
    client = ControllerClient()
    result = client.claim_node(token, name=name)
    if result is not None and 'name' in result:
        click.echo("Claimed node with name {}".format(result['name']))
    elif result is not None and 'message' in result:
        click.echo(result['message'])
    else:
        click.echo("No node was found with that claim token.")
    return result 
开发者ID:ParadropLabs,项目名称:Paradrop,代码行数:18,代码来源:cloud.py


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