Пример #1
0
def save_replay(proto_game, replay_to_parse_path, parsed_data_path) -> str:
    """
    :param proto_game: Representing the parsed data.
    :param replay_to_parse_path: The file path to the replay we want to parse.
    :param parsed_data_path: The path to parsed data with the initial unparsed filename.
    :return: The replay ID.
    """
    replay_id = proto_game.game_metadata.match_guid
    if replay_id == '':
        replay_id = proto_game.game_metadata.id

    replay_path = FileManager.get_replay_path(replay_id)
    proto_path = FileManager.get_proto_path(replay_id)
    pandas_path = FileManager.get_pandas_path(replay_id)
    shutil.move(replay_to_parse_path, replay_path)
    shutil.move(parsed_data_path + '.pts', proto_path)
    shutil.move(parsed_data_path + '.gzip', pandas_path)

    result = upload_replay(replay_path)
    if result is not None:
        upload_proto(proto_path)
        upload_df(pandas_path)

        os.remove(replay_path)
        os.remove(proto_path)
        os.remove(pandas_path)

    return replay_id
Пример #2
0
def download_replay(id_):
    filename = id_ + ".replay"
    path = FileManager.get_replay_path(id_)
    if os.path.isfile(path):
        return send_from_directory(current_app.config['REPLAY_DIR'], filename, as_attachment=True)
    elif config is not None and hasattr(config, 'GCP_BUCKET_URL'):
        return redirect(config.GCP_BUCKET_URL + filename)
    return "Replay not found", 404
Пример #3
0
def download_replay(id_):
    filename = id_ + ".replay"
    path = FileManager.get_replay_path(id_)
    if os.path.isfile(path):
        return send_from_directory(current_app.config['REPLAY_DIR'],
                                   filename,
                                   as_attachment=True)
    return redirect(get_replay_url(id_))