| The Gaudi Framework v30r0 (c919700c)

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

1922 def __init__(self, arguments=None, **args):
1923 """Prepare the destination directory.
1924
1925 Creates the destination directory and store in it some preliminary
1926 annotations and the static files found in the template directory
1927 'html_report'.
1928 """
1929 ResultStream.__init__(self, arguments, **args)
1930 self._summary = []
1931 self._summaryFile = os.path.join(self.dir, "summary.json")
1932 self._annotationsFile = os.path.join(self.dir, "annotations.json")
1933 # Prepare the destination directory using the template
1934 templateDir = os.path.join(os.path.dirname(__file__), "html_report")
1935 if not os.path.isdir(self.dir):
1936 os.makedirs(self.dir)
1937 # Copy the files in the template directory excluding the directories
1938 for f in os.listdir(templateDir):
1939 src = os.path.join(templateDir, f)
1940 dst = os.path.join(self.dir, f)
1941 if not os.path.isdir(src) and not os.path.exists(dst):
1942 shutil.copy(src, dst)
1943 # Add some non-QMTest attributes
1944 if "CMTCONFIG" in os.environ:
1945 self.WriteAnnotation("cmt.cmtconfig", os.environ["CMTCONFIG"])
1946 import socket
1947 self.WriteAnnotation("hostname", socket.gethostname())
1948
GaudiTest.HTMLResultStream._summaryFile
_summaryFile
Definition: GaudiTest.py:1931
GaudiTest.HTMLResultStream.__init__
def __init__(self, arguments=None, args)
Definition: GaudiTest.py:1922
GaudiTest.HTMLResultStream._summary
_summary
Definition: GaudiTest.py:1930
GaudiTest.HTMLResultStream._annotationsFile
_annotationsFile
Definition: GaudiTest.py:1932
GaudiTest.HTMLResultStream.WriteAnnotation
def WriteAnnotation(self, key, value)
Definition: GaudiTest.py:1963

## Member Function Documentation

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

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

Definition at line 1949 of file GaudiTest.py.

1949 def _updateSummary(self):
1950 """Helper function to extend the global summary file in the destination
1951 directory.
1952 """
1953 if os.path.exists(self._summaryFile):
1954 oldSummary = json.load(open(self._summaryFile))
1955 else:
1956 oldSummary = []
1957 ids = set([i["id"] for i in self._summary])
1958 newSummary = [i for i in oldSummary if i["id"] not in ids]
1959 newSummary.extend(self._summary)
1960 json.dump(newSummary, open(self._summaryFile, "w"),
1961 sort_keys=True)
1962
GaudiTest.HTMLResultStream._summaryFile
_summaryFile
Definition: GaudiTest.py:1931
GaudiTest.HTMLResultStream._updateSummary
def _updateSummary(self)
Definition: GaudiTest.py:1949
GaudiTest.HTMLResultStream._summary
_summary
Definition: GaudiTest.py:1930

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

Definition at line 2034 of file GaudiTest.py.

2034 def Summarize(self):
2035 # Not implemented.
2036 pass
2037
2038
GaudiTest.HTMLResultStream.Summarize
def Summarize(self)
Definition: GaudiTest.py:2034

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

1963 def WriteAnnotation(self, key, value):
1964 """Writes the annotation to the annotation file.
1965 If the key is already present with a different value, the value becomes
1966 a list and the new value is appended to it, except for start_time and
1967 end_time.
1968 """
1969 # Initialize the annotation dict from the file (if present)
1970 if os.path.exists(self._annotationsFile):
1971 annotations = json.load(open(self._annotationsFile))
1972 else:
1973 annotations = {}
1974 # hack because we do not have proper JSON support
1975 key, value = map(str, [key, value])
1976 if key == "qmtest.run.start_time":
1977 # Special handling of the start time:
1978 # if we are updating a result, we have to keep the original start
1979 # time, but remove the original end time to mark the report to be
1980 # in progress.
1981 if key not in annotations:
1982 annotations[key] = value
1983 if "qmtest.run.end_time" in annotations:
1984 del annotations["qmtest.run.end_time"]
1985 else:
1986 # All other annotations are added to a list
1987 if key in annotations:
1988 old = annotations[key]
1989 if type(old) is list:
1990 if value not in old:
1991 annotations[key].append(value)
1992 elif value != old:
1993 annotations[key] = [old, value]
1994 else:
1995 annotations[key] = value
1996 # Write the new annotations file
1997 json.dump(annotations, open(self._annotationsFile, "w"),
1998 sort_keys=True)
1999
GaudiTest.HTMLResultStream._annotationsFile
_annotationsFile
Definition: GaudiTest.py:1932
Containers::map
struct GAUDI_API map
Parametrisation class for map-like implementation.
Definition: KeyedObjectManager.h:26
gaudirun.type
type
Definition: gaudirun.py:133
GaudiTest.HTMLResultStream.WriteAnnotation
def WriteAnnotation(self, key, value)
Definition: GaudiTest.py:1963

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

2000 def WriteResult(self, result):
2001 """Prepare the test result directory in the destination directory storing
2002 into it the result fields.
2003 A summary of the test result is stored both in a file in the test directory
2004 and in the global summary file.
2005 """
2006 summary = {}
2007 summary["id"] = result.GetId()
2008 summary["outcome"] = result.GetOutcome()
2009 summary["cause"] = result.GetCause()
2010 summary["fields"] = result.keys()
2011 summary["fields"].sort()
2012
2013 # Since we miss proper JSON support, I hack a bit
2014 for f in ["id", "outcome", "cause"]:
2015 summary[f] = str(summary[f])
2016 summary["fields"] = map(str, summary["fields"])
2017
2018 self._summary.append(summary)
2019
2020 # format:
2021 # testname/summary.json
2022 # testname/field1
2023 # testname/field2
2024 testOutDir = os.path.join(self.dir, summary["id"])
2025 if not os.path.isdir(testOutDir):
2026 os.makedirs(testOutDir)
2027 json.dump(summary, open(os.path.join(testOutDir, "summary.json"), "w"),
2028 sort_keys=True)
2029 for f in summary["fields"]:
2030 open(os.path.join(testOutDir, f), "w").write(result[f])
2031
2032 self._updateSummary()
2033
GaudiTest.HTMLResultStream._updateSummary
def _updateSummary(self)
Definition: GaudiTest.py:1949
Containers::map
struct GAUDI_API map
Parametrisation class for map-like implementation.
Definition: KeyedObjectManager.h:26
GaudiPython.GaudiAlgs.write
write
Definition: GaudiAlgs.py:1259
GaudiTest.HTMLResultStream.WriteResult
def WriteResult(self, result)
Definition: GaudiTest.py:2000

## Member Data Documentation

GaudiTest.HTMLResultStream._annotationsFile
| private

Definition at line 1932 of file GaudiTest.py.

GaudiTest.HTMLResultStream._summary
| private

Definition at line 1930 of file GaudiTest.py.

GaudiTest.HTMLResultStream._summaryFile
| private

Definition at line 1931 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 1911 of file GaudiTest.py.

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

- GaudiPolicy/qmtest_classes/GaudiTest.py