import os, hashlib, urllib2, json, sys sys.path += ['.', '..'] from whyattend import replays TRACKER_URL = sys.argv[1] if __name__ == '__main__': checksums = json.load( urllib2.urlopen(TRACKER_URL + '/api/battle-checksums'))['hashes'] for root, subfolders, files in os.walk(sys.argv[2]): for file in files: if not file.endswith('.wotreplay'): continue try: replay_blob = open(os.path.join(root, file), 'rb').read() replay = replays.parse_replay(replay_blob) if not replays.is_cw(replay): continue hash = hashlib.sha1() hash.update(''.join(sorted(replays.player_team(replay)))) hash.update(replays.guess_enemy_clan(replay)) hash.update(replay['first']['mapName']) if hash.hexdigest() not in checksums: print file, 'is an unknown CW replay!' except Exception as e: pass #print "Error processing " + file + " " + str(e)
if __name__ == '__main__': for root, subfolders, files in os.walk(config.UPLOAD_FOLDER): for file in files: try: replay_blob = open(os.path.join(root, file), 'rb').read() replay = replays.parse_replay(replay_blob) if not replay['first'] or not replay['second']: print "Skipping incomplete replay " + file continue if not replays.is_cw(replay): print "Skipping non-CW-replay " + file continue date = datetime.datetime.strptime(replay['first']['dateTime'], '%d.%m.%Y %H:%M:%S') clan = replays.guess_clan(replay) enemy_clan = replays.guess_enemy_clan(replay) battle = Battle.query.filter_by(clan=clan, enemy_clan=enemy_clan, date=date).first() if not battle: print "Could not find matching battle for file " + file continue if battle.replay.replay_blob: print "Skipping battle " + str( battle.id) + " that already has a replay blob" continue battle.replay.replay_blob = replay_blob print "Adding replay " + file + " for battle " + str( battle.id) + " " + battle.enemy_clan
if __name__ == '__main__': for root, subfolders, files in os.walk(config.UPLOAD_FOLDER): for file in files: try: replay_blob = open(os.path.join(root, file), 'rb').read() replay = replays.parse_replay(replay_blob) if not replay['first'] or not replay['second']: print "Skipping incomplete replay " + file continue if not replays.is_cw(replay): print "Skipping non-CW-replay " + file continue date = datetime.datetime.strptime(replay['first']['dateTime'], '%d.%m.%Y %H:%M:%S') clan = replays.guess_clan(replay) enemy_clan = replays.guess_enemy_clan(replay) battle = Battle.query.filter_by(clan=clan, enemy_clan=enemy_clan, date=date).first() if not battle: print "Could not find matching battle for file " + file continue if battle.replay.replay_blob: print "Skipping battle " + str(battle.id) + " that already has a replay blob" continue battle.replay.replay_blob = replay_blob print "Adding replay " + file + " for battle " + str(battle.id) + " " + battle.enemy_clan db_session.add(battle.replay) db_session.commit() except Exception as e: print "Error processing " + file + " " + str(e)
import os, hashlib, urllib2, json, sys sys.path += ['.', '..'] from whyattend import replays TRACKER_URL = sys.argv[1] if __name__ == '__main__': checksums = json.load(urllib2.urlopen(TRACKER_URL + '/api/battle-checksums'))['hashes'] for root, subfolders, files in os.walk(sys.argv[2]): for file in files: if not file.endswith('.wotreplay'): continue try: replay_blob = open(os.path.join(root, file), 'rb').read() replay = replays.parse_replay(replay_blob) if not replays.is_cw(replay): continue hash = hashlib.sha1() hash.update(''.join(sorted(replays.player_team(replay)))) hash.update(replays.guess_enemy_clan(replay)) hash.update(replay['first']['mapName']) if hash.hexdigest() not in checksums: print file, 'is an unknown CW replay!' except Exception as e: pass #print "Error processing " + file + " " + str(e)