11#!/usr/bin/env python
22# -*- coding: utf-8 -*-
3+ """
4+ This script is intended for use debugging parse issues on replays.
5+
6+ sc2parse [FILES..]
7+
8+ Recursively parses all the files. When exceptions are thrown it catches them
9+ and attempts to print out any information that might be needed for debug. If
10+ information you need isn't available feel free to add new handlers or add to
11+ existing exception handlers.
12+
13+ Also sets logging to INFO so that missing unit type and ability type messages
14+ are caught and reported. At some point these things should be moved to WARN.
15+
16+ If there are parse exceptions, this script should be run to generate an info
17+ for the ticket filed.
18+ """
319
420import sys
521import sc2reader
622import traceback
723
8- sc2reader .useFileCache ( '/home/graylin/projects/sc2reader/local_cache ' )
24+ sc2reader .log_utils . log_to_console ( 'INFO ' )
925
1026def main ():
1127 for argument in sys .argv [1 :]:
12- for path in sc2reader .utils .get_files (argument ):
28+ for path in sc2reader .utils .get_files (argument , extension = 'SC2Replay' ):
1329 try :
1430 replay = sc2reader .load_replay (path , debug = True , verbose = True )
1531 except sc2reader .exceptions .ReadError as e :
16- print e .replay .filename
32+ print
33+ print path
1734 print '{build} - {real_type} on {map_name} - Played {start_time}' .format (** e .replay .__dict__ )
1835 print '[ERROR]' , e .message
1936 for event in e .game_events [- 5 :]:
@@ -22,6 +39,7 @@ def main():
2239 print e .buffer .peek (50 ).encode ('hex' )
2340 print
2441 except Exception as e :
42+ print
2543 print path
2644 replay = sc2reader .load_replay (path , debug = True , load_level = 1 )
2745 print '{build} - {real_type} on {map_name} - Played {start_time}' .format (** replay .__dict__ )
@@ -35,7 +53,5 @@ def main():
3553 print
3654
3755
38-
39-
4056if __name__ == '__main__' :
4157 main ()
0 commit comments