Changeset 61323 in vbox for trunk/src/VBox/ValidationKit/testdriver/reporter.py
- Timestamp:
- May 31, 2016 9:08:04 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/testdriver/reporter.py
r61189 r61323 168 168 """ 169 169 _ = oSrcFile; _ = sSrcFilename; _ = sAltName; _ = sDescription; _ = sKind; _ = sCaller; _ = sTsPrf; 170 return True; 171 172 def addLogString(self, sLog, sLogName, sAltName, sDescription, sKind, sCaller, sTsPrf): 173 """ 174 Adds the file to the report. 175 Returns True on success, False on failure. 176 """ 177 _ = sLog; _ = sLogName; _ = sAltName; _ = sDescription; _ = sKind; _ = sCaller; _ = sTsPrf; 170 178 return True; 171 179 … … 465 473 return fRc; 466 474 475 def addLogString(self, sLog, sLogName, sAltName, sDescription, sKind, sCaller, sTsPrf): 476 # Figure the destination filename. 477 iOtherFile = self.iOtherFile; 478 self.iOtherFile += 1; 479 sDstFilename = os.path.join(self.sLogDir, 'other-%d-%s.log' \ 480 % (iOtherFile, os.path.splitext(os.path.basename(sLogName))[0])); 481 self.log(0, '** Other log file: %s - %s (%s)' % (sDstFilename, sDescription, sLogName), sCaller, sTsPrf); 482 483 # Open the destination file and copy over the data. 484 fRc = True; 485 try: 486 oDstFile = utils.openNoInherit(sDstFilename, 'w'); 487 except Exception, oXcpt: 488 self.log(0, 'error opening %s: %s' % (sDstFilename, oXcpt), sCaller, sTsPrf); 489 else: 490 try: 491 oDstFile.write(sLog); 492 except Exception, oXcpt: 493 fRc = False; 494 self.log(0, 'error writing %s: %s' % (sDstFilename, oXcpt), sCaller, sTsPrf); 495 496 oDstFile.close(); 497 498 # Leave a mark in the XML log. 499 self._xmlWrite(['<LogFile timestamp="%s" filename="%s" source="%s" kind="%s" ok="%s">%s</LogFile>\n' 500 % (utils.getIsoTimestamp(), self._xmlEscAttr(os.path.basename(sDstFilename)), self._xmlEscAttr(sLogName), \ 501 self._xmlEscAttr(sKind), fRc, self._xmlEscAttr(sDescription))] ); 502 _ = sAltName; 503 return fRc; 504 467 505 def subXmlStart(self, oFileWrapper): 468 506 # Open a new file and just include it from the main XML. … … 682 720 return False; 683 721 722 def _doUploadString(self, sSrc, sSrcName, sDescription, sKind, sMime): 723 """ Uploads the given string as a separate file to the test manager. """ 724 725 # Prepare header and url. 726 dHeader = dict(self._dHttpHeader); 727 dHeader['Content-Type'] = 'application/octet-stream'; 728 self._writeOutput('%s: _doUploadString: sHeader=%s' % (utils.getTimePrefix(), dHeader,)); 729 self._writeOutput('%s: _doUploadString: size=%d' % (utils.getTimePrefix(), sys.getsizeof(sSrc),)); 730 731 from common import constants; 732 sUrl = self._sTmServerPath + '&' \ 733 + self._fnUrlEncode({ constants.tbreq.UPLOAD_PARAM_NAME: os.path.basename(sSrcName), 734 constants.tbreq.UPLOAD_PARAM_DESC: sDescription, 735 constants.tbreq.UPLOAD_PARAM_KIND: sKind, 736 constants.tbreq.UPLOAD_PARAM_MIME: sMime, 737 constants.tbreq.ALL_PARAM_ACTION: constants.tbreq.UPLOAD, 738 }); 739 740 # Retry loop. 741 secStart = utils.timestampSecond(); 742 while True: 743 try: 744 oConn = self._fnTmConnect(); 745 oConn.request('POST', sUrl, sSrc, dHeader); 746 fRc = self._processTmStatusResponse(oConn, '_doUploadString', fClose = True); 747 oConn.close(); 748 if fRc is not None: 749 return fRc; 750 except: 751 logXcpt('warning: exception during UPLOAD request'); 752 753 if utils.timestampSecond() - secStart >= self.kcSecTestManagerRetryTimeout: 754 self._writeOutput('%s: _doUploadString: Timed out.' % (utils.getTimePrefix(),)); 755 break; 756 self._writeOutput('%s: _doUploadString: Retrying...' % (utils.getTimePrefix(), )); 757 time.sleep(2); 758 759 return False; 760 684 761 def _xmlDoFlush(self, asXml, fRetry = False, fDtor = False): 685 762 """ … … 757 834 self.log(0, '*** UNKNOWN FILE "%s" - KIND "%s" - DESC "%s" ***' 758 835 % (sSrcFilename, sKind, sDescription), sCaller, sTsPrf); 836 return fRc; 837 838 def addLogString(self, sLog, sLogName, sAltName, sDescription, sKind, sCaller, sTsPrf): 839 fRc = True; 840 if sKind in [ 'text', 'log', ] or sKind.startswith('log/'): 841 self.log(0, '*** Uploading "%s" - KIND: "%s" - DESC: "%s" ***' 842 % (sLogName, sKind, sDescription), sCaller, sTsPrf); 843 self.xmlFlush(); 844 g_oLock.release(); 845 self._doUploadString(sLog, sAltName, sDescription, sKind, 'text/plain'); 846 g_oLock.acquire(); 847 else: 848 self.log(0, '*** UNKNOWN FILE "%s" - KIND "%s" - DESC "%s" ***' 849 % (sLogName, sKind, sDescription), sCaller, sTsPrf); 759 850 return fRc; 760 851 … … 1223 1314 return fRc; 1224 1315 1316 def addLogString(sLog, sLogName, sKind, sDescription = ''): 1317 """ 1318 Adds the specified log string to the report. 1319 1320 The sLog parameter sets the name of the log file. 1321 1322 The sDescription is a free form description of the log file. 1323 1324 The sKind parameter is for adding some machine parsable hint what kind of 1325 log file this really is. 1326 1327 Returns True on success, False on failure (no ENOENT errors are logged). 1328 """ 1329 sTsPrf = utils.getTimePrefix(); 1330 sCaller = utils.getCallerName(); 1331 fRc = False; 1332 1333 g_oLock.acquire(); 1334 fRc = g_oReporter.addLogString(sLog, sLogName, None, sDescription, sKind, sCaller, sTsPrf); 1335 g_oLock.release(); 1336 return fRc; 1337 1225 1338 def isLocal(): 1226 1339 """Is this a local reporter?"""
Note:
See TracChangeset
for help on using the changeset viewer.