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


Python click.echo_via_pager方法代码示例

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


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

示例1: rib_getversion

# 需要导入模块: import click [as 别名]
# 或者: from click import echo_via_pager [as 别名]
def rib_getversion(ctx, name, paging):
    if ctx.invoked_subcommand != 'help':
        try:
            rpc_type = 'RibApi.GetVersion'
            if name in ctx.obj['manager'].rpcs[rpc_type]:
                if ctx.invoked_subcommand is None:
                    if paging:
                        click.echo_via_pager(ctx.obj['manager'].get_rpc(type=rpc_type, name=name))
                    else:
                        click.echo(ctx.obj['manager'].get_rpc(type=rpc_type, name=name))

            else:
                click.secho('Rpc with name \'{name}\' doesnt exists, adding one to rpc manager'.format(name=name), fg='yellow')
                ctx.obj['manager'].rpcs[rpc_type][name] = rib_api.GetVersion(stub=ctx.obj['rib_fib_stub'],
                                                                            metadata=ctx.obj['context'].metadata,
                                                                            name=name)
            ctx.obj['RPC_NAME'] = name
            ctx.obj['RPC_TYPE'] = rpc_type
        except KeyError as e:
            click.secho('\nYou have to create at least one connection before creating RPCs\n', fg='red')
            sys.exit() 
开发者ID:nokia,项目名称:SROS-grpc-services,代码行数:23,代码来源:grpc_shell.py

示例2: rib_modify

# 需要导入模块: import click [as 别名]
# 或者: from click import echo_via_pager [as 别名]
def rib_modify(ctx,name, paging):
    '''
        RibApi.Modify
    '''
    if ctx.invoked_subcommand != 'help':
        try:
            rpc_type = 'RibApi.Modify'
            if name in ctx.obj['manager'].rpcs[rpc_type]:
                if ctx.invoked_subcommand is None:
                    if paging:
                        click.echo_via_pager(ctx.obj['manager'].get_rpc(type=rpc_type, name=name))
                    else:
                        click.echo(ctx.obj['manager'].get_rpc(type=rpc_type, name=name))

            else:
                click.secho('Rpc with name \'{name}\' doesnt exists, adding one to rpc manager'.format(name=name), fg='yellow')
                ctx.obj['manager'].rpcs[rpc_type][name] = rib_api.Modify(stub=ctx.obj['rib_fib_stub'],
                                                                         metadata=ctx.obj['context'].metadata,
                                                                         name=name)
            ctx.obj['RPC_NAME'] = name
            ctx.obj['RPC_TYPE'] = rpc_type
        except KeyError as e:
            click.secho('\nYou have to create at least one connection before creating RPCs\n', fg='red')
            sys.exit() 
开发者ID:nokia,项目名称:SROS-grpc-services,代码行数:26,代码来源:grpc_shell.py

示例3: help_tasks

# 需要导入模块: import click [as 别名]
# 或者: from click import echo_via_pager [as 别名]
def help_tasks(ctx, param, value):
    if not value or ctx.resilient_parsing:
        return
    from nidaba import celery
    t = celery.app.tasks
    hidden = ['util']
    last = u''
    docs = u''
    for k in sorted(t.keys()):
        hier = k.split('.')
        if hier[0] == 'nidaba':
            if hier[1] in hidden:
                continue
            elif hier[1] != last:
                docs += '{}\n{}\n\n'.format(hier[1].title(), len(hier[1]) *
                                            '-')
                last = hier[1]
            docs += '{}\n{}\n\n{}'.format(hier[-1], len(hier[-1]) * '~',
                                          getdoc(t[k].run).decode('utf-8').partition('Returns:')[0])
    click.echo_via_pager(docs)
    ctx.exit() 
开发者ID:OpenPhilology,项目名称:nidaba,代码行数:23,代码来源:cli.py

示例4: list_services

# 需要导入模块: import click [as 别名]
# 或者: from click import echo_via_pager [as 别名]
def list_services():
    """List all services and statuses."""
    try:
        data = []
        svcs = services.get()
        llen = len(sorted(svcs, key=lambda x: len(x.name))[-1].name)
        for x in svcs:
            data.append(
                click.style(
                    '{name: <{fill}}'.format(name=x.name, fill=llen + 3),
                    fg="white", bold=True) +
                click.style(
                    x.state.capitalize(),
                    fg="green" if x.state == "running" else "red") + "   " +
                click.style(
                    "Enabled" if x.enabled else "Disabled",
                    fg="green" if x.enabled else "red")
            )
        click.echo_via_pager("\n".join(data))
    except Exception as e:
        raise CLIException(str(e)) 
