root/branch/3.3.1/testXML.py

Revision 686, 2.1 kB (checked in by mswat, 4 years ago)

Started new branch 3.3.1 - it will have steering, and other upgrades but probably not the new PyQt? player

Line 
1#!/usr/bin/env python
2#
3# testXML.py - test .xml configuration files
4#
5#
6# for cleaner output, might also want to comment out following lines in compucell3d.sh:
7# echo "Configuration file: $xmlFile"
8# echo "CompuCell3D - version $COMPUCELL3D_MAJOR_VERSION.$COMPUCELL3D_MINOR_VERSION.$COMPUCELL3D_BUILD_VERSION"
9
10
11import sys
12import string
13import re
14#import subprocess
15import os, time
16
17
18def processLine(line, output):
19#      line = string.strip(line) + "\n"   # if want to strip blanks
20
21      # for now, let's just do a simple replacement of Steps.
22      if string.find(line, "<Steps>") > -1:
23#        print 'found one: ' + line
24#        line = re.sub('\>','',line)
25#        print 'now line: ' + line
26        output.write( '<Steps>10</Steps>\n')
27      else:
28        output.write(line)
29
30def usage():
31    msg = """Usage:\n  testXML.py\n
32This script attempts to
33The converted code is printed on the standard output.
34
35"""
36    print msg
37
38def main():
39#    if len(sys.argv) < 2:
40#        usage()
41#        sys.exit(1)
42
43    count=0
44    outfile = 'tmp.xml'   # might want to do something different than copying to this config file
45    for id in os.walk('Demos'):
46      if count>0 and count<10:  # to test all, remove 'count<10' check
47        print count,'-->',id
48    #    print id[0],id[2]
49        for f in id[2]:
50    #      print f[-3:]
51          if f[-3:] == 'xml':
52    #        print 'yes, found xml:',f
53            fullf = os.path.join(id[0],f)
54            print fullf
55            input = open(fullf,'r')
56            output = open(outfile,'w')
57            for line in input.readlines():
58              processLine(line,output)
59            input.close()
60            output.close()
61      count+=1
62
63
64    # execute cc3d on this .xml config file
65    cmd = "./compucell3d.sh -i " + outfile
66    print cmd
67#    subprocess.call(cmd)
68    os.system(cmd)
69
70    # assuming you've redirected cerr and cout (from the player's main.cpp), concat to a master output file
71#    os.system("cat cc3d-out.txt >> cc3d-all.txt")
72#    os.system("echo '-------------------------------' >> cc3d-all.txt")
73    time.sleep(1)
74
75if __name__ == "__main__":
76    main()
Note: See TracBrowser for help on using the browser.