Ejemplo n.º 1
0
def get_new_command(command):
    m = re.search(regex, command.stderr.lower())
    new_command = m.group(1)
    return [
        shell.and_(new_command, command.script),
        shell.and_(new_command + " -k", command.script)
    ]
Ejemplo n.º 2
0
def get_new_command(command):
    cmds = command.script_parts
    machine = None
    if len(cmds) >= 3:
        machine = cmds[2]

    start_all_instances = shell.and_(u"vagrant up", command.script)
    if machine is None:
        return start_all_instances
    else:
        return [shell.and_(u"vagrant up {}".format(machine), command.script),
                start_all_instances]
Ejemplo n.º 3
0
def get_new_command(command):
    cmds = command.script_parts
    machine = None
    if len(cmds) >= 3:
        machine = cmds[2]

    start_all_instances = shell.and_(u"vagrant up", command.script)
    if machine is None:
        return start_all_instances
    else:
        return [
            shell.and_(u"vagrant up {}".format(machine), command.script),
            start_all_instances
        ]
Ejemplo n.º 4
0
def get_new_command(command):
    cmds = command.script_parts
    machine = None
    if len(cmds) >= 3:
        machine = cmds[2]

    startAllInstances = shell.and_("vagrant up", command.script)
    if machine is None:
        return startAllInstances
    else:
        return [
            shell.and_("vagrant up " + machine, command.script),
            startAllInstances
        ]
Ejemplo n.º 5
0
def get_new_command(command):
    missing_file = re.findall(
        r"error: pathspec '([^']*)' "
        r"did not match any file\(s\) known to git",
        command.output,
    )[0]
    closest_branch = utils.get_closest(missing_file,
                                       get_branches(),
                                       fallback_to_first=False)

    new_commands = []

    if closest_branch:
        new_commands.append(
            replace_argument(command.script, missing_file, closest_branch))
    if command.script_parts[1] == "checkout":
        new_commands.append(
            replace_argument(command.script, "checkout", "checkout -b"))

    if not new_commands:
        new_commands.append(
            shell.and_("git branch {}", "{}").format(missing_file,
                                                     command.script))

    return new_commands
Ejemplo n.º 6
0
def get_new_command(command):
    missing_file = re.findall(
            r"error: pathspec '([^']*)' "
            r"did not match any file\(s\) known to git.", command.stderr)[0]

    formatme = shell.and_('git add -- {}', '{}')
    return formatme.format(missing_file, command.script)
Ejemplo n.º 7
0
def get_new_command(command):
    missing_file = re.findall(
        r"error: pathspec '([^']*)' "
        r"did not match any file\(s\) known to git.", command.stderr)[0]

    formatme = shell.and_('git add -- {}', '{}')
    return formatme.format(missing_file, command.script)
def get_new_command(command):
    '''
    Prepends docker container rm -f {container ID} to
    the previous docker image rm {image ID} command
    '''
    container_id = command.output.strip().split(' ')
    return shell.and_('docker container rm -f {}',
                      '{}').format(container_id[-1], command.script)
def get_new_command(command):
    """
    Prepends docker container rm -f {container ID} to
    the previous docker image rm {image ID} command
    """
    container_id = command.output.strip().split(" ")
    return shell.and_("docker container rm -f {}",
                      "{}").format(container_id[-1], command.script)
Ejemplo n.º 10
0
def get_new_command(command):
    branch_name = re.findall(
        r"fatal: A branch named '([^']*)' already exists.", command.stderr)[0]
    new_command_templates = [['git branch -d {0}', 'git branch {0}'],
                             ['git branch -D {0}', 'git branch {0}'],
                             ['git checkout {0}']]
    for new_command_template in new_command_templates:
        yield shell.and_(*new_command_template).format(branch_name)
Ejemplo n.º 11
0
def get_new_command(command):
    packages = get_pkgfile(command.script)

    formatme = shell.and_('{} -S {}', '{}')
    return [
        formatme.format(pacman, package, command.script)
        for package in packages
    ]
Ejemplo n.º 12
0
def get_new_command(command):
    branch_name = first_0flag(command.script_parts)
    fixed_flag = branch_name.replace("0", "-")
    fixed_script = command.script.replace(branch_name, fixed_flag)
    if "A branch named '" in command.output and "' already exists." in command.output:
        delete_branch = u"git branch -D {}".format(branch_name)
        return shell.and_(delete_branch, fixed_script)
    return fixed_script
Ejemplo n.º 13
0
def get_new_command(command):
    stderr = command.stderr.strip()
    if is_arg_url(command):
        yield command.script.replace('open ', 'open http://')
    elif stderr.startswith('The file ') and stderr.endswith(' does not exist.'):
        arg = command.script.split(' ', 1)[1]
        for option in ['touch', 'mkdir']:
            yield shell.and_(u'{} {}'.format(option, arg), command.script)
