64 f = sys.stdin |
64 f = sys.stdin |
65 st = RecipeStats() |
65 st = RecipeStats() |
66 |
66 |
67 recipe_re = re.compile(".*<recipe name='([^']+)'.*") |
67 recipe_re = re.compile(".*<recipe name='([^']+)'.*") |
68 time_re = re.compile(".*<time start='([0-9]+\.[0-9]+)' *elapsed='([0-9]+\.[0-9]+)'.*") |
68 time_re = re.compile(".*<time start='([0-9]+\.[0-9]+)' *elapsed='([0-9]+\.[0-9]+)'.*") |
69 status_re = re.compile(".*<status exit='([^']*)'.*") |
69 status_re = re.compile(".*<status exit='(?P<exit>(ok|failed))'( *code='(?P<code>[0-9]+)')?.*") |
70 |
70 |
71 alternating = 0 |
71 alternating = 0 |
72 start_time = 0.0 |
72 start_time = 0.0 |
73 |
73 |
74 |
74 |
75 for l in f.xreadlines(): |
75 for l in f.xreadlines(): |
76 l2 = l.rstrip("\n") |
76 l2 = l.rstrip("\n\r") |
77 rm = recipe_re.match(l2) |
77 rm = recipe_re.match(l2) |
78 |
78 |
79 if rm is not None: |
79 if rm is not None: |
80 rname = rm.groups()[0] |
80 rname = rm.groups()[0] |
81 continue |
81 continue |
82 |
82 |
83 |
83 |
84 tm = time_re.match(l2) |
84 tm = time_re.match(l2) |
85 if tm is not None: |
85 if tm is not None: |
86 s = float(tm.groups()[0]) |
86 try: |
87 elapsed = float(tm.groups()[1]) |
87 s = float(tm.groups()[0]) |
|
88 elapsed = float(tm.groups()[1]) |
88 |
89 |
89 if start_time == 0.0: |
90 if start_time == 0.0: |
90 start_time = s |
91 start_time = s |
91 |
92 |
92 s -= start_time |
93 s -= start_time |
93 |
94 |
94 #print s,elapsed |
95 #print s,elapsed |
95 continue |
96 continue |
|
97 except ValueError, e: |
|
98 raise Exception("Parse problem: float conversion on these groups: %s\n%s" %(str(tm.groups()), str(e))) |
|
99 else: |
|
100 if l2.find("<time") is not -1: |
|
101 raise Exception("unparsed timing status: %s\n"%l2) |
96 |
102 |
97 sm = status_re.match(l2) |
103 sm = status_re.match(l2) |
98 |
104 |
99 if sm is None: |
105 if sm is None: |
100 continue |
106 continue |
101 |
107 |
102 if sm.groups()[0] == 'ok': |
108 if sm.groupdict()['exit'] == 'ok': |
103 status = 0 |
109 status = 0 |
104 else: |
110 else: |
105 status = int(sm.groups()[0]) |
111 status = int(sm.groupdict()['code']) |
106 |
112 |
107 st.add(s, elapsed, rname, status) |
113 st.add(s, elapsed, rname, status) |
108 |
114 |
109 print st.recipe_csv() |
115 print st.recipe_csv() |
110 |
116 |