mail[Wesnoth-commits] r36523 - /trunk/utils/ai_test/ai_test.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by terraninfo on July 02, 2009 - 17:03:
Author: crab
Date: Thu Jul  2 17:03:19 2009
New Revision: 36523

URL: http://svn.gna.org/viewcvs/wesnoth?rev=36523&view=rev
Log:
update of ai testing script

Modified:
    trunk/utils/ai_test/ai_test.py

Modified: trunk/utils/ai_test/ai_test.py
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/ai_test/ai_test.py?rev=36523&r1=36522&r2=36523&view=diff
==============================================================================
--- trunk/utils/ai_test/ai_test.py (original)
+++ trunk/utils/ai_test/ai_test.py Thu Jul  2 17:03:19 2009
@@ -20,7 +20,7 @@
        map = ''
        svn_release = '0'
        test = 'default'
-       turn = '0'
+       end_turn = '0'
        version_string = ''
        winner_side = '0'
        
@@ -59,7 +59,7 @@
        print 'Running: '+command_line
        start = time()
        p = Popen(command_line, shell=True, stdout=PIPE, stderr=PIPE)
-       outlines = p.stdout.readlines()
+       # outlines = p.stdout.readlines()
        outerrlines = p.stderr.readlines()
        print 'Finished'
        for line in outerrlines:
@@ -80,14 +80,18 @@
                        if ((n1>-1) and (n2>-1) and (n2>n1)):
                                sz = s[n1+1:n2]
                                #parse local_modifications
+                               n3 = sz.rfind('M')
+                               if (n3>-1):
+                                       sz = sz[:n3]
+                                       game_result.local_modifications = 1
                                #parse svn_release
                                game_result.svn_release = sz
                        continue
 
-               n,s = do_filter(str,'info ai/testing: VICTORY_TURN:')
+               n,s = do_filter(str,'info ai/testing: GAME_END_TURN:')
                if (n>-1):
                        #print 'AND THE VICTORY_TURN IS: '+s    
-                       game_result.turn = s
+                       game_result.end_turn = s
                        continue
 
                n,s = do_filter(str,'info ai/testing: AI_IDENTIFIER1:')
@@ -121,16 +125,13 @@
                print 'stderr:'
                for line in outerrlines:
                        print filter_non_printable(line.strip())
-               print 'stdout:'
-               for line in outlines:
-                       print filter_non_printable(line.strip())
                print '===================='    
                
        return game_result
 
 def save_result(cfg,game_result):
        print 'Saving to DB....'
-       query = 'insert into 
game(ai_config1,ai_config2,ai_ident1,ai_ident2,duration,faction1,faction2,is_success,local_modifications,map,svn_release,test,turn,version_string,winner_side)
 values (%s,%s,%s,%s,cast(%s as double precision),%s,%s,cast(%s as 
boolean),cast(%s as boolean),%s,cast(%s as int),%s,cast(%s as int),%s,cast(%s 
as int))'
+       query = 'insert into 
game(ai_config1,ai_config2,ai_ident1,ai_ident2,duration,faction1,faction2,is_success,local_modifications,map,svn_release,test,end_turn,version_string,winner_side)
 values (%s,%s,%s,%s,cast(%s as double precision),%s,%s,cast(%s as 
boolean),cast(%s as boolean),%s,cast(%s as int),%s,cast(%s as int),%s,cast(%s 
as int))'
        db_ip = cfg.get('default','db_ip')
        db_port = cfg.getint('default','db_port')
        db_name = cfg.get('default','db_name')
@@ -139,7 +140,7 @@
 
        dbconnection = 
PgSQL.connect(database=db_name,host=db_ip,port=db_port,user=db_user,password=db_pass)
        cu = dbconnection.cursor()
-       cu.execute(query, game_result.ai_config1, game_result.ai_config2, 
game_result.ai_ident1, game_result.ai_ident2, game_result.duration, 
game_result.faction1, game_result.faction2, game_result.is_success, 
game_result.local_modifications, game_result.map, game_result.svn_release, 
game_result.test, game_result.turn, game_result.version_string, 
game_result.winner_side)
+       cu.execute(query, game_result.ai_config1, game_result.ai_config2, 
game_result.ai_ident1, game_result.ai_ident2, game_result.duration, 
game_result.faction1, game_result.faction2, game_result.is_success, 
game_result.local_modifications, game_result.map, game_result.svn_release, 
game_result.test, game_result.end_turn, game_result.version_string, 
game_result.winner_side)
        cu.execute('commit')
        dbconnection.close()
        print 'Saved to DB'




Related Messages


Powered by MHonArc, Updated Thu Jul 02 23:40:36 2009