コード例 #1
0
def help_command(ctx, config_dump=False):
    """Print some information on the system environment."""
    def banner(title):
        "Helper"
        click.echo('')
        click.secho('~~~ {} ~~~'.format(title), fg='green', bg='black', bold=True)

    if config_dump:
        ctx.obj.cfg.dump()
        sys.exit(0)

    app_name = ctx.find_root().info_name
    click.secho('*** "{}" Help & Information ***'.format(app_name), fg='white', bg='blue', bold=True)

    banner('Version Information')
    click.echo(config.version_info(ctx))

    banner('Configuration')
    locations = ctx.obj.cfg.locations(exists=False)
    locations = [(u'✔' if os.path.exists(i) else u'✘', click.pretty_path(i)) for i in locations]
    click.echo(u'The following configuration files are merged in order, if they exist:\n    {0}'.format(
        u'\n    '.join(u'{}   {}'.format(*i) for i in locations),
    ))

    banner('More Help')
    click.echo("Call '{} --help' to get a list of available commands & options.".format(app_name))
    click.echo("Call '{} «command» --help' to get help on a specific command.".format(app_name))
    click.echo("Call '{} --version' to get the above version information separately.".format(app_name))
    click.echo("Call '{} --license' to get licensing informatioon.".format(app_name))
コード例 #2
0
ファイル: help.py プロジェクト: 1and1/config-sesame
def help_command(ctx, config_dump=False):
    """Print some information on the system environment."""
    def banner(title):
        "Helper"
        click.echo('')
        click.secho('~~~ {} ~~~'.format(title), fg='green', bg='black', bold=True)

    if config_dump:
        ctx.obj.cfg.dump()
        sys.exit(0)

    app_name = ctx.find_root().info_name
    click.secho('*** "{}" Help & Information ***'.format(app_name), fg='white', bg='blue', bold=True)

    banner('Version Information')
    click.echo(config.version_info(ctx))

    banner('Configuration')
    locations = ctx.obj.cfg.locations(exists=False)
    locations = [(u'✔' if os.path.exists(i) else u'✘', click.pretty_path(i)) for i in locations]
    click.echo(u'The following configuration files are merged in order, if they exist:\n    {0}'.format(
        u'\n    '.join(u'{}   {}'.format(*i) for i in locations),
    ))

    banner('Vault Information')
    try:
        conn = vault.Connection()
    except ValueError as cause:
        if "target" in str(cause):
            click.serror("{} -- forgot to edit configuration or set VAULT_ADDR?", cause)
        else:
            raise
    else:
        print(conn)
        policies = conn.api.list_policies()
        if 'root' in policies:
            click.secho("WARN: You are connected using a 'root' token!",
                fg='yellow', bg='black', bold=True, reverse=True)
        print("Policies: {}".format(', '.join(policies)))
        print("Auth Backends:")
        for mount, data in conn.api.list_auth_backends().items():
            print("    {mount:15s} {type:15s} {description}".format(mount=mount, **data))
        print("Storage:")
        for mount, data in conn.api.list_secret_backends().items():
            print("    {mount:15s} {type:15s} {description}".format(mount=mount, **data))

    banner('More Help')
    click.echo("Call '{} --help' to get a list of available commands & options.".format(app_name))
    click.echo("Call '{} «command» --help' to get help on a specific command.".format(app_name))
    click.echo("Call '{} --version' to get the above version information separately.".format(app_name))
    click.echo("Call '{} --license' to get licensing informatioon.".format(app_name))
コード例 #3
0
ファイル: help.py プロジェクト: 1and1/confluencer
def help_command(ctx, config_dump=False):
    """Print some information on the system environment."""
    def banner(title):
        "Helper"
        click.echo('')
        click.secho('~~~ {} ~~~'.format(title), fg='green', bg='black', bold=True)

    if config_dump:
        ctx.obj.cfg.dump()
        sys.exit(0)

    app_name = ctx.find_root().info_name
    click.secho('*** "{}" Help & Information ***'.format(app_name), fg='white', bg='blue', bold=True)

    banner('Version Information')
    click.echo(config.version_info(ctx))

    banner('Configuration')
    locations = ctx.obj.cfg.locations(exists=False)
    locations = [(u'✔' if os.path.exists(i) else u'✘', click.pretty_path(i)) for i in locations]
    click.echo(u'The following configuration files are merged in order, if they exist:\n    {0}'.format(
        u'\n    '.join(u'{}   {}'.format(*i) for i in locations),
    ))

    banner('Confluence Stats')
    with api.context() as cf:
        try:
            spaces = list(cf.getall('space'))
        except api.ERRORS as cause:
            # Just log and otherwise ignore any errors
            click.serror("API ERROR: {}", cause)
        else:
            click.echo(u'{} spaces found.'.format(len(spaces)))
            click.echo(u'\nMost recently created:')
            for space in itertools.islice(sorted(spaces, key=lambda i: i.id, reverse=True), 5):
                click.echo(u'    {:10} {:>15} {}'.format(space.type, space.key, space.name))

    banner('More Help')
    click.echo("Call '{} --help' to get a list of available commands & options.".format(app_name))
    click.echo("Call '{} «command» --help' to get help on a specific command.".format(app_name))
    click.echo("Call '{} --version' to get the above version information separately.".format(app_name))
    click.echo("Call '{} --license' to get licensing informatioon.".format(app_name))
