def testConvertXmlReportToTextSummary( self ): MomBuildMockupTestCase.setUp( self, useScm = True ) # enable SCM self._executeBuild() converter = XmlReportConverter( self._getXmlReport() ) text = converter.convertToTextSummary() self.assertTrue( len( text ) > 100 )
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
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 )
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 ) )