Example #1
0
def create_rattletrap_command(replay_path: str, output_path: str, overwrite: bool = True, rattletrap_path: str = None) \
        -> List[str]:
    """
    Takes a path to the replay and outputs the json of that replay.

    :param replay_path: Path to a specific replay.
    :param output_path: The output path of rattletrap.
    :param overwrite: True if we should recreate the json even if it already exists.
    :param rattletrap_path: Custom location for rattletrap executable.
    :return: The json created from rattle trap.
    """
    if rattletrap_path is None:
        rattletrap_path = get_rattletrap_path()
    binaries = get_rattletrap_binaries(rattletrap_path)
    if len(binaries) == 0:
        logger.warning("Need to redownload rattletrap")
        download_rattletrap()
        binaries = get_rattletrap_binaries(rattletrap_path)
    binary = get_binary_for_platform(pt.system(), binaries)
    if binary is None:
        logger.warning('no binary!')
    cmd = [
        os.path.join(rattletrap_path, '{}'.format(binary)), '--compact', '-i',
        replay_path
    ]
    if output_path:
        output_dirs = os.path.dirname(output_path)
        if not os.path.isdir(output_dirs) and output_dirs != '':
            os.makedirs(output_dirs)
        if overwrite or not os.path.isfile(output_path):
            cmd += ['--output', output_path]

    return cmd
Example #2
0
    def test_rattle(self):
        self.cleanup()

        download_rattletrap()