| The Gaudi Framework v28r2p1 (f1a77ff4)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
GaudiTest.HTMLResultStream Class Reference
Inheritance diagram for GaudiTest.HTMLResultStream:
[legend]
Collaboration diagram for GaudiTest.HTMLResultStream:
[legend]

## Public Member Functions
def | __init__ (self, arguments=None, args)
def | WriteAnnotation (self, key, value)
def | WriteResult (self, result)
def | Summarize (self)

## Static Public Attributes
list | arguments

## Private Member Functions
def | _updateSummary (self)

## Private Attributes
| _summary
| _summaryFile
| _annotationsFile

## Detailed Description

    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 1810 of file GaudiTest.py.

## Constructor & Destructor Documentation

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 1830 of file GaudiTest.py.

1830 def __init__(self, arguments = None, **args):
1831 """Prepare the destination directory.
1832
1833 Creates the destination directory and store in it some preliminary
1834 annotations and the static files found in the template directory
1835 'html_report'.
1836 """
1837 ResultStream.__init__(self, arguments, **args)
1838 self._summary = []
1839 self._summaryFile = os.path.join(self.dir, "summary.json")
1840 self._annotationsFile = os.path.join(self.dir, "annotations.json")
1841 # Prepare the destination directory using the template
1842 templateDir = os.path.join(os.path.dirname(__file__), "html_report")
1843 if not os.path.isdir(self.dir):
1844 os.makedirs(self.dir)
1845 # Copy the files in the template directory excluding the directories
1846 for f in os.listdir(templateDir):
1847 src = os.path.join(templateDir, f)
1848 dst = os.path.join(self.dir, f)
1849 if not os.path.isdir(src) and not os.path.exists(dst):
1850 shutil.copy(src, dst)
1851 # Add some non-QMTest attributes
1852 if "CMTCONFIG" in os.environ:
1853 self.WriteAnnotation("cmt.cmtconfig", os.environ["CMTCONFIG"])
1854 import socket
1855 self.WriteAnnotation("hostname", socket.gethostname())
1856
GaudiTest.HTMLResultStream._summaryFile
_summaryFile
Definition: GaudiTest.py:1839
GaudiTest.HTMLResultStream.__init__
def __init__(self, arguments=None, args)
Definition: GaudiTest.py:1830
GaudiTest.HTMLResultStream._summary
_summary
Definition: GaudiTest.py:1838
GaudiTest.HTMLResultStream._annotationsFile
_annotationsFile
Definition: GaudiTest.py:1840
GaudiTest.HTMLResultStream.WriteAnnotation
def WriteAnnotation(self, key, value)
Definition: GaudiTest.py:1871

## Member Function Documentation

def GaudiTest.HTMLResultStream._updateSummary | ( |  | self | ) |
| private

    Helper function to extend the global summary file in the destination
    directory.

Definition at line 1857 of file GaudiTest.py.

1857 def _updateSummary(self):
1858 """Helper function to extend the global summary file in the destination
1859 directory.
1860 """
1861 if os.path.exists(self._summaryFile):
1862 oldSummary = json.load(open(self._summaryFile))
1863 else:
1864 oldSummary = []
1865 ids = set([ i["id"] for i in self._summary ])
1866 newSummary = [ i for i in oldSummary if i["id"] not in ids ]
1867 newSummary.extend(self._summary)
1868 json.dump(newSummary, open(self._summaryFile, "w"),
1869 sort_keys = True)
1870
GaudiTest.HTMLResultStream._summaryFile
_summaryFile
Definition: GaudiTest.py:1839
GaudiTest.HTMLResultStream._updateSummary
def _updateSummary(self)
Definition: GaudiTest.py:1857
GaudiTest.HTMLResultStream._summary
_summary
Definition: GaudiTest.py:1838

def GaudiTest.HTMLResultStream.Summarize | ( |  | self | ) |

Definition at line 1942 of file GaudiTest.py.

1942 def Summarize(self):
1943 # Not implemented.
1944 pass
1945
1946
1947
1948
GaudiTest.HTMLResultStream.Summarize
def Summarize(self)
Definition: GaudiTest.py:1942

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 1871 of file GaudiTest.py.

