コード例 #1
0
ファイル: EmailReporter.py プロジェクト: KDAB/Make-O-Matic
	def _initEmailBody( self, email ):
		# body
		reporterUseCompression = mApp().getSettings().get( Settings.EmailReporterUseCompressionForAttachments, False )

		report = InstructionsXmlReport( mApp() )
		converter = XmlReportConverter( report )

		### text and html part
		# summary
		email.attachAlternativeTextPart( 
				converter.convertToTextSummary(),
				converter.convertToHtml( summaryOnly = True )
		)

		# report
		if self.getEnableFullReport():
			email.attachAlternativeTextPart( 
					converter.convertToText( short = True ),
					converter.convertToHtml()
			)

			returnCode = mApp().getReturnCode()
			if returnCode != 0:
				email.addTextAttachment( converter.convertToFailedStepsLog(), "failed-steps.log", useCompression = reporterUseCompression )

		# attachments
		exception = mApp().getException()
		if exception:
			traceback = u"\n".join( exception[1] )
			email.addTextAttachment( "{0}\n\n{1}".format( exception[0], traceback ), "exception.log", useCompression = reporterUseCompression )

		return email
コード例 #2
0
ファイル: XmlReportTests.py プロジェクト: KDAB/Make-O-Matic
	def testConvertXmlReportToHtmlWithoutLxml( self ):
		# write a new method implementation
		def hasXsltSupport_new( self ):
			return False

		converter = XmlReportConverter( self._getXmlReport() )
		replace_bound_method( converter, converter.hasXsltSupport, hasXsltSupport_new ) # replace method

		xmlString = converter.convertToHtml()
		self.assertTrue( xmlString == None, "If no XSLT support is available, converting to HTML should not work" )
コード例 #3
0
ファイル: XmlReportTests.py プロジェクト: KDAB/Make-O-Matic
	def testConvertXmlReportToHtml( self ):
		self._executeBuild()
		converter = XmlReportConverter( self._getXmlReport() )
		xmlString = converter.convertToHtml()

		if converter.hasXsltSupport(): # can convert to HTML
			self.assertNotEquals( xmlString, None )
		else: # cannot convert, should be None
			self.assertEquals( xmlString, None )
			return # quit test case, to HTML conversion is not possible here

		doc = etree.XML( xmlString )
		self.assertEqual( doc.tag, "{http://www.w3.org/1999/xhtml}html" ) # root
		self.assertNotEquals( doc.find( ".//{http://www.w3.org/1999/xhtml}table" ), None )
		self.assertNotEquals( doc.find( ".//{http://www.w3.org/1999/xhtml}td" ), None )
コード例 #4
0
ファイル: report_converter.py プロジェクト: KDAB/Make-O-Matic
def main():
	# instantiate MApplication, required for debug() calls
	MApplication()

	# check if first parameter is set
	try:
		inputFile = sys.argv[1]
	except IndexError:
		usage()
		sys.exit( 1 )

	# check if second parameter in TARGET_FORMATS
	try:
		if sys.argv[2] in TARGET_FORMATS:
			targetFormat = sys.argv[2]
		else:
			usage()
			sys.exit( 1 )
	except IndexError:
		# second parameter not set => using default
		targetFormat = "text"

	# start IO
	fin = open( inputFile )
	xmlReport = StringBasedXmlReport( fin.read() )
	fin.close

	converter = XmlReportConverter( xmlReport )
	if targetFormat == "text":
		print( converter.convertToText() )
	elif targetFormat == "text_summary":
		print( converter.convertToTextSummary() )
	elif targetFormat == "html":
		print( converter.convertToHtml( enableCrossLinking = True ) )
	elif targetFormat == "html_summary":
		print( converter.convertToHtml( summaryOnly = True, enableCrossLinking = True ) )
コード例 #5
0
	def report( self ):
		# create temporary directories
		self._cloneDirectories()

		report = InstructionsXmlReport( mApp() )
		converter = XmlReportConverter( report )
		html = converter.convertToHtml( enableCrossLinking = True )

		# write file
		filePath = os.path.join( self.getTemporaryLocation(), "index.html" )
		f = codecs.open( filePath, 'w', encoding = "utf-8" )
		f.write( html or '' )
		f.close()

		# temporary: also write report
		filePath = os.path.join( self.getTemporaryLocation(), "build-report.xml" )
		f = codecs.open( filePath, 'w', encoding = "utf-8" )
		f.write( report.getReport() )
		f.close()

		self._upload()

		# cleanup temporary directories again
		self._deleteClonedDirectories()
コード例 #6
0
ファイル: MomTestCase.py プロジェクト: KDAB/Make-O-Matic
	def _printHtmlReport( self, instructions = None ):
		conv = XmlReportConverter( self._getReport( instructions ) )
		print( conv.convertToHtml() )