scripts/python/issuelister.py
changeset 14 6015c630283e
equal deleted inserted replaced
13:32a0da1099d8 14:6015c630283e
       
     1 import xml.dom.minidom
       
     2 import sys
       
     3 
       
     4 headers = []
       
     5 libraryissues = []
       
     6 
       
     7 def loadfile(filename):
       
     8 	x = xml.dom.minidom.parse(filename)
       
     9 	issuelists=x.getElementsByTagName('issuelist')
       
    10 
       
    11 	
       
    12 	for issuelist in issuelists:
       
    13 		for cn in issuelist.childNodes:
       
    14 			if isinstance(cn, xml.dom.minidom.Element):
       
    15 				if cn.nodeName == 'library':
       
    16 					libraryissues.append(cn)
       
    17 				elif cn.nodeName == 'headerfile':
       
    18 					headers.append(cn)
       
    19 
       
    20 
       
    21 typeidmap=['removed', '','moved','deleted','inserted','modified','added','modified','modified','modified','modified','modified','removed','N/A','','']
       
    22 
       
    23 noktypemaphdr={
       
    24 			'NOK': 'This header contains changes that cause incompatibility. It must be fixed.', 
       
    25 			'MOK': 'This header contains changes that cannot be verified automatically; they must be investigated manually.'}
       
    26 
       
    27 ioktypehdr='This issue is known to be ok. But the header contains other unrelated changes.'
       
    28 oktypehdr='This header is known to be ok.'
       
    29 othertypehdr='This header contains changes that may cause incompatibility. It must be analysed by an expert.'
       
    30 
       
    31 oktype='This library is known to be ok'
       
    32 noktype='This library contains changes that cause incompatibility. It must be fixed.'
       
    33 othertype='This library contains changes that may cause incompatibility. It must be analysed by an expert.'
       
    34 
       
    35 #
       
    36 #
       
    37 #typeidmap=['removed', '','moved','deleted','inserted','modified','added','modified','modified','modified','modified','modified','removed','N/A','','']
       
    38 #
       
    39 #oktypemaphdr={'OK': 'This header is known to be ok.',
       
    40 #			'NOK': 'This header contains changes that cause incompatibility. It must be fixed.', 
       
    41 #			'IOK': 'This issue is known to be ok. But the header contains other unrelated changes.', 
       
    42 #			'MOK': 'This header contains changes that cannot be verified automatically; they must be investigated manually.'}
       
    43 #
       
    44 #othertypemaphdr='This header contains changes that may cause incompatibility. It must be analysed by an expert.'
       
    45 #
       
    46 #oktype='This library is known to be ok'
       
    47 #noktype='This library contains changes that cause incompatibility. It must be fixed.'
       
    48 #othertype='This library contains changes that may cause incompatibility. It must be analysed by an expert.'
       
    49 
       
    50 
       
    51 				
       
    52 
       
    53 def print_errors(library, isok=False):
       
    54 
       
    55 	if isok:
       
    56 		libstatus = oktype
       
    57 		bug_severity='NORMAL'
       
    58 		bug_status='RESOLVED'
       
    59 		resolution='WONTFIX'
       
    60 	else:
       
    61 		libstatus = othertype
       
    62 		bug_severity='MAJOR'
       
    63 		bug_status='NEW'
       
    64 		resolution=''
       
    65 		
       
    66 	for issue in library['issues']:
       
    67 		if issue['status'] == 'NOK':
       
    68 			libstatus = noktype
       
    69 			bug_severity='CRITICAL'
       
    70 			bug_status='NEW'
       
    71 			resolution=''
       
    72 
       
    73 
       
    74 	short_desc = 'Compatibility break in library %s' % library['shortname']
       
    75 	
       
    76 	library_info='Library details<br>name: %s<br>shortname: %s<br>comparefilename: %s<br>baseplatform: %s<br>currentplatform: %s' % (library['name'], library['shortname'], library['comparefilename'], library['baseplatform'], library['currentplatform'])
       
    77 	
       
    78 	long_desc = libstatus + '<br>'
       
    79 	for issue in library['issues']:
       
    80 		if issue['funcpos'] == '':
       
    81 			if issue['newfuncpos'] != '':
       
    82 				pos = issue['newfuncpos']
       
    83 			else:
       
    84 				pos = '-'
       
    85 		elif issue['newfuncpos'] != '':
       
    86 			pos = '%s->%s' % (issue['funcpos'], issue['newfuncpos'])
       
    87 		else:
       
    88 			pos = issue['funcpos']
       
    89 		
       
    90 		if issue['funcname'] != '':
       
    91 			if issue['newfuncname'] != '':
       
    92 				funcstring = 'was %s; now %s' % (issue['funcname'], issue['newfuncname'])
       
    93 			else:
       
    94 				funcstring = issue['funcname']
       
    95 		elif issue['newfuncname'] != '':
       
    96 			funcstring = issue['newfuncname']
       
    97 		else:
       
    98 			funcstring = ''
       
    99 		
       
   100 		long_desc = long_desc + '[%s] (%s) %s %s (%s) [BC: %s, SC:%s]<br>%s' % (pos, typeidmap[issue['typeid']-1], issue['typeinfo'], funcstring, issue['comment'], issue['bc_severity'], issue['sc_severity'], library_info)
       
   101 		
       
   102 	
       
   103 	product=library['shortname']
       
   104 	reporter='BC checker'
       
   105 	assigned_to=''
       
   106 	backlog_url=''
       
   107 	deadline=''
       
   108 	assigned_to=''
       
   109 	version='unspecified'
       
   110 	component=''
       
   111 	rep_platform='N/A'
       
   112 	keywords='Symbian^2, Compatibility_Break'
       
   113 	
       
   114 	print "%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s" % (product, reporter, assigned_to, bug_severity, backlog_url, short_desc, long_desc, deadline, bug_status, resolution, version, component, rep_platform, keywords)
       
   115 			
       
   116 		
       
   117 def list_libraryissues():
       
   118 	libissues=[]
       
   119 	for li in libraryissues:
       
   120 	
       
   121 		try:
       
   122 			name=li.getElementsByTagName('name')[0].childNodes[0].wholeText
       
   123 		except:
       
   124 			name=''
       
   125 		try:
       
   126 			shortname=li.getElementsByTagName('shortname')[0].childNodes[0].wholeText
       
   127 		except:
       
   128 			shortname=''
       
   129 
       
   130 		try:
       
   131 			comparefilename=li.getElementsByTagName('comparefilename')[0].childNodes[0].wholeText
       
   132 		except:
       
   133 			comparefilename=''
       
   134 		
       
   135 		try:
       
   136 			baseplatform=li.getElementsByTagName('baseplatform')[0].childNodes[0].wholeText
       
   137 		except:
       
   138 			baseplatform=''
       
   139 
       
   140 		try:
       
   141 			currentplatform=li.getElementsByTagName('currentplatform')[0].childNodes[0].wholeText
       
   142 		except:
       
   143 			currentplatform=''
       
   144 
       
   145 		try:
       
   146 			issues=li.getElementsByTagName('issue')
       
   147 			issuelist = []
       
   148 			for issue in issues:
       
   149 				try:
       
   150 					typeid=int(issue.getElementsByTagName('typeid')[0].childNodes[0].wholeText)
       
   151 				except:
       
   152 					typeid=-1
       
   153 				try:
       
   154 					funcname=issue.getElementsByTagName('funcname')[0].childNodes[0].wholeText
       
   155 				except:
       
   156 					funcname=''
       
   157 				try:
       
   158 					newfuncname=issue.getElementsByTagName('newfuncname')[0].childNodes[0].wholeText
       
   159 				except:
       
   160 					newfuncname=''	
       
   161 				try:
       
   162 					funcpos=issue.getElementsByTagName('funcpos')[0].childNodes[0].wholeText
       
   163 				except:
       
   164 					funcpos=''	
       
   165 				try:
       
   166 					newfuncpos=issue.getElementsByTagName('newfuncpos')[0].childNodes[0].wholeText
       
   167 				except:
       
   168 					newfuncpos=''	
       
   169 				try:
       
   170 					bc_severity=issue.getElementsByTagName('bc_severity')[0].childNodes[0].wholeText
       
   171 				except:
       
   172 					bc_severity=''
       
   173 				try:
       
   174 					sc_severity=issue.getElementsByTagName('sc_severity')[0].childNodes[0].wholeText
       
   175 				except:
       
   176 					sc_severity=''
       
   177 				try:
       
   178 					status=issue.getElementsByTagName('status')[0].childNodes[0].wholeText
       
   179 				except:
       
   180 					status=''
       
   181 				try:
       
   182 					typeinfo=issue.getElementsByTagName('typeinfo')[0].childNodes[0].wholeText
       
   183 				except:
       
   184 					typeinfo=''	
       
   185 				try:
       
   186 					comment=issue.getElementsByTagName('comment')[0].childNodes[0].wholeText
       
   187 				except:
       
   188 					comment=''					
       
   189 				anissue={'typeid': typeid, 'funcname':funcname, 'newfuncname':newfuncname, 'funcpos': funcpos, 'newfuncpos': newfuncpos, 'bc_severity': bc_severity, 'sc_severity': sc_severity, 'status': status, 'typeinfo': typeinfo, 'comment': comment}
       
   190 				issuelist.append(anissue)
       
   191 		except:
       
   192 			pass
       
   193 		
       
   194 		libissue = {'name': name, 'shortname': shortname, 'comparefilename': comparefilename, 'baseplatform': baseplatform, 'currentplatform': currentplatform, 'issues': issuelist}
       
   195 		libissues.append(libissue)
       
   196 	
       
   197 	summ = 0
       
   198 	libsok = []
       
   199 	libsnotok = []
       
   200 
       
   201 	for libiss in libissues:
       
   202 		nokcount = 0
       
   203 		mokcount = 0
       
   204 		okcount = 0
       
   205 		othercount = 0
       
   206 	
       
   207 		for iss in libiss['issues']:
       
   208 		
       
   209 			if iss['status'] == 'NOK':
       
   210 				nokcount=nokcount+1
       
   211 			elif iss['status'] == 'MOK':
       
   212 				mokcount=mokcount+1
       
   213 			elif iss['status'] == 'OK':
       
   214 				okcount=okcount+1
       
   215 			elif iss['status'] == '' and iss['typeid'] != 7 and iss['typeid'] != 2:
       
   216 				othercount = othercount+1
       
   217 			
       
   218 		if nokcount == 0 and mokcount == 0 and okcount > 0 and othercount == 0:
       
   219 			libsok.append(libiss)
       
   220 		elif nokcount > 0 or othercount > 0:
       
   221 			libsnotok.append(libiss)
       
   222 		
       
   223 	for l in libsnotok:
       
   224 		print_errors(l)	
       
   225 	
       
   226 	for l in libsok:
       
   227 		print_errors(l, True)
       
   228 
       
   229 def print_header_errors(header):
       
   230 
       
   231 	if header['status']=='OK':
       
   232 		headerstatus = oktypehdr
       
   233 		bug_severity='NORMAL'
       
   234 		bug_status='RESOLVED'
       
   235 		resolution='WONTFIX'
       
   236 	elif header['status']=='IOK':
       
   237 		headerstatus = ioktypehdr
       
   238 		bug_severity='NORMAL'
       
   239 		bug_status='RESOLVED'
       
   240 		resolution='WONTFIX'
       
   241 	elif header['status'] != '':
       
   242 		headerstatus = noktypemaphdr[header['status']]
       
   243 		bug_severity='CRITICAL'
       
   244 		bug_status='NEW'
       
   245 		resolution=''
       
   246 	else:
       
   247 		headerstatus = othertypehdr
       
   248 		bug_severity='MAJOR'
       
   249 		bug_status='NEW'
       
   250 		resolution=''
       
   251 
       
   252 	short_desc = 'Compatibility break in header %s' % (header['shortname'])
       
   253 
       
   254 	
       
   255 	headerinfo='Header details<br>filename: %s<br>shortname: %s<br>comparefilename: %s' % (header['filename'], header['shortname'], header['comparefilename'])
       
   256 
       
   257 	
       
   258 	if header['status'] == 'OK':
       
   259 		long_desc = headerstatus + ' Comment: ' + header['comment'] + '<br>'
       
   260 	else:
       
   261 		long_desc = headerstatus + ' '
       
   262 			
       
   263 	for issue in header['issues']:
       
   264 		long_desc = long_desc + '%s %s %s [BC: %s, SC:%s]<br>%s' % (issue['identitydescription'], issue['typestring'], issue['cause'], issue['bc_severity'], issue['sc_severity'], headerinfo)
       
   265 		
       
   266 	
       
   267 	product=header['shortname']
       
   268 	reporter='BC checker'
       
   269 	assigned_to=''
       
   270 	backlog_url=''
       
   271 	deadline=''
       
   272 	assigned_to=''
       
   273 	version='unspecified'
       
   274 	component=''
       
   275 	rep_platform='N/A'
       
   276 	keywords='Symbian^2, Compatibility_Break'
       
   277 
       
   278 	
       
   279 	print "%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s" % (product, reporter, assigned_to, bug_severity, backlog_url, short_desc, long_desc, deadline, bug_status, resolution, version, component, rep_platform, keywords)
       
   280 			
       
   281 		
       
   282 def list_headerissues():
       
   283 	headerissues=[]
       
   284 	for hi in headers:
       
   285 
       
   286 		try:
       
   287 			filename=hi.getElementsByTagName('filename')[0].childNodes[0].wholeText
       
   288 		except:
       
   289 			filename=''
       
   290 			
       
   291 		try:
       
   292 			shortname=hi.getElementsByTagName('shortname')[0].childNodes[0].wholeText
       
   293 		except:
       
   294 			shortname=''
       
   295 			
       
   296 		try:
       
   297 			comparefilename=hi.getElementsByTagName('comparefilename')[0].childNodes[0].wholeText
       
   298 		except:
       
   299 			comparefilename=''
       
   300 
       
   301 		try:
       
   302 			status=hi.getElementsByTagName('status')[0].childNodes[0].wholeText
       
   303 		except:
       
   304 			status=''
       
   305 		
       
   306 		try:
       
   307 			comment=hi.getElementsByTagName('comment')[0].childNodes[0].wholeText
       
   308 		except:
       
   309 			comment=''
       
   310 
       
   311 		try:
       
   312 			checksum=hi.getElementsByTagName('checksum')[0].childNodes[0].wholeText
       
   313 		except:
       
   314 			checksum=''
       
   315 
       
   316 		try:
       
   317 			issues=hi.getElementsByTagName('issue')
       
   318 			issuelist = []
       
   319 			for issue in issues:
       
   320 				try:
       
   321 					issueid=int(issue.getElementsByTagName('issueid')[0].childNodes[0].wholeText)
       
   322 				except:
       
   323 					issueid=-1
       
   324 					
       
   325 				try:
       
   326 					typeid=int(issue.getElementsByTagName('typeid')[0].childNodes[0].wholeText)
       
   327 				except:
       
   328 					typeid=-1
       
   329 				try:
       
   330 					identityid=issue.getElementsByTagName('identityid')[0].childNodes[0].wholeText
       
   331 				except:
       
   332 					identityid=''
       
   333 				try:
       
   334 					identitydescription=issue.getElementsByTagName('identitydescription')[0].childNodes[0].wholeText
       
   335 				except:
       
   336 					identitydescription=''
       
   337 						
       
   338 				try:
       
   339 					typestring=issue.getElementsByTagName('typestring')[0].childNodes[0].wholeText
       
   340 				except:
       
   341 					typestring=''
       
   342 						
       
   343 				try:
       
   344 					cause=issue.getElementsByTagName('cause')[0].childNodes[0].wholeText
       
   345 				except:
       
   346 					cause=''
       
   347 				
       
   348 				try:
       
   349 					ignoreinformation=issue.getElementsByTagName('ignoreinformation')[0].childNodes[0].wholeText
       
   350 				except:
       
   351 					ignoreinformation=''
       
   352 					
       
   353 				try:
       
   354 					documentation=issue.getElementsByTagName('documentation')[0].childNodes[0].wholeText
       
   355 				except:
       
   356 					documentation=''
       
   357 				
       
   358 				try:
       
   359 					linenumber=issue.getElementsByTagName('linenumber')[0].childNodes[0].wholeText
       
   360 				except:
       
   361 					linenumber=''
       
   362 					
       
   363 				try:
       
   364 					sc_severity=issue.getElementsByTagName('scseverity')[0]
       
   365 			
       
   366 					try:
       
   367 						typeid=sc_severity.getElementsByTagName('typeid')[0].childNodes[0].wholeText
       
   368 					except:
       
   369 						typeid=''
       
   370 
       
   371 
       
   372 					try:
       
   373 						sctypestring=sc_severity.getElementsByTagName('typestring')[0].childNodes[0].wholeText
       
   374 					except:
       
   375 						sctypestring=''
       
   376 					
       
   377 					sc_severity=sctypestring				
       
   378 				except:
       
   379 					sc_severity=''
       
   380 	
       
   381 				try:
       
   382 					bc_severity=issue.getElementsByTagName('severity')[0]
       
   383 					
       
   384 					try:
       
   385 						typeid=bc_severity.getElementsByTagName('typeid')[0].childNodes[0].wholeText
       
   386 					except:
       
   387 						typeid=''
       
   388 
       
   389 
       
   390 					try:
       
   391 						bctypestring=bc_severity.getElementsByTagName('typestring')[0].childNodes[0].wholeText
       
   392 					except:
       
   393 						bctypestring=''
       
   394 					
       
   395 					bc_severity=bctypestring				
       
   396 				except:
       
   397 					bc_severity=''
       
   398 																			
       
   399 				anissue={'issueid': issueid, 'typeid': typeid, 'identityid': identityid, 'identitydescription': identitydescription, 'typestring': typestring, 'cause': cause, 'ignoreinformation': ignoreinformation, 'documentation': documentation, 'linenumber': linenumber, 'bc_severity': bc_severity, 'sc_severity': sc_severity}
       
   400 				issuelist.append(anissue)
       
   401 		except:
       
   402 			print 'except!'
       
   403 		
       
   404 		headerissue = {'filename': filename, 'shortname': shortname, 'comparefilename': comparefilename, 'status': status, 'comment': comment, 'checksum': checksum, 'issues': issuelist}
       
   405 		headerissues.append(headerissue)
       
   406 
       
   407 	for l in headerissues:
       
   408 		print_header_errors(l)
       
   409 
       
   410 
       
   411 if len(sys.argv) < 2:
       
   412 	print 'usage: python issuelist.py <reportfile1.xml> [reportfile2.xml]'
       
   413 elif len(sys.argv) >= 2:
       
   414 	loadfile(sys.argv[1])
       
   415 	if len(sys.argv) > 2:
       
   416 			loadfile(sys.argv[2])
       
   417 	
       
   418 	print "%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s" % ('product', 'reporter', 'assigned_to', 'bug_severity', 'backlog_url', 'short_desc', 'long_desc', 'deadline', 'bug_status', 'resolution', 'version', 'component', 'rep_platform','keywords')
       
   419 
       
   420 	list_headerissues()
       
   421 	list_libraryissues()
       
   422