1871 def WriteAnnotation(self, key, value):
1872 """Writes the annotation to the annotation file.
1873 If the key is already present with a different value, the value becomes
1874 a list and the new value is appended to it, except for start_time and
1875 end_time.
1876 """
1877 # Initialize the annotation dict from the file (if present)
1878 if os.path.exists(self._annotationsFile):
1879 annotations = json.load(open(self._annotationsFile))
1880 else:
1881 annotations = {}
1882 # hack because we do not have proper JSON support
1883 key, value = map(str, [key, value])
1884 if key == "qmtest.run.start_time":
1885 # Special handling of the start time:
1886 # if we are updating a result, we have to keep the original start
1887 # time, but remove the original end time to mark the report to be
1888 # in progress.
1889 if key not in annotations:
1890 annotations[key] = value
1891 if "qmtest.run.end_time" in annotations:
1892 del annotations["qmtest.run.end_time"]
1893 else:
1894 # All other annotations are added to a list
1895 if key in annotations:
1896 old = annotations[key]
1897 if type(old) is list:
1898 if value not in old:
1899 annotations[key].append(value)
1900 elif value != old:
1901 annotations[key] = [old, value]
1902 else:
1903 annotations[key] = value
1904 # Write the new annotations file
1905 json.dump(annotations, open(self._annotationsFile, "w"),
1906 sort_keys = True)
1907
GaudiTest.HTMLResultStream._annotationsFile
_annotationsFile
Definition: GaudiTest.py:1840
Containers::map
struct GAUDI_API map
Parametrisation class for map-like implementation.
Definition: KeyedObjectManager.h:25
gaudirun.type
type
Definition: gaudirun.py:125
GaudiTest.HTMLResultStream.WriteAnnotation
def WriteAnnotation(self, key, value)
Definition: GaudiTest.py:1871

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 1908 of file GaudiTest.py.

1908 def WriteResult(self, result):
1909 """Prepare the test result directory in the destination directory storing
1910 into it the result fields.
1911 A summary of the test result is stored both in a file in the test directory
1912 and in the global summary file.
1913 """
1914 summary = {}
1915 summary["id"] = result.GetId()
1916 summary["outcome"] = result.GetOutcome()
1917 summary["cause"] = result.GetCause()
1918 summary["fields"] = result.keys()
1919 summary["fields"].sort()
1920
1921 # Since we miss proper JSON support, I hack a bit
1922 for f in ["id", "outcome", "cause"]:
1923 summary[f] = str(summary[f])
1924 summary["fields"] = map(str, summary["fields"])
1925
1926 self._summary.append(summary)
1927
1928 # format:
1929 # testname/summary.json
1930 # testname/field1
1931 # testname/field2
1932 testOutDir = os.path.join(self.dir, summary["id"])
1933 if not os.path.isdir(testOutDir):
1934 os.makedirs(testOutDir)
1935 json.dump(summary, open(os.path.join(testOutDir, "summary.json"), "w"),
1936 sort_keys = True)
1937 for f in summary["fields"]:
1938 open(os.path.join(testOutDir, f), "w").write(result[f])
1939
1940 self._updateSummary()
1941
GaudiTest.HTMLResultStream._updateSummary
def _updateSummary(self)
Definition: GaudiTest.py:1857
Containers::map
struct GAUDI_API map
Parametrisation class for map-like implementation.
Definition: KeyedObjectManager.h:25
GaudiPython.GaudiAlgs.write
write
Definition: GaudiAlgs.py:1144
GaudiTest.HTMLResultStream.WriteResult
def WriteResult(self, result)
Definition: GaudiTest.py:1908

## Member Data Documentation

GaudiTest.HTMLResultStream._annotationsFile
| private

Definition at line 1840 of file GaudiTest.py.

GaudiTest.HTMLResultStream._summary
| private

Definition at line 1838 of file GaudiTest.py.

GaudiTest.HTMLResultStream._summaryFile
| private

Definition at line 1839 of file GaudiTest.py.

list GaudiTest.HTMLResultStream.arguments
| static

Initial value:
1 = [
2 qm.fields.TextField(
3 name = "dir",
4 title = "Destination Directory",
5 description = ,
6 verbatim = "true",
7 default_value = ""),
8 ]

Definition at line 1819 of file GaudiTest.py.

The documentation for this class was generated from the following file:

- GaudiPolicy/qmtest_classes/GaudiTest.py