コード例 #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 testXmlReportOnUnicodeFromApplicationOutput( self ):

		class TestPlugin( Plugin ):
			EXECUTABLE = ['python', os.path.join( self.MY_DIRECTORY, '..', 'scripts', 'print_unicode_output.py' )]

			def setup( self ):
				step = self.getInstructions().getStep( 'cleanup' )
				action = ShellCommandAction( command = self.EXECUTABLE )
				step.addMainAction( action )

		self.build.addPlugin( TestPlugin() )
		self._executeBuild()

		converter = XmlReportConverter( self._getXmlReport() )
		converter.convertToText() # test if conversion does not crash something

		self.assertTrue( self.build.getReturnCode() == 0 )
コード例 #3
0
ファイル: ConsoleReporter.py プロジェクト: KDAB/Make-O-Matic
	def report( self ):
		if self.isReportSent():
			return

		report = InstructionsXmlReport( self.getInstructions() )
		converter = XmlReportConverter( report )

		print( " " )
		print( converter.convertToTextSummary().encode( "utf-8" ) )
		print( converter.convertToText().encode( "utf-8" ) )
		print( " " ) # empty line
		self._setIsReportSent( True )
コード例 #4
0
ファイル: XmlReportTests.py プロジェクト: KDAB/Make-O-Matic
	def testXmlReportOnExceptionInXmlReportGeneration( self ):
		# inject invalid XML template function into plugin
		def command_new( self ):
			raise MomError( "Test Error" )
		logger = ConsoleLogger()
		self.build.addPlugin( logger )
		replace_bound_method( logger, logger.getObjectStatus, command_new )

		self._executeBuild()

		converter = XmlReportConverter( self._getXmlReport() )
		text = converter.convertToText()

		self.assertTrue( "Exception" in text )
コード例 #5
0
ファイル: XmlReportTests.py プロジェクト: KDAB/Make-O-Matic
	def testXmlReportOnUnicodeOutput( self ):
		# inject plugin producing unicode strings
		class TestPlugin( Plugin ):
			def setup( self ):
				raise MomError( u"äöü" )

		self.build.addPlugin( TestPlugin() )

		self._executeBuild()

		converter = XmlReportConverter( self._getXmlReport() )
		text = converter.convertToText()

		self.assertTrue( u"äöü" in text )
コード例 #6
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 ) )
コード例 #7
0
ファイル: XmlReportTests.py プロジェクト: KDAB/Make-O-Matic
	def testConvertXmlReportToText( self ):
		self._executeBuild()
		converter = XmlReportConverter( self._getXmlReport() )
		text = converter.convertToText()

		self.assertTrue( len( text ) > 1000 )
コード例 #8
0
ファイル: MomTestCase.py プロジェクト: KDAB/Make-O-Matic
	def _printTextReport( self, instructions = None ):
		conv = XmlReportConverter( self._getReport( instructions ) )
		print( conv.convertToText() )