當前位置: 首頁>>代碼示例>>Python>>正文


Python click.secho方法代碼示例

本文整理匯總了Python中click.secho方法的典型用法代碼示例。如果您正苦於以下問題:Python click.secho方法的具體用法?Python click.secho怎麽用?Python click.secho使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在click的用法示例。


在下文中一共展示了click.secho方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: init

# 需要導入模塊: import click [as 別名]
# 或者: from click import secho [as 別名]
def init(paths, output, **kwargs):
    """Init data package from list of files.

    It will also infer tabular data's schemas from their contents.
    """
    dp = init_datapackage(paths)

    click.secho(
        json_module.dumps(dp.descriptor, indent=4),
        file=output
    )

    exit(int(not dp.valid))  # Just to be defensive, as it should always be valid.


# Internal 
開發者ID:frictionlessdata,項目名稱:goodtables-py,代碼行數:18,代碼來源:cli.py

示例2: wp

# 需要導入模塊: import click [as 別名]
# 或者: from click import secho [as 別名]
def wp(ssid):
    """Show wifi password."""
    if not ssid:
        ok, err = _detect_wifi_ssid()
        if not ok:
            click.secho(click.style(err, fg='red'))
            sys.exit(1)
        ssid = err
    ok, err = _hack_wifi_password(ssid)
    if not ok:
        click.secho(click.style(err, fg='red'))
        sys.exit(1)
    click.secho(click.style('{ssid}:{password}'.format(ssid=ssid, password=err), fg='green'))


# Install click commands. 
開發者ID:cls1991,項目名稱:ng,代碼行數:18,代碼來源:ng.py

示例3: copy_resources

# 需要導入模塊: import click [as 別名]
# 或者: from click import secho [as 別名]
def copy_resources(self):
        """Copies the relevant resources to a resources subdirectory"""
        if not os.path.isdir('resources'):
            os.mkdir('resources')

        resource_dir = os.path.join(os.getcwd(), 'resources', '')
        copied_resources = []

        for resource in self.resources:
            src = os.path.join(EULER_DATA, 'resources', resource)
            if os.path.isfile(src):
                shutil.copy(src, resource_dir)
                copied_resources.append(resource)

        if copied_resources:
            copied = ', '.join(copied_resources)
            path = os.path.relpath(resource_dir, os.pardir)
            msg = "Copied {} to {}.".format(copied, path)

            click.secho(msg, fg='green') 
開發者ID:iKevinY,項目名稱:EulerPy,代碼行數:22,代碼來源:problem.py

示例4: solution

# 需要導入模塊: import click [as 別名]
# 或者: from click import secho [as 別名]
def solution(self):
        """Returns the answer to a given problem"""
        num = self.num

        solution_file = os.path.join(EULER_DATA, 'solutions.txt')
        solution_line = linecache.getline(solution_file, num)

        try:
            answer = solution_line.split('. ')[1].strip()
        except IndexError:
            answer = None

        if answer:
            return answer
        else:
            msg = 'Answer for problem %i not found in solutions.txt.' % num
            click.secho(msg, fg='red')
            click.echo('If you have an answer, consider submitting a pull '
                       'request to EulerPy on GitHub.')
            sys.exit(1) 
開發者ID:iKevinY,項目名稱:EulerPy,代碼行數:22,代碼來源:problem.py

示例5: fail_if_publish_binary_not_installed

# 需要導入模塊: import click [as 別名]
# 或者: from click import secho [as 別名]
def fail_if_publish_binary_not_installed(binary, publish_target, install_link):
    """Exit (with error message) if ``binary` isn't installed"""
    if not shutil.which(binary):
        click.secho(
            "Publishing to {publish_target} requires {binary} to be installed and configured".format(
                publish_target=publish_target, binary=binary
            ),
            bg="red",
            fg="white",
            bold=True,
            err=True,
        )
        click.echo(
            "Follow the instructions at {install_link}".format(
                install_link=install_link
            ),
            err=True,
        )
        sys.exit(1) 
開發者ID:simonw,項目名稱:datasette,代碼行數:21,代碼來源:common.py

示例6: synthesize

