예제 #1
0
 def validate_move(kill_tmux):
     moves = [m for m in self.queue if m.kill_tmux == kill_tmux]
     if moves:
         prompt = highlight("About to perform the following moves")
         if kill_tmux:
             prompt += highlight(" and kill the associated tmux sessions")
         self.ui.check_permission(
             prompt + ":", *[f"{m.src} -> {m.dest}" for m in self.queue]
         )
예제 #2
0
    def process(self, run: RunEntry):
        tmux = self.tmux(run.path)
        for dir_path in self.file_system.dir_paths(run.path):
            dir_path.mkdir(exist_ok=True, parents=True)

        tmux.new(window_name=run.description, command=run.command)
        self.db.append(run)
        self.ui.print(highlight('Path:'),
                      str(run.path),
                      highlight('Description:'),
                      run.description,
                      highlight('Command sent to session:'),
                      run.command,
                      highlight('List active:'),
                      'tmux list-session',
                      highlight('Attach:'),
                      f'tmux attach -t {tmux}',
                      '',
                      sep='\n')
예제 #3
0
def strings(runs: List[RunEntry], key: str, porcelain: bool) -> List[str]:
    if key == "all":
        for entry in runs:
            yield str(entry)
    else:
        attr_dict = get_dict(runs=runs, key=key)
        if porcelain:
            for value in attr_dict.values():
                yield str(value)
        else:
            for path, attr in attr_dict.items():
                yield highlight(path, ": ", sep="") + str(attr)
예제 #4
0
    def process(self, run: RunEntry):
        tmux = self.tmux(run.path)
        for dir_path in self.file_system.dir_paths(run.path):
            dir_path.mkdir(exist_ok=True, parents=True)

        tmux.new(window_name=run.description, command=str(run.command))
        self.db.append(run)
        self.ui.print(
            highlight("Path:"),
            str(run.path),
            highlight("Description:"),
            run.description,
            highlight("Command sent to session:"),
            run.command,
            highlight("List active:"),
            "tmux list-session",
            highlight("Attach:"),
            f"tmux attach -t '{tmux}'",
            "",
            sep="\n",
        )
예제 #5
0
def strings(
    runs: List[RunEntry],
    args: List[str],
    prefix: str,
    db: DataBase,
    description: Optional[str],
    path: Optional[PurePath],
    porcelain: bool,
):
    entry_dict = defaultdict(list)
    return_strings = [] if porcelain else [highlight("To reproduce:")]
    for entry in runs:
        entry_dict[entry.commit].append(entry)
    for commit, entries in entry_dict.items():
        return_strings.append(f"git checkout {commit}")
        string = "runs new"
        for i, entry in enumerate(entries):
            if path is None:
                new_path = entry.path
            elif len(entries) > 1:
                new_path = PurePath(path, str(i))
            else:
                new_path = path

            command = Command(entry.command, path=entry.path)
            command = command.exclude(prefix, *args)
            new_path, command, _description = map(
                json.dumps,
                [
                    str(new_path),
                    str(command),
                    description or entry.description.strip('"').strip("'"),
                ],
            )
            join_string = " " if len(entries) == 1 else " \\\n"
            string = join_string.join(
                [
                    string,
                    f"--path={new_path}",
                    f"--command={command}",
                    f"--description={_description}",
                ]
            )
        return_strings.append(string)
    return return_strings
예제 #6
0
def strings(runs: List[RunEntry], flags: List[str], prefix: str, db: DataBase,
            path: Optional[PurePath], description: Optional[str]):
    entry_dict = defaultdict(list)
    return_strings = [highlight('To reproduce:')]
    for entry in runs:
        entry_dict[entry.commit].append(entry)
    for commit, entries in entry_dict.items():
        return_strings.append(f'git checkout {commit}')
        command_string = 'runs new'
        for i, entry in enumerate(entries):
            if path is None:
                new_path = entry.path
            elif len(entries) > 1:
                new_path = PurePath(path, str(i))
            else:
                new_path = path

            subcommand = get_command_string(
                path=PurePath(new_path),
                prefix=prefix,
                command=entry.command,
                flags=flags)
            new_path, subcommand, _description = map(json.dumps, [
                str(new_path), subcommand, description
                or entry.description.strip('"').strip("'")
            ])
            if len(entries) == 1:
                command_string += f' {new_path} {subcommand} --description={_description}'
            else:
                command_string = ' \\\n  '.join([
                    command_string,
                    f'--path={new_path}',
                    f'--command={subcommand}',
                    f'--description={_description}',
                ])
        return_strings.append(command_string)
    return return_strings