|
Gaudi Framework, version v22r1 |
| Home | Generated: Mon Feb 28 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 1676 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 1696 of file GaudiTest.py.
01697 : 01698 """Prepare the destination directory. 01699 01700 Creates the destination directory and store in it some preliminary 01701 annotations and the static files found in the template directory 01702 'html_report'. 01703 """ 01704 ResultStream.__init__(self, arguments, **args) 01705 self._summary = [] 01706 self._summaryFile = os.path.join(self.dir, "summary.json") 01707 self._annotationsFile = os.path.join(self.dir, "annotations.json") 01708 # Prepare the destination directory using the template 01709 templateDir = os.path.join(os.path.dirname(__file__), "html_report") 01710 if not os.path.isdir(self.dir): 01711 os.makedirs(self.dir) 01712 # Copy the files in the template directory excluding the directories 01713 for f in os.listdir(templateDir): 01714 src = os.path.join(templateDir, f) 01715 dst = os.path.join(self.dir, f) 01716 if not os.path.isdir(src) and not os.path.exists(dst): 01717 shutil.copy(src, dst) 01718 # Add some non-QMTest attributes 01719 if "CMTCONFIG" in os.environ: 01720 self.WriteAnnotation("cmt.cmtconfig", os.environ["CMTCONFIG"]) 01721 import socket 01722 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 1723 of file GaudiTest.py.
01724 : 01725 """Helper function to extend the global summary file in the destination 01726 directory. 01727 """ 01728 if os.path.exists(self._summaryFile): 01729 oldSummary = json.load(open(self._summaryFile)) 01730 else: 01731 oldSummary = [] 01732 ids = set([ i["id"] for i in self._summary ]) 01733 newSummary = [ i for i in oldSummary if i["id"] not in ids ] 01734 newSummary.extend(self._summary) 01735 json.dump(newSummary, open(self._summaryFile, "w"), 01736 sort_keys = True)
| def GaudiTest::HTMLResultStream::Summarize | ( | self ) |
Definition at line 1808 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 1737 of file GaudiTest.py.
01738 : 01739 """Writes the annotation to the annotation file. 01740 If the key is already present with a different value, the value becomes 01741 a list and the new value is appended to it, except for start_time and 01742 end_time. 01743 """ 01744 # Initialize the annotation dict from the file (if present) 01745 if os.path.exists(self._annotationsFile): 01746 annotations = json.load(open(self._annotationsFile)) 01747 else: 01748 annotations = {} 01749 # hack because we do not have proper JSON support 01750 key, value = map(str, [key, value]) 01751 if key == "qmtest.run.start_time": 01752 # Special handling of the start time: 01753 # if we are updating a result, we have to keep the original start 01754 # time, but remove the original end time to mark the report to be 01755 # in progress. 01756 if key not in annotations: 01757 annotations[key] = value 01758 if "qmtest.run.end_time" in annotations: 01759 del annotations["qmtest.run.end_time"] 01760 else: 01761 # All other annotations are added to a list 01762 if key in annotations: 01763 old = annotations[key] 01764 if type(old) is list: 01765 if value not in old: 01766 annotations[key].append(value) 01767 elif value != old: 01768 annotations[key] = [old, value] 01769 else: 01770 annotations[key] = value 01771 # Write the new annotations file 01772 json.dump(annotations, open(self._annotationsFile, "w"), 01773 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 1774 of file GaudiTest.py.
01775 : 01776 """Prepare the test result directory in the destination directory storing 01777 into it the result fields. 01778 A summary of the test result is stored both in a file in the test directory 01779 and in the global summary file. 01780 """ 01781 summary = {} 01782 summary["id"] = result.GetId() 01783 summary["outcome"] = result.GetOutcome() 01784 summary["cause"] = result.GetCause() 01785 summary["fields"] = result.keys() 01786 summary["fields"].sort() 01787 01788 # Since we miss proper JSON support, I hack a bit 01789 for f in ["id", "outcome", "cause"]: 01790 summary[f] = str(summary[f]) 01791 summary["fields"] = map(str, summary["fields"]) 01792 01793 self._summary.append(summary) 01794 01795 # format: 01796 # testname/summary.json 01797 # testname/field1 01798 # testname/field2 01799 testOutDir = os.path.join(self.dir, summary["id"]) 01800 if not os.path.isdir(testOutDir): 01801 os.makedirs(testOutDir) 01802 json.dump(summary, open(os.path.join(testOutDir, "summary.json"), "w"), 01803 sort_keys = True) 01804 for f in summary["fields"]: 01805 open(os.path.join(testOutDir, f), "w").write(result[f]) 01806 01807 self._updateSummary()
Definition at line 1701 of file GaudiTest.py.
GaudiTest::HTMLResultStream::_summary [private] |
Definition at line 1701 of file GaudiTest.py.
Definition at line 1701 of file GaudiTest.py.
list GaudiTest::HTMLResultStream::arguments [static] |
[
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 1685 of file GaudiTest.py.