當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。