def __init__(self, config, resource):
     super(HtmlReportWorkThread, self).__init__()
     self._resource = resource
     logName = self.class_id
     automationlog = PaeAutomationLog(logName)
     automationlog.TryAddConsole()
     self._config = config
     self._logger = automationlog.GetLogger(logName)
     self._client = None
     self._reportHeader = []
     self._reportData = []
     self._powerCycleRequestCount = 0
     self._reportHeader.append(
         '<html xmlns="http://www.w3.org/1999/xhtml">')
     self._reportHeader.append(
         '<body style="background-color:{0};">'.format(
             'rgb(225, 231, 242)'))
     self._reportHeader.append(
         '<table cellspacing="0" cellpadding="0" border="0" style="height: 50px;width: 100%;'
         'background-color:steelblue; font-family:arial,helvetica; '
         'font-size:smaller; font-weight:bold; color:white;border-radius:5px;">'
     )
     self._reportHeader.append('<tr style="border:none;">')
     s = self._config['Client']['ip']
     if s is None:
         s = socket.gethostname()
     self._reportHeader.append(
         '<th align=left style="padding-left:3px;">{0}</th><th>'.format(
             self._resource['ICON']['INTEL_LOGO']))
     self._reportHeader.append(
         'Apache Pass Health Check Report [ {0} ] on system @{1}'.format(
             util.GetCurrentTimestamp(), s))
     self._reportHeader.append('</th></tr></table>')
Exemple #2
0
    def DoWork(self):
        try:
            AutomationLog().Close()
            cwd = os.getcwd()
            for d in ['log', 'report']:
                self._createDirectory('{0}/{1}'.format(cwd, r'archive/'), d)

            for key in self._parentWorkThread.TestResultsDictionary.keys():
                resultFolder = r'{0}/{1}'.format(cwd, r'archive/results')
                for g in [RESULTS.FAILED, RESULTS.SKIPPED]:
                    if self._createDirectory(resultFolder, key):
                        for k, v in self._parentWorkThread.TestResultsDictionary.iteritems(
                        ):
                            ids = [x for x in v if x[x.keys()[0]] == g]
                            if len(ids) > 0:
                                filename = '{0}/{1}/{2}_{3}.txt'.format(
                                    resultFolder, key, g.value,
                                    util.GetCurrentTimestamp(
                                        '%Y-%m-%d-%H-%M-%S'))
                                outFile = open(filename, 'w')
                                for id in ids:
                                    outFile.writelines(id)
                                outFile.flush()
                                pass

            files = os.listdir(cwd)
            for l in [x for x in files if x.endswith('.log')]:
                source = os.path.join(cwd, l)
                target = os.path.join(
                    cwd, r'archive/log/{0}_{1}.log'.format(
                        l.split('.')[0],
                        util.GetCurrentTimestamp('%Y-%m-%d-%H-%M-%S')))
                # TODO : self._movDataFile(source, target)
            htmlFiles = [x for x in files if x.endswith('.html')]
            for l in htmlFiles:
                source = os.path.join(cwd, l)
                target = os.path.join(cwd, r'archive/report/{0}'.format(l))
                self._movDataFile(source, target)

        except Exception as e:
            print(str(e))
Exemple #3
0
    def SetParentWorkThread(self, val):
        super(OpenHtmlFileState, self).SetParentWorkThread(val)
        cwd = os.getcwd()
        path = '{0}/archive/report'.format(cwd)
        try:
            if not os.path.exists(path):
                os.makedirs(path)
        except IOError as e:
            self._logger.error(str(e))

        url = 'file://{0}'.format(os.path.join(path, self._config["reporthtmlfilename"]))
        self._urlSummary = '{0}_Summary_{1}.html'.format((url).replace('.html', ''),
                                                         util.GetCurrentTimestamp('%Y-%m-%d-%H-%M-%S'))
        self._url = self._urlSummary.replace('_Summary', '')
        pass