Exemple #1
0
    def execute(self, show_script, shell):
        output = ''
        if show_script and shell:
            cmd_name = self._bsm.config('app')['cmd_name']
            app_root = self._bsm.config('app').get('app_root', '')

            shell = Shell(shell, cmd_name, app_root)
            shell.add_script('exit')
            output = shell.script

        self._bsm.exit()

        return CmdResult(output=output, script_types='exit')
Exemple #2
0
    def execute(self, show_script, shell):
        output = ''
        if show_script and shell:
            cmd_name = self._bsm.config('app')['cmd_name']
            app_root = self._bsm.config('app').get('app_root', '')

            shell = Shell(shell, cmd_name, app_root)
            shell.add_script('init')
            output = shell.script

#        self._bsm.default_load()

        return CmdResult(output, 'init')
Exemple #3
0
def shell_with_cmd(request):
    return Shell(request.param[0], 'test_bsm', '/fake_app_root'), request.param[1]
Exemple #4
0
def shell(request):
    return Shell(request.param, 'test_bsm', '/fake_app_root')
Exemple #5
0
def _generate_script(cmd_name, app_root, shell_name, output, env_changes, script_types):
    try:
        shell = Shell(shell_name, cmd_name, app_root)
    except Exception as e:
        raise CmdError('Can not load shell "{0}": {1}'.format(shell_name, e))

    shell.comment('Setup env and alias')
    shell.add_env(env_changes)

    shell.newline()
    shell.comment('Add definition script')
    for st in script_types:
        shell.add_script(st)

    shell.newline()
    shell.comment('Final output')
    if output:
        shell.echo(output)

    shell.newline()
    shell.comment('Shell script finished')

    return shell.script
Exemple #6
0
def _generate_script(cmd_name, app_root, shell_name, output, commands, env_changes, script_types):
    try:
        shell = Shell(shell_name, cmd_name, app_root)
    except Exception as e:
        raise CmdError('Can not load shell "{0}": {1}'.format(shell_name, e))

    shell.comment('Setup env and alias')
    shell.add_env(env_changes)

    shell.newline()
    shell.comment('Add definition script')
    for st in script_types:
        shell.add_script(st)

    shell.newline()
    shell.comment('Run commands')
    for command in commands:
        cmd = command.get('cmd', [])
        cwd = command.get('cwd', None)
        if cmd:
            shell.output('='*80)
            shell.output('= Start to run: {0}'.format(cmd))
            if cwd is not None:
                shell.output('= Cwd: {0}'.format(cwd))
            shell.run(cmd, cwd)
            shell.output('- End command')
            shell.output('-'*80)

    shell.newline()
    shell.comment('Final output')
    if output:
        shell.output(output)

    shell.newline()
    shell.comment('Shell script finished')

    return shell.script
Exemple #7
0
    def execute(self, shell):
        cmd_name = self._bsm.config('app')['cmd_name']
        app_root = self._bsm.config('app').get('app_root', '')

        shell = Shell(shell, cmd_name, app_root)
        return shell.setup_script()