|
Gaudi Framework, version v23r3 |
| Home | Generated: Thu Jun 28 2012 |


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 1701 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 1721 of file GaudiTest.py.
01722 : 01723 """Prepare the destination directory. 01724 01725 Creates the destination directory and store in it some preliminary 01726 annotations and the static files found in the template directory 01727 'html_report'. 01728 """ 01729 ResultStream.__init__(self, arguments, **args) 01730 self._summary = [] 01731 self._summaryFile = os.path.join(self.dir, "summary.json") 01732 self._annotationsFile = os.path.join(self.dir, "annotations.json") 01733 # Prepare the destination directory using the template 01734 templateDir = os.path.join(os.path.dirname(__file__), "html_report") 01735 if not os.path.isdir(self.dir): 01736 os.makedirs(self.dir) 01737 # Copy the files in the template directory excluding the directories 01738 for f in os.listdir(templateDir): 01739 src = os.path.join(templateDir, f) 01740 dst = os.path.join(self.dir, f) 01741 if not os.path.isdir(src) and not os.path.exists(dst): 01742 shutil.copy(src, dst) 01743 # Add some non-QMTest attributes 01744 if "CMTCONFIG" in os.environ: 01745 self.WriteAnnotation("cmt.cmtconfig", os.environ["CMTCONFIG"]) 01746 import socket 01747 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 1748 of file GaudiTest.py.
01749 : 01750 """Helper function to extend the global summary file in the destination 01751 directory. 01752 """ 01753 if os.path.exists(self._summaryFile): 01754 oldSummary = json.load(open(self._summaryFile)) 01755 else: 01756 oldSummary = [] 01757 ids = set([ i["id"] for i in self._summary ]) 01758 newSummary = [ i for i in oldSummary if i["id"] not in ids ] 01759 newSummary.extend(self._summary) 01760 json.dump(newSummary, open(self._summaryFile, "w"), 01761 sort_keys = True)
| def GaudiTest::HTMLResultStream::Summarize | ( | self ) |
Definition at line 1833 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 1762 of file GaudiTest.py.
01763 : 01764 """Writes the annotation to the annotation file. 01765 If the key is already present with a different value, the value becomes 01766 a list and the new value is appended to it, except for start_time and 01767 end_time. 01768 """ 01769 # Initialize the annotation dict from the file (if present) 01770 if os.path.exists(self._annotationsFile): 01771 annotations = json.load(open(self._annotationsFile)) 01772 else: 01773 annotations = {} 01774 # hack because we do not have proper JSON support 01775 key, value = map(str, [key, value]) 01776 if key == "qmtest.run.start_time": 01777 # Special handling of the start time: 01778 # if we are updating a result, we have to keep the original start 01779 # time, but remove the original end time to mark the report to be 01780 # in progress. 01781 if key not in annotations: 01782 annotations[key] = value 01783 if "qmtest.run.end_time" in annotations: 01784 del annotations["qmtest.run.end_time"] 01785 else: 01786 # All other annotations are added to a list 01787 if key in annotations: 01788 old = annotations[key] 01789 if type(old) is list: 01790 if value not in old: 01791 annotations[key].append(value) 01792 elif value != old: 01793 annotations[key] = [old, value] 01794 else: 01795 annotations[key] = value 01796 # Write the new annotations file 01797 json.dump(annotations, open(self._annotationsFile, "w"), 01798 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 1799 of file GaudiTest.py.
01800 : 01801 """Prepare the test result directory in the destination directory storing 01802 into it the result fields. 01803 A summary of the test result is stored both in a file in the test directory 01804 and in the global summary file. 01805 """ 01806 summary = {} 01807 summary["id"] = result.GetId() 01808 summary["outcome"] = result.GetOutcome() 01809 summary["cause"] = result.GetCause() 01810 summary["fields"] = result.keys() 01811 summary["fields"].sort() 01812 01813 # Since we miss proper JSON support, I hack a bit 01814 for f in ["id", "outcome", "cause"]: 01815 summary[f] = str(summary[f]) 01816 summary["fields"] = map(str, summary["fields"]) 01817 01818 self._summary.append(summary) 01819 01820 # format: 01821 # testname/summary.json 01822 # testname/field1 01823 # testname/field2 01824 testOutDir = os.path.join(self.dir, summary["id"]) 01825 if not os.path.isdir(testOutDir): 01826 os.makedirs(testOutDir) 01827 json.dump(summary, open(os.path.join(testOutDir, "summary.json"), "w"), 01828 sort_keys = True) 01829 for f in summary["fields"]: 01830 open(os.path.join(testOutDir, f), "w").write(result[f]) 01831 01832 self._updateSummary()
Definition at line 1726 of file GaudiTest.py.
GaudiTest::HTMLResultStream::_summary [private] |
Definition at line 1726 of file GaudiTest.py.
Definition at line 1726 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 1710 of file GaudiTest.py.