sbsv2/raptor/bin/recipestats.py
branchwip
changeset 88 b5820d0f3a1c
parent 87 01cb4707f979
child 92 6ebd8f14df45
equal deleted inserted replaced
87:01cb4707f979 88:b5820d0f3a1c
       
     1 #!/usr/bin/env python
     1 #
     2 #
     2 # Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 # Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 # All rights reserved.
     4 # All rights reserved.
     4 # This component and the accompanying materials are made available
     5 # This component and the accompanying materials are made available
     5 # under the terms of the License "Eclipse Public License v1.0"
     6 # under the terms of the License "Eclipse Public License v1.0"
    63 	f = sys.stdin
    64 	f = sys.stdin
    64 	st = RecipeStats()
    65 	st = RecipeStats()
    65 
    66 
    66 	recipe_re = re.compile(".*<recipe name='([^']+)'.*")
    67 	recipe_re = re.compile(".*<recipe name='([^']+)'.*")
    67 	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]+)'.*")
    68 	status_re = re.compile(".*<status exit='([^']*)'.*")
    69 	status_re = re.compile(".*<status exit='(?P<exit>(ok|failed))'( *code='(?P<code>[0-9]+)')?.*")
    69 
    70 
    70 	alternating = 0
    71 	alternating = 0
    71 	start_time = 0.0
    72 	start_time = 0.0
    72 
    73 
    73 	
    74 	
    74 	for l in f.xreadlines():
    75 	for l in f.xreadlines():
    75 		l2 = l.rstrip("\n")
    76 		l2 = l.rstrip("\n\r")
    76 		rm = recipe_re.match(l2)
    77 		rm = recipe_re.match(l2)
    77 
    78 
    78 		if rm is not None:
    79 		if rm is not None:
    79 			rname = rm.groups()[0]
    80 			rname = rm.groups()[0]
    80 			continue
    81 			continue
    81 
    82 
    82 
    83 
    83 		tm = time_re.match(l2)
    84 		tm = time_re.match(l2)
    84 		if tm is not None:
    85 		if tm is not None:
    85 			s = float(tm.groups()[0])
    86 			try:
    86 			elapsed = float(tm.groups()[1])
    87 				s = float(tm.groups()[0])
       
    88 				elapsed = float(tm.groups()[1])
    87 
    89 
    88 			if start_time == 0.0:
    90 				if start_time == 0.0:
    89 				start_time = s
    91 					start_time = s
    90 
    92 
    91 			s -= start_time
    93 				s -= start_time
    92 
    94 
    93 			#print s,elapsed
    95 				#print s,elapsed
    94 			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)
    95 
   102 
    96 		sm = status_re.match(l2)
   103 		sm = status_re.match(l2)
    97 
   104 
    98 		if sm is None:
   105 		if sm is None:
    99 			continue
   106 			continue
   100 
   107 
   101 		if sm.groups()[0] == 'ok':
   108 		if sm.groupdict()['exit'] == 'ok':
   102 			status = 0
   109 			status = 0
   103 		else:
   110 		else:
   104 			status = int(sm.groups()[0])
   111 			status = int(sm.groupdict()['code'])
   105 
   112 
   106 		st.add(s, elapsed, rname, status)
   113 		st.add(s, elapsed, rname, status)
   107 
   114 
   108 	print st.recipe_csv()
   115 	print st.recipe_csv()
   109 
   116