开发者ID:arkOScloud,项目名称:core,代码行数:23,代码来源:services.py

示例5: get_build_logs

# 需要导入模块: import click [as 别名]
# 或者: from click import echo_via_pager [as 别名]
def get_build_logs(facade: ServeFacade, job_id, out_dir):
    """
    Retrieve logs from a running endpoint.
    """
    try:

        # ensure arguments are correctly defined
        validate_inputs([job_id], ['ind'])

        click.echo("{} - Retrieving {} from {}".format(
            click.style("Info", bold=True, fg='green'),
            click.style("build-logs", bold=True),
            click.style(job_id, bold=True, fg='green', dim=True)))

        logs = facade.get_build_logs(job_id)
        click.echo_via_pager(logs)
        facade.write_build_logs(job_id, logs, out_dir)

    except Exception as e:
        handle_specific_exception(e)
        handle_exception(e)


# SERVE kill
# =========== 
开发者ID:KI-labs,项目名称:kaos,代码行数:27,代码来源:serve.py

示例6: echo_via_pager

# 需要导入模块: import click [as 别名]
# 或者: from click import echo_via_pager [as 别名]
def echo_via_pager(self, text, color=None):
        if self.pgspecial.pager_config == PAGER_OFF or self.watch_command:
            click.echo(text, color=color)
        elif "pspg" in os.environ.get("PAGER", "") and self.table_format == "csv":
            click.echo_via_pager(text, color)
        elif self.pgspecial.pager_config == PAGER_LONG_OUTPUT:
            lines = text.split("\n")

            # The last 4 lines are reserved for the pgcli menu and padding
            if self.is_too_tall(lines) or any(self.is_too_wide(l) for l in lines):
                click.echo_via_pager(text, color=color)
            else:
                click.echo(text, color=color)
        else:
            click.echo_via_pager(text, color) 
开发者ID:dbcli,项目名称:pgcli,代码行数:17,代码来源:main.py

示例7: _page

# 需要导入模块: import click [as 别名]
# 或者: from click import echo_via_pager [as 别名]
def _page(it):
    click.echo_via_pager('\n'.join(map(str, it))) 
开发者ID:pybel,项目名称:pybel,代码行数:4,代码来源:cli.py

示例8: ls

# 需要导入模块: import click [as 别名]
# 或者: from click import echo_via_pager [as 别名]
def ls(manager: Manager, url: Optional[str], namespace_id: Optional[int]):
    """List cached namespaces."""
    if url:
        n = manager.get_or_create_namespace(url)
        _page(n.entries)
    elif namespace_id is not None:
        _ls(manager, Namespace, namespace_id)
    else:
        click.echo_via_pager(
            '\n'.join(
                "{}\t{}\t{}".format(n.id, n.name, n.url)
                for n in manager.session.query(Namespace)
            ),
        ) 
开发者ID:pybel,项目名称:pybel,代码行数:16,代码来源:cli.py

示例9: echo_warnings_via_pager

# 需要导入模块: import click [as 别名]
# 或者: from click import echo_via_pager [as 别名]
def echo_warnings_via_pager(warnings: List[WarningTuple], sep: str = '\t') -> None:
    """Output the warnings from a BEL graph with Click and the system's pager."""
    # Exit if no warnings
    if not warnings:
        click.echo('Congratulations! No warnings.')
        sys.exit(0)

    max_line_width = max(
        len(str(exc.line_number))
        for _, exc, _ in warnings
    )

    max_warning_width = max(
        len(exc.__class__.__name__)
        for _, exc, _ in warnings
    )

    s1 = '{:>' + str(max_line_width) + '}' + sep
    s2 = '{:>' + str(max_warning_width) + '}' + sep

    def _make_line(path: str, exc: BELParserWarning):
        s = click.style(path, fg='cyan') + sep
        s += click.style(s1.format(exc.line_number), fg='blue', bold=True)
        s += click.style(
            s2.format(exc.__class__.__name__),
            fg=('red' if exc.__class__.__name__.endswith('Error') else 'yellow'),
        )
        s += click.style(exc.line, bold=True) + sep
        s += click.style(str(exc))
        return s

    click.echo_via_pager(
        '\n'.join(
            _make_line(path, exc)
            for path, exc, _ in warnings
        ),
    ) 
开发者ID:pybel,项目名称:pybel,代码行数:39,代码来源:cli.py

示例10: paging