コード例 #4
0
def help_command(ctx, config_dump=False):
    """Print some information on the system environment."""
    def banner(title):
        "Helper"
        click.echo('')
        click.secho('~~~ {} ~~~'.format(title),
                    fg='green',
                    bg='black',
                    bold=True)

    if config_dump:
        ctx.obj.cfg.dump()
        sys.exit(0)

    app_name = ctx.find_root().info_name
    click.secho('*** "{}" Help & Information ***'.format(app_name),
                fg='white',
                bg='blue',
                bold=True)

    banner('Version Information')
    click.echo(config.version_info(ctx))

    banner('Configuration')
    locations = ctx.obj.cfg.locations(exists=False)
    locations = [(u'✔' if os.path.exists(i) else u'✘', click.pretty_path(i))
                 for i in locations]
    click.echo(
        u'The following configuration files are merged in order, if they exist:\n    {0}'
        .format(u'\n    '.join(u'{}   {}'.format(*i) for i in locations), ))

    banner('Confluence Stats')
    with api.context() as cf:
        try:
            user = cf.user()
            spaces = list(cf.getall('space'))
        except api.ERRORS as cause:
            # Just log and otherwise ignore any errors
            api.diagnostics(cause)
        else:
            click.echo(
                u'Confluence API [{u._info.server} / {u._info.sen}]'
                u' accessed as {u.displayName} [{u.username}].'.format(u=user))
            click.echo(u'{} spaces found.'.format(len(spaces)))
            click.echo(u'\nMost recently created:')
            for space in itertools.islice(
                    sorted(spaces, key=lambda i: i.id, reverse=True), 5):
                click.echo(u'    {:10} {:>15} {}'.format(
                    space.type, space.key, space.name))

    banner('More Help')
    click.echo(
        "Call '{} --help' to get a list of available commands & options.".
        format(app_name))
    click.echo(
        "Call '{} «command» --help' to get help on a specific command.".format(
            app_name))
    click.echo(
        "Call '{} --version' to get the above version information separately.".
        format(app_name))
    click.echo(
        "Call '{} --license' to get licensing informatioon.".format(app_name))
コード例 #5
0
def help_command(ctx, config_dump=False):
    """Print some information on the system environment."""
    def banner(title):
        "Helper"
        click.echo('')
        click.secho('~~~ {} ~~~'.format(title),
                    fg='green',
                    bg='black',
                    bold=True)

    if config_dump:
        ctx.obj.cfg.dump()
        sys.exit(0)

    app_name = ctx.find_root().info_name
    click.secho('*** "{}" Help & Information ***'.format(app_name),
                fg='white',
                bg='blue',
                bold=True)

    banner('Version Information')
    click.echo(config.version_info(ctx))

    banner('Configuration')
    locations = ctx.obj.cfg.locations(exists=False)
    locations = [(u'✔' if os.path.exists(i) else u'✘', click.pretty_path(i))
                 for i in locations]
    click.echo(
        u'The following configuration files are merged in order, if they exist:\n    {0}'
        .format(u'\n    '.join(u'{}   {}'.format(*i) for i in locations), ))

    banner('Active Login')
    try:
        api = github.api(config=None)  # TODO: config object
    except AssertionError as cause:
        click.serror("AUTH: {}", cause)
    else:
        try:
            dump_user(api, api.gh_config.user)
            limit = api.ratelimit_remaining
            fgcol = 'yellow' if limit >= 100 else 'cyan'
            click.secho('\n{} calls remaining in this hour.'.format(limit),
                        fg=fgcol,
                        bg='black',
                        bold=True)
        except ConnectionError as cause:
            click.serror("HTTP: {}", cause)
        except github.GitHubError as cause:
            click.serror(github.pretty_cause(cause, "API"))

    banner('More Help')
    click.echo(
        "Call '{} --help' to get a list of available commands & options.".
        format(app_name))
    click.echo(
        "Call '{} «command» --help' to get help on a specific command.".format(
            app_name))
    click.echo(
        "Call '{} --version' to get the above version information separately.".
        format(app_name))
    click.echo(
        "Call '{} --license' to get licensing informatioon.".format(app_name))