Ejemplo n.º 14
0
def get_new_command(command):
    output = command.output.strip()
    if is_arg_url(command):
        yield command.script.replace("open ", "open http://")
    elif output.startswith("The file ") and output.endswith(
            " does not exist."):
        arg = command.script.split(" ", 1)[1]
        for option in ["touch", "mkdir"]:
            yield shell.and_(u"{} {}".format(option, arg), command.script)
Ejemplo n.º 15
0
def get_new_command(command):
    for pattern in patterns:
        file = re.findall(pattern, command.output)

        if file:
            file = file[0]
            dir = file[0:file.rfind('/')]

            formatme = shell.and_('mkdir -p {}', '{}')
            return formatme.format(dir, command.script)
Ejemplo n.º 16
0
def get_new_command(command):
    for pattern in patterns:
        file = re.findall(pattern, command.stderr)

        if file:
            file = file[0]
            dir = file[0:file.rfind('/')]

            formatme = shell.and_('mkdir -p {}', '{}')
            return formatme.format(dir, command.script)
Ejemplo n.º 17
0
def get_new_command(command):
    missing_file = re.findall(
        r"error: pathspec '([^']*)' "
        r"did not match any file\(s\) known to git.", command.stderr)[0]
    closest_branch = utils.get_closest(missing_file, get_branches(),
                                       fallback_to_first=False)
    if closest_branch:
        return replace_argument(command.script, missing_file, closest_branch)
    else:
        return shell.and_('git branch {}', '{}').format(
            missing_file, command.script)
def get_new_command(command):
    branch_name = re.findall(
        r"fatal: A branch named '(.+)' already exists.", command.output)[0]
    branch_name = branch_name.replace("'", r"\'")
    new_command_templates = [['git branch -d {0}', 'git branch {0}'],
                             ['git branch -d {0}', 'git checkout -b {0}'],
                             ['git branch -D {0}', 'git branch {0}'],
                             ['git branch -D {0}', 'git checkout -b {0}'],
                             ['git checkout {0}']]
    for new_command_template in new_command_templates:
        yield shell.and_(*new_command_template).format(branch_name)
Ejemplo n.º 19
0
def get_new_command(command):
    m = _search(command.output)

    # Note: there does not seem to be a standard for columns, so they are just
    # ignored by default
    if settings.fixcolcmd and 'col' in m.groupdict():
        editor_call = settings.fixcolcmd.format(editor=os.environ['EDITOR'],
                                                file=m.group('file'),
                                                line=m.group('line'),
                                                col=m.group('col'))
    else:
        editor_call = settings.fixlinecmd.format(editor=os.environ['EDITOR'],
                                                 file=m.group('file'),
                                                 line=m.group('line'))

    return shell.and_(editor_call, command.script)
Ejemplo n.º 20
0
def get_new_command(command):
    m = _search(command.stderr) or _search(command.stdout)

    # Note: there does not seem to be a standard for columns, so they are just
    # ignored by default
    if settings.fixcolcmd and 'col' in m.groupdict():
        editor_call = settings.fixcolcmd.format(editor=os.environ['EDITOR'],
                                                file=m.group('file'),
                                                line=m.group('line'),
                                                col=m.group('col'))
    else:
        editor_call = settings.fixlinecmd.format(editor=os.environ['EDITOR'],
                                                 file=m.group('file'),
                                                 line=m.group('line'))

    return shell.and_(editor_call, command.script)
Ejemplo n.º 21
0
def get_new_command(command):
    m = _search(command.output)

    # Note: there does not seem to be a standard for columns, so they are just
    # ignored by default
    if settings.fixcolcmd and "col" in m.groupdict():
        editor_call = settings.fixcolcmd.format(
            editor=os.environ["EDITOR"],
            file=m.group("file"),
            line=m.group("line"),
            col=m.group("col"),
        )
    else:
        editor_call = settings.fixlinecmd.format(editor=os.environ["EDITOR"],
                                                 file=m.group("file"),
                                                 line=m.group("line"))

    return shell.and_(editor_call, command.script)
Ejemplo n.º 22
0
def get_new_command(command):
    return shell.and_("git checkout master",
                      "{}").format(replace_argument(command.script, "-d",
                                                    "-D"))
Ejemplo n.º 23
0
def get_new_command(command):
    dir = shell.quote(_tar_file(command.script_parts)[1])
    return shell.and_('mkdir -p {dir}', '{cmd} -C {dir}') \
        .format(dir=dir, cmd=command.script)
def test_get_new_command():
    assert get_new_command(Command("git branch list", "")) == shell.and_(
        "git branch --delete list", "git branch")