# 需要導入模塊: import click [as 別名]
# 或者: from click import secho [as 別名]
def synthesize(access_key, secret_key, output_file, voice_name, voice_language,
               codec, text):
    """Synthesize passed text and save it as an audio file"""
    try:
        ivona_api = IvonaAPI(
            access_key, secret_key,
            voice_name=voice_name, language=voice_language, codec=codec,
        )
    except (ValueError, IvonaAPIException) as e:
        raise click.ClickException("Something went wrong: {}".format(repr(e)))

    with click.open_file(output_file, 'wb') as file:
        ivona_api.text_to_speech(text, file)

    click.secho(
        "File successfully saved as '{}'".format(output_file),
        fg='green',
    ) 
開發者ID:Pythonity,項目名稱:ivona-speak,代碼行數:20,代碼來源:command_line.py

示例7: list_voices

# 需要導入模塊: import click [as 別名]
# 或者: from click import secho [as 別名]
def list_voices(access_key, secret_key, voice_language, voice_gender):
    """List available Ivona voices"""
    try:
        ivona_api = IvonaAPI(access_key, secret_key)
    except (ValueError, IvonaAPIException) as e:
        raise click.ClickException("Something went wrong: {}".format(repr(e)))

    click.echo("Listing available voices...")

    voices_list = ivona_api.get_available_voices(
        language=voice_language,
        gender=voice_gender,
    )

    # Group voices by language
    voices_dict = dict()
    data = sorted(voices_list, key=lambda x: x['Language'])
    for k, g in groupby(data, key=lambda x: x['Language']):
        voices_dict[k] = list(g)

    for ln, voices in voices_dict.items():
        voice_names = [v['Name'] for v in voices]
        click.echo("{}: {}".format(ln, ', '.join(voice_names)))

    click.secho("All done", fg='green') 
開發者ID:Pythonity,項目名稱:ivona-speak,代碼行數:27,代碼來源:command_line.py

示例8: show_server_banner

# 需要導入模塊: import click [as 別名]
# 或者: from click import secho [as 別名]
def show_server_banner(env, debug, app_import_path, eager_loading):
    """Show extra startup messages the first time the server is run,
    ignoring the reloader.
    """
    if os.environ.get('WERKZEUG_RUN_MAIN') == 'true':
        return

    if app_import_path is not None:
        message = ' * Serving Flask app "{0}"'.format(app_import_path)

        if not eager_loading:
            message += ' (lazy loading)'

        click.echo(message)

    click.echo(' * Environment: {0}'.format(env))

    if env == 'production':
        click.secho(
            '   WARNING: Do not use the development server in a production'
            ' environment.', fg='red')
        click.secho('   Use a production WSGI server instead.', dim=True)

    if debug is not None:
        click.echo(' * Debug mode: {0}'.format('on' if debug else 'off')) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:27,代碼來源:cli.py

示例9: replay

# 需要導入模塊: import click [as 別名]
# 或者: from click import secho [as 別名]
def replay(
    cassette_path: str,
    id_: Optional[str],
    status: Optional[str] = None,
    uri: Optional[str] = None,
    method: Optional[str] = None,
) -> None:
    """Replay a cassette.

    Cassettes in VCR-compatible format can be replayed.
    For example, ones that are recorded with ``store-network-log`` option of `schemathesis run` command.
    """
    click.secho(f"{bold('Replaying cassette')}: {cassette_path}")
    with open(cassette_path) as fd:
        cassette = yaml.load(fd, Loader=SafeLoader)
    click.secho(f"{bold('Total interactions')}: {len(cassette['http_interactions'])}\n")
    for replayed in cassettes.replay(cassette, id_=id_, status=status, uri=uri, method=method):
        click.secho(f"  {bold('ID')}              : {replayed.interaction['id']}")
        click.secho(f"  {bold('URI')}             : {replayed.interaction['request']['uri']}")
        click.secho(f"  {bold('Old status code')} : {replayed.interaction['response']['status']['code']}")
        click.secho(f"  {bold('New status code')} : {replayed.response.status_code}\n") 
開發者ID:kiwicom,項目名稱:schemathesis,代碼行數:23,代碼來源:__init__.py

示例10: validate_app

# 需要導入模塊: import click [as 別名]
# 或者: from click import secho [as 別名]
def validate_app(ctx: click.core.Context, param: click.core.Parameter, raw_value: Optional[str]) -> Optional[str]:
    if raw_value is None:
        return raw_value
    try:
        utils.import_app(raw_value)
        # String is returned instead of an app because it might be passed to a subprocess
        # Since most of app instances are not-transferable to another process, they are passed as strings and
        # imported in a subprocess
        return raw_value
    except Exception as exc:
        show_errors_tracebacks = ctx.params["show_errors_tracebacks"]
        message = utils.format_exception(exc, show_errors_tracebacks)
        click.secho(f"{message}\nCan not import application from the given module", fg="red")
        if not show_errors_tracebacks:
            click.secho(
                "Add this option to your command line parameters to see full tracebacks: --show-errors-tracebacks",
                fg="red",
            )
        raise click.exceptions.Exit(1) 
