reporter.py revision 440416c42460ff291475a273205375c8ddb30333
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich# -*- coding: utf-8 -*-
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen Rabinovich# pylint: disable=C0302
66900b43227bf441b6a6b1084af2c96ce2c747c8Allen RabinovichTestdriver reporter module.
70837a7c5871ea73a84ab67d8c34fcd9d2daa31cAllen RabinovichCopyright (C) 2010-2014 Oracle Corporation
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen RabinovichThis file is part of VirtualBox Open Source Edition (OSE), as
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovichavailable from http://www.virtualbox.org. This file is free software;
70837a7c5871ea73a84ab67d8c34fcd9d2daa31cAllen Rabinovichyou can redistribute it and/or modify it under the terms of the GNU
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen RabinovichGeneral Public License (GPL) as published by the Free Software
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen RabinovichFoundation, in version 2 as it comes in the "COPYING" file of the
76438e9b6959cc0bd7e35fb9cf5a11c87a37f744Allen RabinovichVirtualBox OSE distribution. VirtualBox OSE is distributed in the
7211944935145abdba8a3ea3b17621ec264d8e21Allen Rabinovichhope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen RabinovichThe contents of this file may alternatively be used under the terms
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovichof the Common Development and Distribution License Version 1.0
7211944935145abdba8a3ea3b17621ec264d8e21Allen Rabinovich(CDDL) only, as it comes in the "COPYING.CDDL" file of the
7211944935145abdba8a3ea3b17621ec264d8e21Allen RabinovichVirtualBox OSE distribution, in which case the provisions of the
7211944935145abdba8a3ea3b17621ec264d8e21Allen RabinovichCDDL are applicable instead of those of the GPL.
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen RabinovichYou may elect to license modified versions of this file under the
70837a7c5871ea73a84ab67d8c34fcd9d2daa31cAllen Rabinovichterms and conditions of either the GPL or the CDDL or both.
7211944935145abdba8a3ea3b17621ec264d8e21Allen Rabinovich# Standard Python imports.
70837a7c5871ea73a84ab67d8c34fcd9d2daa31cAllen Rabinovich# Validation Kit imports.
70837a7c5871ea73a84ab67d8c34fcd9d2daa31cAllen Rabinovich## test reporter instance
70837a7c5871ea73a84ab67d8c34fcd9d2daa31cAllen Rabinovich Python logging => testdriver/reporter.py stream.
70837a7c5871ea73a84ab67d8c34fcd9d2daa31cAllen Rabinovich """Writes python log message to our stream."""
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich #g_oReporter.log(0, 'python: %s' % (sText), utils.getCallerName(), utils.getTimePrefix());
70837a7c5871ea73a84ab67d8c34fcd9d2daa31cAllen Rabinovich """Flushes the stream."""
70837a7c5871ea73a84ab67d8c34fcd9d2daa31cAllen Rabinovich Base class for the reporters.
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich self.fTimedOut = False; # Once set, it trickles all the way up.
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich self.sName = os.path.splitext(os.path.basename(sys.argv[0]))[0];
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich # Hook into the python logging.
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich logging.basicConfig(stream = PythonLoggingStream(),
70837a7c5871ea73a84ab67d8c34fcd9d2daa31cAllen Rabinovich format = '%(name)-12s %(levelname)-8s %(message)s');
70837a7c5871ea73a84ab67d8c34fcd9d2daa31cAllen Rabinovich # Introspection and configuration.
return False;
return sValue;
_ = oFileWrapper;
return self.log(0, 'raw xml%s: %s' % (oFileWrapper.sPrefix, sRawXml), sCaller, utils.getTimePrefix());
_ = oFileWrapper;
return True;
return sName;
self._xmlWrite([ '<FailureDetails timestamp="%s" text="%s"/>' % (sTsIso, self._xmlEscAttr(sDetails),), ]);
elif fTimedOut:
return True;
return False;
import user;
if fIndent:
return False;
return True;
return True;
self.log(0, 'Other log file: %s - %s (%s)' % (sDstFilename, sDescription, sSrcFilename), sCaller, sTsPrf);
while True:
% (utils.getIsoTimestamp(), self._xmlEscAttr(os.path.basename(sDstFilename)), self._xmlEscAttr(sSrcFilename), \
_ = sAltName;
return fRc;
import urlparse;
import httplib;
import urllib;
'User-Agent': 'TestDriverReporter/%s.0 (%s, %s)' % (__version__, utils.getHostOs(), utils.getHostArch(),),
dParams = {
import httplib;
if sResult is not None:
return True;
return False;
self._writeOutput('%s: %s: Failed - dResponse=%s' % (utils.getTimePrefix(), sOperation, dResponse,));
self._writeOutput('%s: %s: Unexpected Content-Type: %s' % (utils.getTimePrefix(), sOperation, sContentType,));
while True:
if fRc is not None:
return fRc;
logXcpt();
return False;
while True:
fRc = None;
return (None, False);
return (None, True);
if not fDtor:
return False;
return fRc;
if fIncErrors:
if asXml is None:
return True;
return False;
return False;
_ = sCaller;
## @todo should validate the document here and maybe auto terminate things. Adding some hints to have the server do
if fIncErrors:
if oType is not None:
if sText is not None:
asInfo = [];
g_oReporter.log(0, 'internal-error: Hit exception #2! %s' % (traceback.format_exc()), sCaller, sTsPrf);
return rc;
_ = cb;
return True;
_ = cb;
return rc;
return rc;
return False;
return False;
return False;
return False;
return False;
if sAltName is None:
return fRc;
def isLocal():
def incVerbosity():
def incDebug():
def getErrorCount():
return cErrors;
return rc;
return rc;
return False;
if oType is not None:
return False;
return rc;
def testErrorCount():
return cErrors;
def testCleanup():
return fRc;
return fRc;
def checkTestManagerConnection():
return fRc;
def flushall():
return True;
def _InitReporterModule():