Ejemplo n.º 25
0
def test_get_new_command():
    assert (get_new_command(Command('git branch list')) ==
            shell.and_('git branch --delete list', 'git branch'))
Ejemplo n.º 26
0
def get_new_command(command):
    path = re.findall(r"touch: (?:cannot touch ')?(.+)/.+'?:",
                      command.output)[0]
    return shell.and_(u'mkdir -p {}'.format(path), command.script)
Ejemplo n.º 27
0
def get_new_command(command):
    repl = shell.and_('mkdir -p \\1', 'cd \\1')
    return re.sub(r'^cd (.*)', repl, command.script)
Ejemplo n.º 28
0
def get_new_command(command):
    return shell.and_("tsuru login", command.script)
Ejemplo n.º 29
0
def get_new_command(command):
    executable = _get_executable(command)
    name = get_package(executable)
    formatme = shell.and_('sudo apt-get install {}', '{}')
    return formatme.format(name, command.script)
Ejemplo n.º 30
0
def get_new_command(command):
    brew_cask_script = _get_script_for_brew_cask(command.output)
    return shell.and_(brew_cask_script, command.script)
Ejemplo n.º 31
0
def _get_script_for_brew_cask(output):
    cask_install_lines = _get_cask_install_lines(output)
    if len(cask_install_lines) > 1:
        return shell.and_(*cask_install_lines)
    else:
        return cask_install_lines[0]
Ejemplo n.º 32
0
def get_new_command(command):
    formatme = shell.and_('git stash', '{}')
    return formatme.format(command.script)
Ejemplo n.º 33
0
def get_new_command(command):
    path = re.findall(r"touch: cannot touch '(.+)/.+':", command.output)[0]
    return shell.and_(u'mkdir -p {}'.format(path), command.script)
Ejemplo n.º 34
0
def get_new_command(command):
    return shell.and_(replace_argument(command.script, 'push', 'pull'),
                      command.script)
def get_new_command(command):
    return shell.and_('git branch --delete list', 'git branch')
Ejemplo n.º 36
0
def get_new_command(command):
    repl = shell.and_('mkdir -p \\1', 'cd \\1')
    return re.sub(r'^cd (.*)', repl, command.script)
Ejemplo n.º 37
0
def get_new_command(command):
    name = get_package(command.script)
    formatme = shell.and_('sudo apt-get install {}', '{}')
    return formatme.format(name, command.script)
Ejemplo n.º 38
0
def get_new_command(command):
    brew_cask_script = _get_script_for_brew_cask(command.output)
    return shell.and_(brew_cask_script, command.script)
Ejemplo n.º 39
0
def _get_script_for_brew_cask(output):
    cask_install_lines = _get_cask_install_lines(output)
    if len(cask_install_lines) > 1:
        return shell.and_(*cask_install_lines)
    else:
        return cask_install_lines[0]
Ejemplo n.º 40
0
def get_new_command(command):
    packages = get_pkgfile(command.script)

    formatme = shell.and_('{} -S {}', '{}')
    return [formatme.format(pacman, package, command.script)
            for package in packages]
Ejemplo n.º 41
0
def get_new_command(command):
    name = regex.findall(command.output)[0]
    return shell.and_('nix-env -iA {}'.format(name), command.script)
def get_new_command(command):
    return shell.and_('git stash', 'git pull', 'git stash pop')
Ejemplo n.º 43
0
def get_new_command(command):
    return shell.and_('tsuru login', command.script)
Ejemplo n.º 44
0
def get_new_command(command):
    return shell.and_(
        'chmod +x {}'.format(command.script_parts[0][2:]),
        command.script)
Ejemplo n.º 45
0
def get_new_command(command):
    return shell.and_("chmod +x {}".format(command.script_parts[0][2:]),
                      command.script)
Ejemplo n.º 46
0
def get_new_command(command):
    port = _get_used_port(command)
    pid = _get_pid_by_port(port)
    return shell.and_(u"kill {}".format(pid), command.script)
Ejemplo n.º 47
0
def get_new_command(command):
    missing_file = _get_missing_file(command)
    formatme = shell.and_('git add -- {}', '{}')
    return formatme.format(missing_file, command.script)
Ejemplo n.º 48
0
def get_new_command(command):
    return shell.and_('git add --update', 'git stash pop', 'git reset .')
Ejemplo n.º 49
0
def get_new_command(command):
    repl = shell.and_("mkdir -p \\1", "cd \\1")
    return re.sub(r"^cd (.*)", repl, command.script)
Ejemplo n.º 50
0
def get_new_command(command):
    line = command.output.split('\n')[-3].strip()
    branch = line.split(' ')[-1]
    set_upstream = line.replace('<remote>', 'origin')\
                       .replace('<branch>', branch)
    return shell.and_(set_upstream, command.script)