|
Gaudi Framework, version v22r4 |
| Home | Generated: Fri Sep 2 2011 |


Public Member Functions | |
| def | __init__ |
| def | WriteAnnotation |
| def | WriteResult |
| def | Summarize |
Static Public Attributes | |
| list | arguments |
Private Member Functions | |
| def | _updateSummary |
Private Attributes | |
| _summary | |
| _summaryFile | |
| _annotationsFile | |
An 'HTMLResultStream' writes its output to a set of HTML files. The argument 'dir' is used to select the destination directory for the HTML report. The destination directory may already contain the report from a previous run (for example of a different package), in which case it will be extended to include the new data.
Definition at line 1683 of file GaudiTest.py.
| def GaudiTest::HTMLResultStream::__init__ | ( | self, | |
arguments = None, |
|||
| args | |||
| ) |
Prepare the destination directory. Creates the destination directory and store in it some preliminary annotations and the static files found in the template directory 'html_report'.
Definition at line 1703 of file GaudiTest.py.
01704 : 01705 """Prepare the destination directory. 01706 01707 Creates the destination directory and store in it some preliminary 01708 annotations and the static files found in the template directory 01709 'html_report'. 01710 """ 01711 ResultStream.__init__(self, arguments, **args) 01712 self._summary = [] 01713 self._summaryFile = os.path.join(self.dir, "summary.json") 01714 self._annotationsFile = os.path.join(self.dir, "annotations.json") 01715 # Prepare the destination directory using the template 01716 templateDir = os.path.join(os.path.dirname(__file__), "html_report") 01717 if not os.path.isdir(self.dir): 01718 os.makedirs(self.dir) 01719 # Copy the files in the template directory excluding the directories 01720 for f in os.listdir(templateDir): 01721 src = os.path.join(templateDir, f) 01722 dst = os.path.join(self.dir, f) 01723 if not os.path.isdir(src) and not os.path.exists(dst): 01724 shutil.copy(src, dst) 01725 # Add some non-QMTest attributes 01726 if "CMTCONFIG" in os.environ: 01727 self.WriteAnnotation("cmt.cmtconfig", os.environ["CMTCONFIG"]) 01728 import socket 01729 self.WriteAnnotation("hostname", socket.gethostname())
| def GaudiTest::HTMLResultStream::_updateSummary | ( | self ) | [private] |
Helper function to extend the global summary file in the destination directory.
Definition at line 1730 of file GaudiTest.py.
01731 : 01732 """Helper function to extend the global summary file in the destination 01733 directory. 01734 """ 01735 if os.path.exists(self._summaryFile): 01736 oldSummary = json.load(open(self._summaryFile)) 01737 else: 01738 oldSummary = [] 01739 ids = set([ i["id"] for i in self._summary ]) 01740 newSummary = [ i for i in oldSummary if i["id"] not in ids ] 01741 newSummary.extend(self._summary) 01742 json.dump(newSummary, open(self._summaryFile, "w"), 01743 sort_keys = True)
| def GaudiTest::HTMLResultStream::Summarize | ( | self ) |
Definition at line 1815 of file GaudiTest.py.
| def GaudiTest::HTMLResultStream::WriteAnnotation | ( | self, | |
| key, | |||
| value | |||
| ) |
Writes the annotation to the annotation file. If the key is already present with a different value, the value becomes a list and the new value is appended to it, except for start_time and end_time.
Definition at line 1744 of file GaudiTest.py.
01745 : 01746 """Writes the annotation to the annotation file. 01747 If the key is already present with a different value, the value becomes 01748 a list and the new value is appended to it, except for start_time and 01749 end_time. 01750 """ 01751 # Initialize the annotation dict from the file (if present) 01752 if os.path.exists(self._annotationsFile): 01753 annotations = json.load(open(self._annotationsFile)) 01754 else: 01755 annotations = {} 01756 # hack because we do not have proper JSON support 01757 key, value = map(str, [key, value]) 01758 if key == "qmtest.run.start_time": 01759 # Special handling of the start time: 01760 # if we are updating a result, we have to keep the original start 01761 # time, but remove the original end time to mark the report to be 01762 # in progress. 01763 if key not in annotations: 01764 annotations[key] = value 01765 if "qmtest.run.end_time" in annotations: 01766 del annotations["qmtest.run.end_time"] 01767 else: 01768 # All other annotations are added to a list 01769 if key in annotations: 01770 old = annotations[key] 01771 if type(old) is list: 01772 if value not in old: 01773 annotations[key].append(value) 01774 elif value != old: 01775 annotations[key] = [old, value] 01776 else: 01777 annotations[key] = value 01778 # Write the new annotations file 01779 json.dump(annotations, open(self._annotationsFile, "w"), 01780 sort_keys = True)
| def GaudiTest::HTMLResultStream::WriteResult | ( | self, | |
| result | |||
| ) |
Prepare the test result directory in the destination directory storing into it the result fields. A summary of the test result is stored both in a file in the test directory and in the global summary file.
Definition at line 1781 of file GaudiTest.py.
01782 : 01783 """Prepare the test result directory in the destination directory storing 01784 into it the result fields. 01785 A summary of the test result is stored both in a file in the test directory 01786 and in the global summary file. 01787 """ 01788 summary = {} 01789 summary["id"] = result.GetId() 01790 summary["outcome"] = result.GetOutcome() 01791 summary["cause"] = result.GetCause() 01792 summary["fields"] = result.keys() 01793 summary["fields"].sort() 01794 01795 # Since we miss proper JSON support, I hack a bit 01796 for f in ["id", "outcome", "cause"]: 01797 summary[f] = str(summary[f]) 01798 summary["fields"] = map(str, summary["fields"]) 01799 01800 self._summary.append(summary) 01801 01802 # format: 01803 # testname/summary.json 01804 # testname/field1 01805 # testname/field2 01806 testOutDir = os.path.join(self.dir, summary["id"]) 01807 if not os.path.isdir(testOutDir): 01808 os.makedirs(testOutDir) 01809 json.dump(summary, open(os.path.join(testOutDir, "summary.json"), "w"), 01810 sort_keys = True) 01811 for f in summary["fields"]: 01812 open(os.path.join(testOutDir, f), "w").write(result[f]) 01813 01814 self._updateSummary()
Definition at line 1708 of file GaudiTest.py.
GaudiTest::HTMLResultStream::_summary [private] |
Definition at line 1708 of file GaudiTest.py.
Definition at line 1708 of file GaudiTest.py.
[
qm.fields.TextField(
name = "dir",
title = "Destination Directory",
description = """The name of the directory.All results will be written to the directory indicated.""",
verbatim = "true",
default_value = ""),
]
Definition at line 1692 of file GaudiTest.py.