開發者ID:kiwicom,項目名稱:schemathesis,代碼行數:21,代碼來源:callbacks.py

示例11: display_statistic

# 需要導入模塊: import click [as 別名]
# 或者: from click import secho [as 別名]
def display_statistic(context: ExecutionContext, event: events.Finished) -> None:
    """Format and print statistic collected by :obj:`models.TestResult`."""
    display_section_name("SUMMARY")
    click.echo()
    total = event.total
    if event.is_empty or not total:
        click.secho("No checks were performed.", bold=True)

    if total:
        display_checks_statistics(total)

    if context.cassette_file_name or context.junit_xml_file:
        click.echo()

    if context.cassette_file_name:
        category = click.style("Network log", bold=True)
        click.secho(f"{category}: {context.cassette_file_name}")

    if context.junit_xml_file:
        category = click.style("JUnit XML file", bold=True)
        click.secho(f"{category}: {context.junit_xml_file}") 
開發者ID:kiwicom,項目名稱:schemathesis,代碼行數:23,代碼來源:default.py

示例12: cli

# 需要導入模塊: import click [as 別名]
# 或者: from click import secho [as 別名]
def cli(ctx, lsftdi, lsusb, lsserial, info):
    """System tools.\n
       Install with `apio install system`"""

    exit_code = 0

    if lsftdi:
        exit_code = System().lsftdi()
    elif lsusb:
        exit_code = System().lsusb()
    elif lsserial:
        exit_code = System().lsserial()
    elif info:
        click.secho('Platform: ', nl=False)
        click.secho(get_systype(), fg='yellow')
    else:
        click.secho(ctx.get_help())

    ctx.exit(exit_code) 
開發者ID:FPGAwars,項目名稱:apio,代碼行數:21,代碼來源:system.py

示例13: cli

# 需要導入模塊: import click [as 別名]
# 或者: from click import secho [as 別名]
def cli(ctx):
    """Check the latest Apio version."""

    current_version = get_distribution('apio').version
    latest_version = get_pypi_latest_version()

    if latest_version is None:
        ctx.exit(1)

    if latest_version == current_version:
        click.secho('You\'re up-to-date!\nApio {} is currently the '
                    'newest version available.'.format(latest_version),
                    fg='green')
    else:
        click.secho('You\'re not updated\nPlease execute '
                    '`pip install -U apio` to upgrade.',
                    fg="yellow") 
開發者ID:FPGAwars,項目名稱:apio,代碼行數:19,代碼來源:upgrade.py

示例14: cli

# 需要導入模塊: import click [as 別名]
# 或者: from click import secho [as 別名]
def cli(ctx, ftdi_enable, ftdi_disable, serial_enable, serial_disable):
    """Manage FPGA boards drivers."""

    exit_code = 0

    if ftdi_enable:   # pragma: no cover
        exit_code = Drivers().ftdi_enable()
    elif ftdi_disable:   # pragma: no cover
        exit_code = Drivers().ftdi_disable()
    elif serial_enable:   # pragma: no cover
        exit_code = Drivers().serial_enable()
    elif serial_disable:   # pragma: no cover
        exit_code = Drivers().serial_disable()
    else:
        click.secho(ctx.get_help())

    ctx.exit(exit_code) 
開發者ID:FPGAwars,項目名稱:apio,代碼行數:19,代碼來源:drivers.py

示例15: cli

# 需要導入模塊: import click [as 別名]
# 或者: from click import secho [as 別名]
def cli(ctx, list, dir, files, project_dir, sayno):
    """Manage verilog examples.\n
       Install with `apio install examples`"""

    exit_code = 0

    if list:
        exit_code = Examples().list_examples()
    elif dir:
        exit_code = Examples().copy_example_dir(dir, project_dir, sayno)
    elif files:
        exit_code = Examples().copy_example_files(files, project_dir, sayno)
    else:
        click.secho(ctx.get_help())
        click.secho(Examples().examples_of_use_cad())

    ctx.exit(exit_code) 
開發者ID:FPGAwars,項目名稱:apio,代碼行數:19,代碼來源:examples.py


注:本文中的click.secho方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。