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


Python click.UNPROCESSED属性代码示例

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


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

示例1: generate_not_available_cmd

# 需要导入模块: import click [as 别名]
# 或者: from click import UNPROCESSED [as 别名]
def generate_not_available_cmd(exc, hint=None):
    error_msg = "".join(
        [
            click.style("Not available: ", fg="red"),
            "Importing this module has failed with error:\n\n",
            *traceback.format_exception(exc, exc, exc.__traceback__),
            f"\n\n{hint}\n" if hint else "",
        ]
    )

    @click.command(
        context_settings=dict(ignore_unknown_options=True),
        help=f"Not available{' (' + hint + ')' if hint else ''}",
    )
    @click.argument("args", nargs=-1, type=click.UNPROCESSED)
    def bad_cmd(args):
        raise SystemExit(error_msg)

    return bad_cmd 
开发者ID:Scille,项目名称:parsec-cloud,代码行数:21,代码来源:cli_utils.py

示例2: main

# 需要导入模块: import click [as 别名]
# 或者: from click import UNPROCESSED [as 别名]
def main():
    """Call the CLI Script."""
    try:
        for alias, conf in get_aliases().items():
            if conf is None:
                continue

            cmd_help = conf['description'] if 'description' in conf else 'No description'

            @stakkr.command(help=cmd_help, name=alias)
            @click.option('--tty/--no-tty', '-t/ ', is_flag=True, default=True, help="Use a TTY")
            @click.argument('extra_args', required=False, nargs=-1, type=click.UNPROCESSED)
            @click.pass_context
            def _f(ctx: Context, extra_args: tuple, tty: bool):
                """See command Help."""
                run_commands(ctx, extra_args, tty)

        stakkr(obj={})
    except Exception as error:
        msg = click.style(r""" ______ _____  _____   ____  _____
|  ____|  __ \|  __ \ / __ \|  __ \
| |__  | |__) | |__) | |  | | |__) |
|  __| |  _  /|  _  /| |  | |  _  /
| |____| | \ \| | \ \| |__| | | \ \
|______|_|  \_\_|  \_\\____/|_|  \_\

""", fg='yellow')
        msg += click.style('{}'.format(error), fg='red')
        print(msg + '\n', file=sys.stderr)

        if debug_mode() is True:
            raise error

        sys.exit(1) 
开发者ID:stakkr-org,项目名称:stakkr,代码行数:36,代码来源:cli.py

示例3: _dynamic_rpc_cmd

# 需要导入模块: import click [as 别名]
# 或者: from click import UNPROCESSED [as 别名]
def _dynamic_rpc_cmd(self, ctx, cmd_name):
        @cli.command()
        @click.argument('params', nargs=-1, type=click.UNPROCESSED)
        @click.pass_context
        def _rpc_result(ctx, params):
            conf = ctx.parent.params['conf']
            try:
                response = requests.post(
                    'http://%s:%s' % (conf['ethpconnect'], conf['ethpport']),
                    data=json.dumps({
                        'id': 'ethereum-cli',
                        'method': cmd_name,
                        'params': params,
                    })
                )
            except requests.exceptions.ConnectionError:
                click.echo('error: couldn\'t connect to server: '
                           'unknown (code -1)')
                click.echo('(make sure server is running and you are '
                           'connecting to the correct RPC port)')
                return
            else:
                response = response.json()
                if response['error']:
                    error = response['error']
                    click.echo('error code: %s' % error['code'])
                    if error['code'] == -1:
                        method = getattr(EthereumProxy, cmd_name)
                        click.echo('error message:\n%s' % method.__doc__)
                    else:
                        click.echo('error message:\n%s' % error['message'])
                    sys.exit(1)
                else:
                    result = response['result']
                    if isinstance(result, Mapping):
                        result = json.dumps(response['result'], indent=4)
                    elif isinstance(result, bool):
                        result = 'true' if result else 'false'
                    click.echo(result)
        return click.Group.get_command(self, ctx, '_rpc_result') 
开发者ID:DeV1doR,项目名称:ethereumd-proxy,代码行数:42,代码来源:ethereum_cli.py


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