# 需要导入模块: import click [as 别名]
# 或者: from click import echo_via_pager [as 别名]
def paging(lines):
    """Page through output."""
    data = '\n'.join(['Line %d' % num for num in range(lines)])
    click.echo_via_pager(data) 
开发者ID:tylerdave,项目名称:PyCon2019-Click-Tutorial,代码行数:6,代码来源:cli.py

示例11: _echo

# 需要导入模块: import click [as 别名]
# 或者: from click import echo_via_pager [as 别名]
def _echo(output, min_lines=10):
    ctx = click.get_current_context()
    if ctx.obj.get('use_pager') and output.count('\n') > min_lines:
        _func = click.echo_via_pager
    else:
        _func = click.echo
    _func(output, sys.stdout) 
开发者ID:rmax,项目名称:databrewer,代码行数:9,代码来源:cli.py

示例12: gnmi_get

# 需要导入模块: import click [as 别名]
# 或者: from click import echo_via_pager [as 别名]
def gnmi_get(ctx, name, paging):
    '''
        gNMI.Get unary rpc - sends resquest consisting of paths to deserved data and
        returns all the data at once in GetRespone - one noticfication per one path
        requested. Since whole response must be srialized at remote device before
        sending, this rpc is not suitable for retrieving large sets of data.
    '''
    if ctx.invoked_subcommand != 'help':
        try:
            rpc_type = 'gNMI.Get'
            if name in ctx.obj['manager'].rpcs[rpc_type]:
                if ctx.invoked_subcommand is None:
                    if paging:
                        click.echo_via_pager(ctx.obj['manager'].get_rpc(type=rpc_type, name=name))
                    else:
                        click.echo(ctx.obj['manager'].get_rpc(type=rpc_type, name=name))

            else:
                click.secho('Rpc with name \'{name}\' doesnt exists, adding one to rpc manager'.format(name=name), fg='yellow')
                ctx.obj['manager'].rpcs[rpc_type][name] = gnmi.Get(stub=ctx.obj['gnmi_stub'],
                                                                        metadata=ctx.obj['context'].metadata,
                                                                        name=name,
                                                                        delimiter=default_delimiter)
            ctx.obj['RPC_NAME'] = name
            ctx.obj['RPC_TYPE'] = rpc_type
        except KeyError as e:
            click.secho('\nYou have to create at least one connection before creating RPCs\n', fg='red')
            sys.exit() 
开发者ID:nokia,项目名称:SROS-grpc-services,代码行数:30,代码来源:grpc_shell.py

示例13: request

# 需要导入模块: import click [as 别名]
# 或者: from click import echo_via_pager [as 别名]
def request(ctx, paging):
    '''
        Displays request currently being built in clients.
    '''
    if paging:
        click.echo_via_pager(str(ctx.obj['manager'].rpcs[ctx.obj['RPC_TYPE']][ctx.obj['RPC_NAME']].request))
    else:
        click.secho(str(ctx.obj['manager'].rpcs[ctx.obj['RPC_TYPE']][ctx.obj['RPC_NAME']].request)) 
开发者ID:nokia,项目名称:SROS-grpc-services,代码行数:10,代码来源:grpc_shell.py

示例14: response

# 需要导入模块: import click [as 别名]
# 或者: from click import echo_via_pager [as 别名]
def response(ctx, paging):
    '''
        Displays response from the last RPC call.
    '''
    if paging:
        click.echo_via_pager(str(ctx.obj['manager'].rpcs[ctx.obj['RPC_TYPE']][ctx.obj['RPC_NAME']].response))
    else:
        click.secho(str(ctx.obj['manager'].rpcs[ctx.obj['RPC_TYPE']][ctx.obj['RPC_NAME']].response)) 
开发者ID:nokia,项目名称:SROS-grpc-services,代码行数:10,代码来源:grpc_shell.py

示例15: error

# 需要导入模块: import click [as 别名]
# 或者: from click import echo_via_pager [as 别名]
def error(ctx, paging):
    '''
        Displays error from last rpc call.
    '''
    if paging:
        click.echo_via_pager(str(ctx.obj['manager'].rpcs[ctx.obj['RPC_TYPE']][ctx.obj['RPC_NAME']].error))
    else:
        click.secho(str(ctx.obj['manager'].rpcs[ctx.obj['RPC_TYPE']][ctx.obj['RPC_NAME']].error)) 
开发者ID:nokia,项目名称:SROS-grpc-services,代码行数:10,代码来源:grpc_shell.py


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