Exemplo n.º 1
0
def add_commands(appliance):
    sandbox_help = "Start {} CLI REPL".format(config_utils.appliance_name())
    exit_sandbox_help = "Exit the {} CLI".format(config_utils.appliance_name())

    @appliance.command(help=sandbox_help)
    def sandbox():

        # `exit` is defined only when in the `sandbox` REPL.
        @appliance.command(help=exit_sandbox_help)
        def exit():
            raise ExitSandboxException()

        @appliance.command(help=exit_sandbox_help)
        def quit():
            raise ExitSandboxException()

        try:
            repl(
                click.get_current_context(),
                prompt_kwargs=_prompt_kwargs(),
                allow_system_commands=False,
                allow_internal_commands=False,
            )
        except ExitSandboxException:
            return
Exemplo n.º 2
0
def add_commands(appliance):
    sandbox_help = "Start {} CLI REPL".format(config_utils.appliance_name())
    exit_sandbox_help = "Exit the {} CLI".format(config_utils.appliance_name())

    @appliance.command(help=sandbox_help)
    def sandbox():

        # `exit` is defined only when in the `sandbox` REPL.
        @appliance.command(help=exit_sandbox_help)
        def exit():
            raise ExitSandboxException()

        @appliance.group(help='Toggle advanced mode')
        def advanced():
            pass

        @advanced.command(help='Enable advanced mode')
        def enable():
            toggle_advanced_mode(True)

        @advanced.command(help='Disable advanced mode')
        def disable():
            toggle_advanced_mode(False)

        try:
            repl(
                click.get_current_context(),
                prompt_kwargs=_prompt_kwargs(),
                allow_system_commands=False,
                allow_internal_commands=False,
            )
        except ExitSandboxException:
            return
Exemplo n.º 3
0
def _eject_failure_message():
    incorrect_code = text.failure('Incorrect eject code given.')
    contact_support = text.line_wrap(
        'Please contact the Alces Flight Support team at '
        '[email protected] if you are encountering difficulty ejecting '
        "your Flight {}.".format(config_utils.appliance_name()))

    return text.join_lines(incorrect_code, contact_support)
Exemplo n.º 4
0
def _eject_confirmation_message():
    info = text.line_wrap(CONFIG.SUPPORT_EJECT_INFO_MESSAGE)
    support_warning = text.line_wrap(
        text.bold('This will opt you out from any obligation for Alces Flight '
                  "Ltd to provide you with support for your Flight {}.".format(
                      config_utils.appliance_name())))
    continue_prompt = text.info('Continue?')

    return text.join_lines(info, support_warning, continue_prompt)
Exemplo n.º 5
0
def add_commands(appliance):

    if utils.in_sandbox():
        return

    @appliance.group(help='Manage Alces Flight Support access')
    def support():
        pass

    @support.command(help='Enable Alces Flight Support access')
    @click.argument('url')
    def enable(url):
        if _support_access_enabled():
            raise click.ClickException(
                'Alces Flight Support access already enabled.')
        else:
            _enable_support_access(url)

    @support.command(help='Disable Alces Flight Support access')
    def disable():
        if not _support_access_enabled():
            raise click.ClickException(
                'Alces Flight Support access already disabled.')
        elif click.confirm(_disable_confirmation_message()):
            _disable_support_access()

    @support.command(help='Display Alces Flight Support status')
    def status():
        eject_info = 'Alces Flight Support: {}'.format(
            _support_coverage_status())
        access_info = 'Alces Flight Support access: {}'.format(
            _support_access_status())
        status = text.join_lines(eject_info, access_info)

        click.echo(status)

    eject_help = "Eject Flight {} support".format(
        config_utils.appliance_name())

    @support.command(help=eject_help)
    @click.argument('eject_code')
    def eject(eject_code):
        if click.confirm(_eject_confirmation_message()):
            _eject_appliance(eject_code)