Changeset 61220 in vbox for trunk/src/VBox/ValidationKit
- Timestamp:
- May 27, 2016 1:16:02 AM (9 years ago)
- Location:
- trunk/src/VBox/ValidationKit/testmanager
- Files:
-
- 35 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/testmanager/core/base.py
r61149 r61220 53 53 pass; 54 54 55 55 56 class TMTooManyRows(TMExceptionBase): 56 57 """ 57 58 Too many rows in the result. 59 Used by ModelLogicBase decendants. 60 """ 61 pass; 62 63 64 class TMRowNotFound(TMExceptionBase): 65 """ 66 Database row not found. 67 Used by ModelLogicBase decendants. 68 """ 69 pass; 70 71 72 class TMRowAlreadyExists(TMExceptionBase): 73 """ 74 Database row already exists (typically raised by addEntry). 75 Used by ModelLogicBase decendants. 76 """ 77 pass; 78 79 80 class TMInvalidData(TMExceptionBase): 81 """ 82 Data validation failed. 83 Used by ModelLogicBase decendants. 84 """ 85 pass; 86 87 88 class TMRowInUse(TMExceptionBase): 89 """ 90 Database row is in use and cannot be deleted. 58 91 Used by ModelLogicBase decendants. 59 92 """ … … 81 114 # an empty array ([]) instead of None as database NULL value. 82 115 kasAltArrayNull = []; 116 117 ## validate 118 ## @{ 119 ksValidateFor_Add = 'add'; 120 ksValidateFor_AddForeignId = 'add-foreign-id'; 121 ksValidateFor_Edit = 'edit'; 122 ksValidateFor_Other = 'other'; 123 ## @} 83 124 84 125 … … 125 166 Returns the hungarian prefix of the given name. 126 167 """ 127 for i in range(len(sName)):168 for i, _ in enumerate(sName): 128 169 if sName[i] not in ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 129 170 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']: … … 179 220 elif isinstance(oValue, list) and len(oValue) > 0 and isinstance(oValue[0], ModelDataBase): 180 221 oValue = copy.copy(oValue); 181 for i in range(len(oValue)):222 for i, _ in enumerate(oValue): 182 223 assert isinstance(oValue[i], ModelDataBase); 183 224 oValue[i] = copy.copy(oValue[i]); … … 215 256 elif isinstance(oValue, list) and len(oValue) > 0 and isinstance(oValue[0], ModelDataBase): 216 257 oValue = copy.copy(oValue); 217 for i in range(len(oValue)):258 for i, _ in enumerate(oValue): 218 259 assert isinstance(oValue[i], ModelDataBase); 219 260 oValue[i] = copy.copy(oValue[i]); … … 295 336 return (oNewValue, sError); 296 337 297 def _validateAndConvertWorker(self, asAllowNullAttributes, oDb ):338 def _validateAndConvertWorker(self, asAllowNullAttributes, oDb, enmValidateFor = ksValidateFor_Other): 298 339 """ 299 340 Worker for implementing validateAndConvert(). … … 312 353 if sError is not None: 313 354 dErrors[sParam] = sError; 355 356 # Check the NULL requirements of the primary ID(s) for the 'add' and 'edit' actions. 357 if enmValidateFor == ModelDataBase.ksValidateFor_Add \ 358 or enmValidateFor == ModelDataBase.ksValidateFor_AddForeignId \ 359 or enmValidateFor == ModelDataBase.ksValidateFor_Edit: 360 fMustBeNull = enmValidateFor == ModelDataBase.ksValidateFor_Add; 361 sAttr = getattr(self, 'ksIdAttr', None); 362 if sAttr is not None: 363 oValue = getattr(self, sAttr); 364 if (oValue is None) != fMustBeNull: 365 sParam = getattr(self, 'ksParam_' + sAttr); 366 sErrMsg = 'Must be NULL!' if fMustBeNull else 'Must not be NULL!' 367 if sParam in dErrors: 368 dErrors[sParam] += ' ' + sErrMsg; 369 else: 370 dErrors[sParam] = sErrMsg; 371 314 372 return dErrors; 315 373 316 def validateAndConvert(self, oDb ):374 def validateAndConvert(self, oDb, enmValidateFor = ksValidateFor_Other): 317 375 """ 318 376 Validates the input and converts valid fields to their right type. … … 328 386 kasValidValues_enmAttr, and kasAllowNullAttributes. 329 387 """ 330 return self._validateAndConvertWorker(getattr(self, 'kasAllowNullAttributes', list()), oDb); 388 return self._validateAndConvertWorker(getattr(self, 'kasAllowNullAttributes', list()), oDb, 389 enmValidateFor = enmValidateFor); 331 390 332 391 def convertParamToAttribute(self, sAttr, sParam, oValue, oDisp, fStrict): … … 402 461 if isinstance(oValue1, list) and isinstance(oValue2, list): 403 462 if len(oValue1) == len(oValue2): 404 for i in range(len(oValue1)):463 for i, _ in enumerate(oValue1): 405 464 if not isinstance(oValue1[i], ModelDataBase) \ 406 or type(oValue1) !=type(oValue2):465 or type(oValue1) is not type(oValue2): 407 466 return False; 408 467 if not oValue1[i].isEqual(oValue2[i]): … … 411 470 412 471 elif isinstance(oValue1, ModelDataBase) \ 413 and type(oValue1) ==type(oValue2):472 and type(oValue1) is type(oValue2): 414 473 return oValue1[i].isEqual(oValue2[i]); 415 474 … … 678 737 oType = type(asValues[0]); 679 738 for i in range(1, len(asValues)): 680 if type(asValues[i]) is not oType: 739 if type(asValues[i]) is not oType: # pylint: disable=C0123 681 740 return (asValues, 'Invalid entry data type ([0]=%s vs [%d]=%s).' % (oType, i, type(asValues[i])) ); 682 741 … … 719 778 720 779 if sError is None and asValues not in aoNilValues and len(asValues) > 0: 721 for i in range(len(asValues)):780 for i, _ in enumerate(asValues): 722 781 sValue = asValues[i]; 723 782 … … 1077 1136 self.assertIsNotNone(oSample.toString()); 1078 1137 1079 # pylint: enable=E1101,C0111,R09031080 1081 1138 1082 1139 class ModelLogicBase(ModelBase): # pylint: disable=R0903 -
trunk/src/VBox/ValidationKit/testmanager/core/build.py
r56295 r61220 37 37 from testmanager import config; 38 38 from testmanager.core import coreconsts; 39 from testmanager.core.base import ModelDataBase, ModelDataBaseTestCase, ModelLogicBase, TMExceptionBase; 39 from testmanager.core.base import ModelDataBase, ModelDataBaseTestCase, ModelLogicBase, TMExceptionBase, \ 40 TMTooManyRows, TMInvalidData, TMRowNotFound, TMRowInUse; 40 41 41 42 … … 76 77 """ 77 78 if aoRow is None: 78 raise TM ExceptionBase('BuildCategory not found.');79 raise TMRowNotFound('BuildCategory not found.'); 79 80 80 81 self.idBuildCategory = aoRow[0]; … … 94 95 aoRow = oDb.fetchOne() 95 96 if aoRow is None: 96 raise TM ExceptionBase('idBuildCategory=%s not found' % (idBuildCategory, ));97 raise TMRowNotFound('idBuildCategory=%s not found' % (idBuildCategory, )); 97 98 return self.initFromDbRow(aoRow); 98 99 … … 220 221 cBuilds = self._oDb.fetchOne()[0]; 221 222 if cBuilds > 0: 222 raise TM ExceptionBase('Build category #%d is used by %d builds and can therefore not be deleted.'223 223 raise TMRowInUse('Build category #%d is used by %d builds and can therefore not be deleted.' 224 % (idBuildCategory, cBuilds,)); 224 225 225 226 # … … 294 295 295 296 # Check BuildCategoryData before do anything 296 dDataErrors = oData.validateAndConvert(self._oDb );297 dDataErrors = oData.validateAndConvert(self._oDb, oData.ksValidateFor_Add); 297 298 if len(dDataErrors) > 0: 298 raise TM ExceptionBase('Invalid data passed to addBuildCategory(): %s' % (dDataErrors,));299 raise TMInvalidData('Invalid data passed to addBuildCategory(): %s' % (dDataErrors,)); 299 300 300 301 # Does it already exist? … … 363 364 """ 364 365 if aoRow is None: 365 raise TM ExceptionBase('Build not found.');366 raise TMRowNotFound('Build not found.'); 366 367 367 368 self.idBuild = aoRow[0]; … … 389 390 aoRow = oDb.fetchOne() 390 391 if aoRow is None: 391 raise TM ExceptionBase('idBuild=%s not found (tsNow=%s sPeriodBack=%s)' % (idBuild, tsNow, sPeriodBack,));392 raise TMRowNotFound('idBuild=%s not found (tsNow=%s sPeriodBack=%s)' % (idBuild, tsNow, sPeriodBack,)); 392 393 return self.initFromDbRow(aoRow); 393 394 … … 443 444 """ 444 445 if aoRow is None: 445 raise TM ExceptionBase('Build not found.');446 raise TMRowNotFound('Build not found.'); 446 447 BuildData.initFromDbRow(self, aoRow); 447 448 self.oCat = BuildCategoryData().initFromDbRow(aoRow[11:]); … … 461 462 aoRow = oDb.fetchOne() 462 463 if aoRow is None: 463 raise TM ExceptionBase('idBuild=%s not found (tsNow=%s sPeriodBack=%s)' % (idBuild, tsNow, sPeriodBack,));464 raise TMRowNotFound('idBuild=%s not found (tsNow=%s sPeriodBack=%s)' % (idBuild, tsNow, sPeriodBack,)); 464 465 return self.initFromDbRow(aoRow); 465 466 … … 556 557 # Validate input and get current data. 557 558 # 558 dErrors = oData.validateAndConvert(self._oDb );559 dErrors = oData.validateAndConvert(self._oDb, oData.ksValidateFor_Edit); 559 560 if len(dErrors) > 0: 560 raise TM ExceptionBase('editEntry invalid input: %s' % (dErrors,));561 raise TMInvalidData('editEntry invalid input: %s' % (dErrors,)); 561 562 oOldData = BuildData().initFromDbWithId(self._oDb, oData.idBuild); 562 563 … … 714 715 aRows = self._oDb.fetchAll() 715 716 if len(aRows) not in (0, 1): 716 raise TM ExceptionBase('Found more than one build with the same credentials. Database structure is corrupted.')717 raise TMTooManyRows('Found more than one build with the same credentials. Database structure is corrupted.') 717 718 try: 718 719 return BuildDataEx().initFromDbRow(aRows[0]) -
trunk/src/VBox/ValidationKit/testmanager/core/buildblacklist.py
r56295 r61220 31 31 32 32 # Validation Kit imports. 33 from testmanager.core.base import ModelDataBase, ModelLogicBase, TM ExceptionBase33 from testmanager.core.base import ModelDataBase, ModelLogicBase, TMInvalidData, TMRowNotFound; 34 34 35 35 … … 87 87 88 88 if aoRow is None: 89 raise TM ExceptionBase('Build Blacklist item not found.')89 raise TMRowNotFound('Build Blacklist item not found.') 90 90 91 91 self.idBlacklisting = aoRow[0] … … 114 114 aoRow = oDb.fetchOne() 115 115 if aoRow is None: 116 raise TM ExceptionBase('idBlacklisting=%s not found (tsNow=%s sPeriodBack=%s)'117 116 raise TMRowNotFound('idBlacklisting=%s not found (tsNow=%s sPeriodBack=%s)' 117 % (idBlacklisting, tsNow, sPeriodBack,)); 118 118 return self.initFromDbRow(aoRow); 119 119 … … 187 187 # 188 188 assert isinstance(oData, BuildBlacklistData); 189 dErrors = oData.validateAndConvert(self._oDb );189 dErrors = oData.validateAndConvert(self._oDb, oData.ksValidateFor_Edit); 190 190 if len(dErrors) > 0: 191 raise TM ExceptionBase('editEntry invalid input: %s' % (dErrors,));191 raise TMInvalidData('editEntry invalid input: %s' % (dErrors,)); 192 192 193 193 oOldData = BuildBlacklistData().initFromDbWithId(self._oDb, oData.idBlacklisting); -
trunk/src/VBox/ValidationKit/testmanager/core/buildsource.py
r56295 r61220 35 35 # Validation Kit imports. 36 36 from common import utils; 37 from testmanager.core.base import ModelDataBase, ModelDataBaseTestCase, ModelLogicBase, TMExceptionBase; 37 from testmanager.core.base import ModelDataBase, ModelDataBaseTestCase, ModelLogicBase, TMRowAlreadyExists, \ 38 TMRowInUse, TMInvalidData, TMRowNotFound; 38 39 from testmanager.core import coreconsts; 39 40 … … 90 91 """ 91 92 if aoRow is None: 92 raise TM ExceptionBase('Build source not found.');93 raise TMRowNotFound('Build source not found.'); 93 94 94 95 self.idBuildSrc = aoRow[0]; … … 118 119 aoRow = oDb.fetchOne() 119 120 if aoRow is None: 120 raise TM ExceptionBase('idBuildSrc=%s not found (tsNow=%s sPeriodBack=%s)' % (idBuildSrc, tsNow, sPeriodBack,));121 raise TMRowNotFound('idBuildSrc=%s not found (tsNow=%s sPeriodBack=%s)' % (idBuildSrc, tsNow, sPeriodBack,)); 121 122 return self.initFromDbRow(aoRow); 122 123 … … 205 206 # Validate the input. 206 207 # 207 dErrors = oData.validateAndConvert(self._oDb );208 dErrors = oData.validateAndConvert(self._oDb, oData.ksValidateFor_Add); 208 209 if len(dErrors) > 0: 209 raise TM ExceptionBase('addEntry invalid input: %s' % (dErrors,));210 raise TMInvalidData('addEntry invalid input: %s' % (dErrors,)); 210 211 self._assertUnique(oData, None); 211 212 … … 247 248 # Validate the input and read the old entry. 248 249 # 249 dErrors = oData.validateAndConvert(self._oDb );250 dErrors = oData.validateAndConvert(self._oDb, oData.ksValidateFor_Edit); 250 251 if len(dErrors) > 0: 251 raise TM ExceptionBase('addEntry invalid input: %s' % (dErrors,));252 raise TMInvalidData('addEntry invalid input: %s' % (dErrors,)); 252 253 self._assertUnique(oData, oData.idBuildSrc); 253 254 oOldData = BuildSourceData().initFromDbWithId(self._oDb, oData.idBuildSrc); … … 303 304 for aoRow in self._oDb.fetchAll(): 304 305 asGroups.append('%s (#%d)' % (aoRow[1], aoRow[0])); 305 raise TM ExceptionBase('Build source #%d is used by one or more scheduling groups: %s'306 306 raise TMRowInUse('Build source #%d is used by one or more scheduling groups: %s' 307 % (idBuildSrc, ', '.join(asGroups),)); 307 308 else: 308 309 self._oDb.execute('UPDATE SchedGroups\n' … … 435 436 , ( oData.sName, )) 436 437 if self._oDb.getRowCount() > 0: 437 raise TM ExceptionBase('A build source with name "%s" already exist.' % (oData.sName,));438 raise TMRowAlreadyExists('A build source with name "%s" already exist.' % (oData.sName,)); 438 439 return True; 439 440 -
trunk/src/VBox/ValidationKit/testmanager/core/dbobjcache.py
r56295 r61220 76 76 def _handleDbException(self): 77 77 """ Deals with database exceptions. """ 78 raise;79 78 #self._oDb.rollback(); 80 #return False;79 return False; 81 80 82 81 def getTestResultString(self, idStrName): … … 98 97 oRet = BuildCategoryData(); 99 98 try: oRet.initFromDbWithId(self._oDb, idBuildCategory); 100 except: self._handleDbException(); 99 except: self._handleDbException(); raise; 101 100 self._adCache[self.ksObjType_BuildCategory_idBuildCategory][idBuildCategory] = oRet; 102 101 return oRet; … … 110 109 oRet = TestBoxData(); 111 110 try: oRet.initFromDbWithId(self._oDb, idTestBox, self.tsNow, self.sPeriodBack); 112 except: self._handleDbException(); 111 except: self._handleDbException(); raise; 113 112 else: self._adCache[self.ksObjType_TestBox_idGenTestBox][oRet.idGenTestBox] = oRet; 114 113 self._adCache[self.ksObjType_TestBox_idTestBox][idTestBox] = oRet; … … 123 122 oRet = TestCaseData(); 124 123 try: oRet.initFromDbWithId(self._oDb, idTestCase, self.tsNow, self.sPeriodBack); 125 except: self._handleDbException(); 124 except: self._handleDbException(); raise; 126 125 else: self._adCache[self.ksObjType_TestCase_idGenTestCase][oRet.idGenTestCase] = oRet; 127 126 self._adCache[self.ksObjType_TestCase_idTestCase][idTestCase] = oRet; … … 136 135 oRet = TestCaseArgsData(); 137 136 try: oRet.initFromDbWithId(self._oDb, idTestCaseArgs, self.tsNow, self.sPeriodBack); 138 except: self._handleDbException(); 137 except: self._handleDbException(); raise; 139 138 else: self._adCache[self.ksObjType_TestCaseArgs_idGenTestCaseArgs][oRet.idGenTestCaseArgs] = oRet; 140 139 self._adCache[self.ksObjType_TestCaseArgs_idTestCaseArgs][idTestCaseArgs] = oRet; -
trunk/src/VBox/ValidationKit/testmanager/core/failurecategory.py
r61217 r61220 31 31 32 32 # Validation Kit imports. 33 from testmanager.core.base import ModelDataBase, ModelLogicBase, TM ExceptionBase34 from testmanager.core.failurereason import FailureReasonLogic 33 from testmanager.core.base import ModelDataBase, ModelLogicBase, TMRowInUse, TMInvalidData, TMRowNotFound; 34 35 35 36 36 class FailureCategoryData(ModelDataBase): … … 38 38 Failure Category Data. 39 39 """ 40 41 ksIdAttr = 'idFailureCategory'; 40 42 41 43 ksParam_idFailureCategory = 'FailureCategory_idFailureCategory' … … 71 73 72 74 if aoRow is None: 73 raise TM ExceptionBase('Failure Category not found.');75 raise TMRowNotFound('Failure Category not found.'); 74 76 75 77 self.idFailureCategory = aoRow[0] … … 81 83 82 84 return self 85 86 def initFromDbWithId(self, oDb, idFailureCategory, tsNow = None, sPeriodBack = None): 87 """ 88 Initialize from the database, given the ID of a row. 89 """ 90 oDb.execute(self.formatSimpleNowAndPeriodQuery(oDb, 91 'SELECT *\n' 92 'FROM FailureCategories\n' 93 'WHERE idFailureCategory = %s\n' 94 , ( idFailureCategory,), tsNow, sPeriodBack)); 95 aoRow = oDb.fetchOne() 96 if aoRow is None: 97 raise TMRowNotFound('idFailureCategory=%s not found (tsNow=%s sPeriodBack=%s)' 98 % (idFailureCategory, tsNow, sPeriodBack,)); 99 return self.initFromDbRow(aoRow); 83 100 84 101 … … 158 175 return None 159 176 160 def addEntry(self, oFailureCategoryData, uidAuthor, fCommit=True): 161 """ 162 Add Failure Category record 163 """ 164 165 # Check if record with the same sShort fiels is already exists 166 self._oDb.execute('SELECT *\n' 167 'FROM FailureCategories\n' 168 'WHERE tsExpire = \'infinity\'::TIMESTAMP\n' 169 ' AND sShort = %s\n', 170 (oFailureCategoryData.sShort,)) 171 if len(self._oDb.fetchAll()) != 0: 172 raise Exception('Record already exist') 173 174 # Add record 175 self._oDb.execute('INSERT INTO FailureCategories (\n' 176 ' uidAuthor, sShort, sFull' 177 ')\n' 178 'VALUES (%s, %s, %s)', 179 (uidAuthor, 180 oFailureCategoryData.sShort, 181 oFailureCategoryData.sFull)) 182 if fCommit: 183 self._oDb.commit() 184 185 return True 186 187 def remove(self, uidAuthor, idFailureCategory, fNeedCommit=True): 188 """ 189 Historize record 190 """ 191 192 # Historize Failure Reasons records first 193 self._oDb.execute('SELECT idFailureReason\n' 194 'FROM FailureReasons\n' 195 'WHERE idFailureCategory = %s\n' 196 ' AND tsExpire = \'infinity\'::TIMESTAMP\n', 197 (idFailureCategory,)) 198 for iFailureReasonId in self._oDb.fetchAll(): 199 FailureReasonLogic(self._oDb).remove(uidAuthor, iFailureReasonId, fNeedCommit = False) 200 201 self._oDb.execute('UPDATE FailureCategories\n' 202 'SET tsExpire = CURRENT_TIMESTAMP,\n' 203 ' uidAuthor = %s\n' 204 'WHERE idFailureCategory = %s\n' 205 ' AND tsExpire = \'infinity\'::TIMESTAMP\n', 206 (uidAuthor, idFailureCategory)) 207 208 if fNeedCommit: 209 self._oDb.commit() 210 211 return True 212 213 def editEntry(self, oFailureCategoryData, uidAuthor, fCommit=True): 214 """Modify database record""" 215 216 # Check if record exists 217 oFailureCategoryDataOld = self.getById(oFailureCategoryData.idFailureCategory) 218 if oFailureCategoryDataOld is None: 219 raise TMExceptionBase( 220 'Failure Category (id: %d) does not exist' 221 % oFailureCategoryData.idFailureCategory) 222 223 # Check if anything has been changed 224 if oFailureCategoryData.isEqual(oFailureCategoryDataOld): 225 return True 226 227 # Historize record 228 self.remove( 229 uidAuthor, oFailureCategoryData.idFailureCategory, fNeedCommit=False) 230 231 self._oDb.execute('INSERT INTO FailureCategories (\n' 232 ' idFailureCategory, uidAuthor, sShort, sFull' 233 ')\n' 234 'VALUES (%s, %s, %s, %s)', 235 (oFailureCategoryData.idFailureCategory, 236 uidAuthor, 237 oFailureCategoryData.sShort, 238 oFailureCategoryData.sFull)) 239 if fCommit: 240 self._oDb.commit() 241 242 return True 177 178 def addEntry(self, oData, uidAuthor, fCommit = False): 179 """ 180 Add a failure reason category. 181 """ 182 # 183 # Validate inputs and read in the old(/current) data. 184 # 185 assert isinstance(oData, FailureCategoryData); 186 dErrors = oData.validateAndConvert(self._oDb, oData.ksValidateFor_Add); 187 if len(dErrors) > 0: 188 raise TMInvalidData('editEntry invalid input: %s' % (dErrors,)); 189 190 # 191 # Add the record. 192 # 193 self._readdEntry(uidAuthor, oData); 194 self._oDb.maybeCommit(fCommit); 195 return True; 196 197 198 def editEntry(self, oData, uidAuthor, fCommit = False): 199 """ 200 Modifies a failure reason category. 201 """ 202 203 # 204 # Validate inputs and read in the old(/current) data. 205 # 206 assert isinstance(oData, FailureCategoryData); 207 dErrors = oData.validateAndConvert(self._oDb, oData.ksValidateFor_Edit); 208 if len(dErrors) > 0: 209 raise TMInvalidData('editEntry invalid input: %s' % (dErrors,)); 210 211 oOldData = FailureCategoryData().initFromDbWithId(self._oDb, oData.idFailureCategory); 212 213 # 214 # Update the data that needs updating. 215 # 216 if not oData.isEqualEx(oOldData, [ 'tsEffective', 'tsExpire', 'uidAuthor', ]): 217 self._historizeEntry(oData.idFailureCategory); 218 self._readdEntry(uidAuthor, oData); 219 self._oDb.maybeCommit(fCommit); 220 return True; 221 222 223 def removeEntry(self, uidAuthor, idFailureCategory, fCascade = False, fCommit = False): 224 """ 225 Deletes a failure reason category. 226 """ 227 _ = fCascade; # too complicated for now. 228 229 # 230 # Check whether it's being used by other tables and bitch if it is . 231 # We currently do not implement cascading. 232 # 233 self._oDb.execute('SELECT CONCAT(idFailureReason, \' - \', sShort)\n' 234 'FROM FailureReasons\n' 235 'WHERE idFailureCategory = %s\n' 236 ' AND tsExpire = \'infinity\'::TIMESTAMP\n' 237 , (idFailureCategory,)); 238 aaoRows = self._oDb.fetchAll(); 239 if len(aaoRows) > 0: 240 raise TMRowInUse('Cannot remove failure reason category %u because its being used by: %s' 241 % (idFailureCategory, ', '.join(aoRow[0] for aoRow in aaoRows),)); 242 243 # 244 # Do the job. 245 # 246 oData = FailureCategoryData().initFromDbWithId(self._oDb, idFailureCategory); 247 (tsCur, tsCurMinusOne) = self._oDb.getCurrentTimestamps(); 248 if oData.tsEffective != tsCur and oData.tsEffective != tsCurMinusOne: 249 self._historizeEntry(idFailureCategory, tsCurMinusOne); 250 self._readdEntry(uidAuthor, oData, tsCurMinusOne); 251 self._historizeEntry(idFailureCategory); 252 self._oDb.maybeCommit(fCommit); 253 return True; 254 243 255 244 256 def cachedLookup(self, idFailureCategory): … … 276 288 return oEntry; 277 289 290 291 # 292 # Helpers. 293 # 294 295 def _readdEntry(self, uidAuthor, oData, tsEffective = None): 296 """ 297 Re-adds the FailureCategories entry. Used by addEntry, editEntry and removeEntry. 298 """ 299 if tsEffective is None: 300 tsEffective = self._oDb.getCurrentTimestamp(); 301 self._oDb.execute('INSERT INTO FailureCategories (\n' 302 ' uidAuthor,\n' 303 ' tsEffective,\n' 304 ' idFailureCategory,\n' 305 ' sShort,\n' 306 ' sFull)\n' 307 'VALUES (%s, %s, ' 308 + ('DEFAULT' if oData.idFailureCategory is None else str(oData.idFailureCategory)) 309 + ', %s, %s)\n' 310 , ( uidAuthor, 311 tsEffective, 312 oData.sShort, 313 oData.sFull,) ); 314 return True; 315 316 317 def _historizeEntry(self, idFailureCategory, tsExpire = None): 318 """ Historizes the current entry. """ 319 if tsExpire is None: 320 tsExpire = self._oDb.getCurrentTimestamp(); 321 self._oDb.execute('UPDATE FailureCategories\n' 322 'SET tsExpire = %s\n' 323 'WHERE idFailureCategory = %s\n' 324 ' AND tsExpire = \'infinity\'::TIMESTAMP\n' 325 , (tsExpire, idFailureCategory,)); 326 return True; 327 328 -
trunk/src/VBox/ValidationKit/testmanager/core/failurereason.py
r61217 r61220 31 31 32 32 # Validation Kit imports. 33 from testmanager.core.base import ModelDataBase, ModelLogicBase, TM ExceptionBase33 from testmanager.core.base import ModelDataBase, ModelLogicBase, TMRowNotFound, TMInvalidData, TMRowInUse; 34 34 from testmanager.core.useraccount import UserAccountLogic; 35 35 … … 82 82 83 83 if aoRow is None: 84 raise TM ExceptionBase('Failure Reason not found.');84 raise TMRowNotFound('Failure Reason not found.'); 85 85 86 86 self.idFailureReason = aoRow[0] … … 95 95 96 96 return self; 97 98 def initFromDbWithId(self, oDb, idFailureReason, tsNow = None, sPeriodBack = None): 99 """ 100 Initialize from the database, given the ID of a row. 101 """ 102 oDb.execute(self.formatSimpleNowAndPeriodQuery(oDb, 103 'SELECT *\n' 104 'FROM FailureReasons\n' 105 'WHERE idFailureReason = %s\n' 106 , ( idFailureReason,), tsNow, sPeriodBack)); 107 aoRow = oDb.fetchOne() 108 if aoRow is None: 109 raise TMRowNotFound('idFailureReason=%s not found (tsNow=%s sPeriodBack=%s)' 110 % (idFailureReason, tsNow, sPeriodBack,)); 111 return self.initFromDbRow(aoRow); 97 112 98 113 … … 205 220 return None 206 221 207 def getIdsByCategory(self, idFailureCategory, tsEffective=None): 208 """ 209 Gets the list of Failure Ressons IDs, 210 all the items belong to @param idFailureCategory 211 """ 212 if tsEffective is None: 213 self._oDb.execute('SELECT idFailureReason\n' 214 'FROM FailureReasons\n' 215 'WHERE tsExpire = \'infinity\'::TIMESTAMP\n' 216 ' AND idFailureCategory = %s\n' 217 'ORDER BY idFailureReason DESC' 218 , (idFailureCategory,)) 219 else: 220 self._oDb.execute('SELECT idFailureReason\n' 221 'FROM FailureReasons\n' 222 'WHERE tsExpire > %s\n' 223 ' AND tsEffective <= %s\n' 224 ' AND idFailureCategory = %s\n' 225 'ORDER BY idFailureReason DESC' 226 , (tsEffective, tsEffective, idFailureCategory)) 227 return self._oDb.fetchAll() 228 229 def getAll(self, tsEffective=None): 230 """ 231 Gets the list of all Failure Reasons. 232 Returns an array of FailureReasonData instances. 233 """ 234 if tsEffective is None: 235 self._oDb.execute('SELECT *\n' 236 'FROM FailureReasons\n' 237 'WHERE tsExpire = \'infinity\'::TIMESTAMP\n' 238 'ORDER BY idFailureReason DESC') 239 else: 240 self._oDb.execute('SELECT *\n' 241 'FROM FailureReasons\n' 242 'WHERE tsExpire > %s\n' 243 ' AND tsEffective <= %s\n' 244 'ORDER BY idFailureReason DESC' 245 , (tsEffective, tsEffective)) 246 aoRet = [] 247 for aoRow in self._oDb.fetchAll(): 248 aoRet.append(FailureReasonData().initFromDbRow(aoRow)) 249 return aoRet 250 251 def addEntry(self, oFailureReasonData, uidAuthor, fCommit=True): 252 """Add record to database""" 253 254 # Check if record with the same sShort fiels is already exists 255 self._oDb.execute('SELECT *\n' 256 'FROM FailureReasons\n' 257 'WHERE tsExpire = \'infinity\'::TIMESTAMP\n' 258 ' AND sShort = %s\n', 259 (oFailureReasonData.sShort,)) 260 if len(self._oDb.fetchAll()) != 0: 261 raise Exception('Record already exist') 262 263 # Add record 264 self._oDb.execute('INSERT INTO FailureReasons (\n' 265 ' uidAuthor, idFailureCategory,' 266 ' sShort, sFull, iTicket, asUrls' 267 ')\n' 268 'VALUES (%s, %s, %s, %s, %s, %s)', 269 (uidAuthor, 270 oFailureReasonData.idFailureCategory, 271 oFailureReasonData.sShort, 272 oFailureReasonData.sFull, 273 oFailureReasonData.iTicket, 274 oFailureReasonData.asUrls)) 275 if fCommit: 276 self._oDb.commit() 277 278 return True 279 280 def remove(self, uidAuthor, idFailureReason, fNeedCommit=True): 281 """ 282 Historize record 283 """ 284 self._oDb.execute('UPDATE FailureReasons\n' 285 'SET tsExpire = CURRENT_TIMESTAMP,\n' 286 ' uidAuthor = %s\n' 287 'WHERE idFailureReason = %s\n' 288 ' AND tsExpire = \'infinity\'::TIMESTAMP\n', 289 (uidAuthor, idFailureReason)) 290 291 # Also historize Black List records 292 self._oDb.execute('UPDATE BuildBlackList\n' 293 'SET tsExpire = CURRENT_TIMESTAMP,\n' 294 ' uidAuthor = %s\n' 295 'WHERE idFailureReason = %s\n' 296 ' AND tsExpire = \'infinity\'::TIMESTAMP\n', 297 (uidAuthor, idFailureReason)) 298 299 if fNeedCommit: 300 self._oDb.commit() 301 302 return True 303 304 def editEntry(self, oFailureReasonData, uidAuthor, fCommit=True): 305 """Modify database record""" 306 307 # Check if record exists 308 oFailureReasonDataOld = self.getById(oFailureReasonData.idFailureReason) 309 if oFailureReasonDataOld is None: 310 raise TMExceptionBase( 311 'Failure Reason (id: %d) does not exist' 312 % oFailureReasonData.idFailureReason) 313 314 # Check if anything has been changed 315 if oFailureReasonData.isEqual(oFailureReasonDataOld): 316 return True 317 318 # Historize record 319 self.remove( 320 uidAuthor, oFailureReasonData.idFailureReason, fNeedCommit=False) 321 322 323 # Add new record (keeping its ID) 324 self._oDb.execute('INSERT INTO FailureReasons (\n' 325 ' idFailureReason,' 326 ' uidAuthor,' 327 ' idFailureCategory,' 328 ' sShort,' 329 ' sFull,' 330 ' iTicket,' 331 ' asUrls' 332 ')\n' 333 'VALUES (%s, %s, %s, %s, %s, %s, %s)', 334 (oFailureReasonData.idFailureReason, 335 uidAuthor, 336 oFailureReasonData.idFailureCategory, 337 oFailureReasonData.sShort, 338 oFailureReasonData.sFull, 339 oFailureReasonData.iTicket, 340 oFailureReasonData.asUrls 341 )) 342 343 if fCommit: 344 self._oDb.commit() 345 346 return True 222 223 def addEntry(self, oData, uidAuthor, fCommit = False): 224 """ 225 Add a failure reason. 226 """ 227 # 228 # Validate. 229 # 230 dErrors = oData.validateAndConvert(self._oDb, oData.ksValidateFor_Add); 231 if len(dErrors) > 0: 232 raise TMInvalidData('addEntry invalid input: %s' % (dErrors,)); 233 234 # 235 # Add the record. 236 # 237 self._readdEntry(uidAuthor, oData); 238 self._oDb.maybeCommit(fCommit); 239 return True; 240 241 242 def editEntry(self, oData, uidAuthor, fCommit = False): 243 """ 244 Modifies a failure reason. 245 """ 246 247 # 248 # Validate inputs and read in the old(/current) data. 249 # 250 assert isinstance(oData, FailureReasonData); 251 dErrors = oData.validateAndConvert(self._oDb, oData.ksValidateFor_Edit); 252 if len(dErrors) > 0: 253 raise TMInvalidData('editEntry invalid input: %s' % (dErrors,)); 254 255 oOldData = FailureReasonData().initFromDbWithId(self._oDb, oData.idFailureReason); 256 257 # 258 # Update the data that needs updating. 259 # 260 if not oData.isEqualEx(oOldData, [ 'tsEffective', 'tsExpire', 'uidAuthor', ]): 261 self._historizeEntry(oData.idFailureReason); 262 self._readdEntry(uidAuthor, oData); 263 self._oDb.maybeCommit(fCommit); 264 return True; 265 266 267 def removeEntry(self, uidAuthor, idFailureReason, fCascade = False, fCommit = False): 268 """ 269 Deletes a failure reason. 270 """ 271 _ = fCascade; # too complicated for now. 272 273 # 274 # Check whether it's being used by other tables and bitch if it is . 275 # We currently do not implement cascading. 276 # 277 self._oDb.execute('SELECT CONCAT(idBlacklisting, \' - blacklisting\')\n' 278 'FROM BuildBlacklist\n' 279 'WHERE idFailureReason = %s\n' 280 ' AND tsExpire = \'infinity\'::TIMESTAMP\n' 281 'UNION\n' 282 'SELECT CONCAT(idTestResult, \' - test result failure reason\')\n' 283 'FROM TestResultFailures\n' 284 'WHERE idFailureReason = %s\n' 285 ' AND tsExpire = \'infinity\'::TIMESTAMP\n' 286 , (idFailureReason, idFailureReason,)); 287 aaoRows = self._oDb.fetchAll(); 288 if len(aaoRows) > 0: 289 raise TMRowInUse('Cannot remove failure reason %u because its being used by: %s' 290 % (idFailureReason, ', '.join(aoRow[0] for aoRow in aaoRows),)); 291 292 # 293 # Do the job. 294 # 295 oData = FailureReasonData().initFromDbWithId(self._oDb, idFailureReason); 296 assert oData.idFailureReason == idFailureReason; 297 (tsCur, tsCurMinusOne) = self._oDb.getCurrentTimestamps(); 298 if oData.tsEffective != tsCur and oData.tsEffective != tsCurMinusOne: 299 self._historizeEntry(idFailureReason, tsCurMinusOne); 300 self._readdEntry(uidAuthor, oData, tsCurMinusOne); 301 self._historizeEntry(idFailureReason); 302 self._oDb.maybeCommit(fCommit); 303 return True; 304 347 305 348 306 def cachedLookup(self, idFailureReason): … … 385 343 return oEntry; 386 344 345 # 346 # Helpers. 347 # 348 349 def _readdEntry(self, uidAuthor, oData, tsEffective = None): 350 """ 351 Re-adds the FailureReasons entry. Used by addEntry, editEntry and removeEntry. 352 """ 353 if tsEffective is None: 354 tsEffective = self._oDb.getCurrentTimestamp(); 355 self._oDb.execute('INSERT INTO FailureReasons (\n' 356 ' uidAuthor,\n' 357 ' tsEffective,\n' 358 ' idFailureReason,\n' 359 ' idFailureCategory,\n' 360 ' sShort,\n' 361 ' sFull,\n' 362 ' iTicket,\n' 363 ' asUrls)\n' 364 'VALUES (%s, %s, ' 365 + ( 'DEFAULT' if oData.idFailureReason is None else str(oData.idFailureReason) ) 366 + ', %s, %s, %s, %s, %s)\n' 367 , ( uidAuthor, 368 tsEffective, 369 oData.idFailureCategory, 370 oData.sShort, 371 oData.sFull, 372 oData.iTicket, 373 oData.asUrls,) ); 374 return True; 375 376 377 def _historizeEntry(self, idFailureReason, tsExpire = None): 378 """ Historizes the current entry. """ 379 if tsExpire is None: 380 tsExpire = self._oDb.getCurrentTimestamp(); 381 self._oDb.execute('UPDATE FailureReasons\n' 382 'SET tsExpire = %s\n' 383 'WHERE idFailureReason = %s\n' 384 ' AND tsExpire = \'infinity\'::TIMESTAMP\n' 385 , (tsExpire, idFailureReason,)); 386 return True; 387 -
trunk/src/VBox/ValidationKit/testmanager/core/globalresource.py
r56295 r61220 34 34 35 35 # Validation Kit imports. 36 from testmanager.core.base import ModelDataBase, ModelDataBaseTestCase, ModelLogicBase, TM ExceptionBase;36 from testmanager.core.base import ModelDataBase, ModelDataBaseTestCase, ModelLogicBase, TMRowNotFound; 37 37 38 38 … … 77 77 """ 78 78 if aoRow is None: 79 raise TM ExceptionBase('Global resource not found.')79 raise TMRowNotFound('Global resource not found.') 80 80 81 81 self.idGlobalRsrc = aoRow[0] … … 99 99 aoRow = oDb.fetchOne() 100 100 if aoRow is None: 101 raise TM ExceptionBase('idGlobalRsrc=%s not found (tsNow=%s sPeriodBack=%s)' % (idGlobalRsrc, tsNow, sPeriodBack,));101 raise TMRowNotFound('idGlobalRsrc=%s not found (tsNow=%s sPeriodBack=%s)' % (idGlobalRsrc, tsNow, sPeriodBack,)); 102 102 return self.initFromDbRow(aoRow); 103 103 … … 220 220 return GlobalResourceData().initFromDbRow(aRows[0]) 221 221 except IndexError: 222 raise TM ExceptionBase('Global resource not found.')222 raise TMRowNotFound('Global resource not found.') 223 223 224 224 def allocateResources(self, idTestBox, aoGlobalRsrcs, fCommit = False): -
trunk/src/VBox/ValidationKit/testmanager/core/schedgroup.py
r56295 r61220 34 34 35 35 # Validation Kit imports. 36 from testmanager.core.base import ModelDataBase, ModelDataBaseTestCase, ModelLogicBase, TMExceptionBase; 36 from testmanager.core.base import ModelDataBase, ModelDataBaseTestCase, ModelLogicBase, TMExceptionBase, \ 37 TMRowInUse, TMInvalidData, TMRowAlreadyExists, TMRowNotFound; 37 38 from testmanager.core.buildsource import BuildSourceData; 38 39 from testmanager.core.testcase import TestCaseData; … … 89 90 90 91 if aoRow is None: 91 raise TM ExceptionBase('SchedGroupMember not found.');92 raise TMRowNotFound('SchedGroupMember not found.'); 92 93 93 94 self.idSchedGroup = aoRow[0]; … … 132 133 return asAttributes; 133 134 134 def _validateAndConvertWorker(self, asAllowNullAttributes, oDb ):135 dErrors = SchedGroupMemberData._validateAndConvertWorker(self, asAllowNullAttributes, oDb );135 def _validateAndConvertWorker(self, asAllowNullAttributes, oDb, enmValidateFor = ModelDataBase.ksValidateFor_Other): 136 dErrors = SchedGroupMemberData._validateAndConvertWorker(self, asAllowNullAttributes, oDb, enmValidateFor); 136 137 if self.ksParam_idTestGroup not in dErrors: 137 138 self.oTestGroup = TestGroupData(); … … 206 207 207 208 if aoRow is None: 208 raise TM ExceptionBase('SchedGroup not found.');209 raise TMRowNotFound('SchedGroup not found.'); 209 210 210 211 self.idSchedGroup = aoRow[0]; … … 231 232 aoRow = oDb.fetchOne() 232 233 if aoRow is None: 233 raise TM ExceptionBase('idSchedGroup=%s not found (tsNow=%s, sPeriodBack=%s)' % (idSchedGroup, tsNow, sPeriodBack));234 raise TMRowNotFound('idSchedGroup=%s not found (tsNow=%s, sPeriodBack=%s)' % (idSchedGroup, tsNow, sPeriodBack)); 234 235 return self.initFromDbRow(aoRow); 235 236 … … 389 390 aoNewMembers.append(oNewMember); 390 391 391 dErrors = oNewMember.validateAndConvert(oDb );392 dErrors = oNewMember.validateAndConvert(oDb, ModelDataBase.ksValidateFor_Other); 392 393 if len(dErrors) > 0: 393 394 asErrors.append(str(dErrors)); 394 395 395 396 if len(asErrors) == 0: 396 for i in range(len(aoNewMembers)):397 for i, _ in enumerate(aoNewMembers): 397 398 idTestGroup = aoNewMembers[i]; 398 399 for j in range(i + 1, len(aoNewMembers)): … … 403 404 return (aoNewMembers, None if len(asErrors) == 0 else '<br>\n'.join(asErrors)); 404 405 405 def _validateAndConvertWorker(self, asAllowNullAttributes, oDb ):406 dErrors = SchedGroupData._validateAndConvertWorker(self, asAllowNullAttributes, oDb );406 def _validateAndConvertWorker(self, asAllowNullAttributes, oDb, enmValidateFor = ModelDataBase.ksValidateFor_Other): 407 dErrors = SchedGroupData._validateAndConvertWorker(self, asAllowNullAttributes, oDb, enmValidateFor); 407 408 408 409 # … … 479 480 # Validate. 480 481 # 481 dDataErrors = oData.validateAndConvert(self._oDb );482 dDataErrors = oData.validateAndConvert(self._oDb, idPrimaryMustBeNullOrNot = True); 482 483 if len(dDataErrors) > 0: 483 raise TM ExceptionBase('Invalid data passed to addEntry: %s' % (dDataErrors,));484 raise TMInvalidData('Invalid data passed to addEntry: %s' % (dDataErrors,)); 484 485 if self.exists(oData.sName): 485 raise TM ExceptionBase('Scheduling group "%s" already exists.' % (oData.sName,));486 raise TMRowAlreadyExists('Scheduling group "%s" already exists.' % (oData.sName,)); 486 487 487 488 # … … 521 522 # Validate input and retrieve the old data. 522 523 # 523 dErrors = oData.validateAndConvert(self._oDb );524 dErrors = oData.validateAndConvert(self._oDb, oData.ksValidateFor_Edit); 524 525 if len(dErrors) > 0: 525 raise TM ExceptionBase('editEntry got invalid data: %s' % (dErrors,));526 raise TMInvalidData('editEntry got invalid data: %s' % (dErrors,)); 526 527 self._assertUnique(oData.sName, oData.idSchedGroup); 527 528 oOldData = SchedGroupDataEx().initFromDbWithId(self._oDb, oData.idSchedGroup); … … 572 573 # 573 574 if idSchedGroup == 1: 574 raise TM ExceptionBase('Cannot remove the default scheduling group (id 1).');575 raise TMRowInUse('Cannot remove the default scheduling group (id 1).'); 575 576 oData = SchedGroupDataEx().initFromDbWithId(self._oDb, idSchedGroup); 576 577 … … 583 584 # Complain about there being associated testboxes. 584 585 asTestBoxes = ['%s (#%d)' % (oTestBox.sName, oTestBox.idTestBox) for oTestBox in oData.aoTestBoxes]; 585 raise TM ExceptionBase('Scheduling group #%d is associated with one or more test boxes: %s'586 586 raise TMRowInUse('Scheduling group #%d is associated with one or more test boxes: %s' 587 % (idSchedGroup, ', '.join(asTestBoxes),)); 587 588 else: 588 589 # Reassign testboxes to scheduling group #1 (the default group). … … 595 596 oData = SchedGroupDataEx().initFromDbWithId(self._oDb, idSchedGroup); 596 597 if len(oData.aoTestBoxes) != 0: 597 raise TM ExceptionBase('More testboxes was added to the scheduling group as we were trying to delete it.');598 raise TMRowInUse('More testboxes was added to the scheduling group as we were trying to delete it.'); 598 599 599 600 # … … 859 860 , ( sName, idSchedGroupIgnore, ) ); 860 861 if self._oDb.getRowCount() > 0: 861 raise TM ExceptionBase('Scheduling group name (%s) is already in use.' % (sName,));862 raise TMRowInUse('Scheduling group name (%s) is already in use.' % (sName,)); 862 863 return True; 863 864 -
trunk/src/VBox/ValidationKit/testmanager/core/schedulerbase.py
r56802 r61220 725 725 726 726 sArgs = ' --gang-member-no %s --gang-members %s' % (oTestSet.iGangMemberNo, len(aoGangMembers)); 727 for i in range(len(aoGangMembers)):727 for i, _ in enumerate(aoGangMembers): 728 728 sArgs = ' --gang-ipv4-%s %s' % (i, aoGangMembers[i].ip); ## @todo IPv6 729 729 -
trunk/src/VBox/ValidationKit/testmanager/core/testbox.py
r56295 r61220 35 35 # Validation Kit imports. 36 36 from testmanager.core.base import ModelDataBase, ModelDataBaseTestCase, ModelLogicBase, TMExceptionBase, \ 37 ChangeLogEntry, AttributeChangeEntry;37 TMInvalidData, TMTooManyRows, TMRowNotFound, ChangeLogEntry, AttributeChangeEntry; 38 38 39 39 … … 171 171 172 172 if aoRow is None: 173 raise TM ExceptionBase('TestBox not found.');173 raise TMRowNotFound('TestBox not found.'); 174 174 175 175 self.idTestBox = aoRow[0]; … … 217 217 aoRow = oDb.fetchOne() 218 218 if aoRow is None: 219 raise TM ExceptionBase('idTestBox=%s not found (tsNow=%s sPeriodBack=%s)' % (idTestBox, tsNow, sPeriodBack,));219 raise TMRowNotFound('idTestBox=%s not found (tsNow=%s sPeriodBack=%s)' % (idTestBox, tsNow, sPeriodBack,)); 220 220 return self.initFromDbRow(aoRow); 221 221 … … 230 230 return self.initFromDbRow(oDb.fetchOne()); 231 231 232 def _validateAndConvertWorker(self, asAllowNullAttributes, oDb ):232 def _validateAndConvertWorker(self, asAllowNullAttributes, oDb, enmValidateFor = ModelDataBase.ksValidateFor_Other): 233 233 # Override to do extra ipLom checks. 234 dErrors = ModelDataBase._validateAndConvertWorker(self, asAllowNullAttributes, oDb );234 dErrors = ModelDataBase._validateAndConvertWorker(self, asAllowNullAttributes, oDb, enmValidateFor); 235 235 if self.ksParam_ipLom not in dErrors \ 236 236 and self.ksParam_enmLomKind not in dErrors \ … … 293 293 return None; 294 294 if self._oDb.getRowCount() != 1: 295 raise TM ExceptionBase('Database integrity error: %u hits' % (self._oDb.getRowCount(),));295 raise TMTooManyRows('Database integrity error: %u hits' % (self._oDb.getRowCount(),)); 296 296 oData = TestBoxData(); 297 297 oData.initFromDbRow(self._oDb.fetchOne()); … … 397 397 of the created testbox on success. Throws error on failure. 398 398 """ 399 dDataErrors = oData.validateAndConvert(self._oDb );399 dDataErrors = oData.validateAndConvert(self._oDb, oData.ksValidateFor_Add); 400 400 if len(dDataErrors) > 0: 401 raise TM ExceptionBase('Invalid data passed to create(): %s' % (dDataErrors,));401 raise TMInvalidData('Invalid data passed to create(): %s' % (dDataErrors,)); 402 402 403 403 self._oDb.execute('INSERT INTO TestBoxes (\n' … … 507 507 """ 508 508 509 dDataErrors = oData.validateAndConvert(self._oDb );509 dDataErrors = oData.validateAndConvert(self._oDb, oData.ksValidateFor_Edit); 510 510 if len(dDataErrors) > 0: 511 raise TM ExceptionBase('Invalid data passed to create(): %s' % (dDataErrors,));511 raise TMInvalidData('Invalid data passed to create(): %s' % (dDataErrors,)); 512 512 513 513 ## @todo check if the data changed. -
trunk/src/VBox/ValidationKit/testmanager/core/testboxcontroller.py
r57679 r61220 395 395 # Update the row in TestBoxes if something changed. 396 396 # 397 # pylint: disable=R0916 397 398 if self._sTestBoxAddr != oTestBox.ip \ 398 399 or sOs != oTestBox.sOs \ -
trunk/src/VBox/ValidationKit/testmanager/core/testboxstatus.py
r56295 r61220 34 34 35 35 # Validation Kit imports. 36 from testmanager.core.base import ModelDataBase, ModelDataBaseTestCase, ModelLogicBase, TM ExceptionBase;36 from testmanager.core.base import ModelDataBase, ModelDataBaseTestCase, ModelLogicBase, TMTooManyRows, TMRowNotFound; 37 37 from testmanager.core.testbox import TestBoxData; 38 38 … … 92 92 93 93 if aoRow is None: 94 raise TM ExceptionBase('TestBoxStatus not found.');94 raise TMRowNotFound('TestBoxStatus not found.'); 95 95 96 96 self.idTestBox = aoRow[0]; … … 175 175 if cRows != 1: 176 176 if cRows != 0: 177 raise TM ExceptionBase('tryFetchStatusForCommandReq got %s rows for idTestBox=%s' % (cRows, idTestBox));177 raise TMTooManyRows('tryFetchStatusForCommandReq got %s rows for idTestBox=%s' % (cRows, idTestBox)); 178 178 return (None, None); 179 179 aoRow = self._oDb.fetchOne(); -
trunk/src/VBox/ValidationKit/testmanager/core/testcase.py
r56295 r61220 38 38 from common import utils; 39 39 from testmanager.core.base import ModelDataBase, ModelDataBaseTestCase, ModelLogicBase, TMExceptionBase, \ 40 ChangeLogEntry, AttributeChangeEntry;40 TMInvalidData, TMRowNotFound, ChangeLogEntry, AttributeChangeEntry; 41 41 from testmanager.core.globalresource import GlobalResourceData; 42 42 from testmanager.core.useraccount import UserAccountLogic; … … 75 75 """ 76 76 if aoRow is None: 77 raise TM ExceptionBase('Test case not found.');77 raise TMRowNotFound('Test case not found.'); 78 78 79 79 self.idTestCase = aoRow[0]; … … 214 214 """ 215 215 if aoRow is None: 216 raise TM ExceptionBase('Test case not found.');216 raise TMRowNotFound('Test case not found.'); 217 217 218 218 self.idTestCase = aoRow[0]; … … 242 242 return True 243 243 244 def validateAndConvert(self, oDb = None ):244 def validateAndConvert(self, oDb = None, enmValidateFor = ModelDataBase.ksValidateFor_Other): 245 245 """ 246 246 Validates the input and converts valid fields to their right type. … … 259 259 260 260 _ = oDb; 261 _ = enmValidateFor; 261 262 return dErrors 262 263 … … 469 470 """ 470 471 if aoRow is None: 471 raise TM ExceptionBase('Test case not found.');472 raise TMRowNotFound('Test case not found.'); 472 473 473 474 self.idTestCase = aoRow[0]; … … 497 498 aoRow = oDb.fetchOne() 498 499 if aoRow is None: 499 raise TM ExceptionBase('idTestCase=%s not found (tsNow=%s sPeriodBack=%s)' % (idTestCase, tsNow, sPeriodBack,));500 raise TMRowNotFound('idTestCase=%s not found (tsNow=%s sPeriodBack=%s)' % (idTestCase, tsNow, sPeriodBack,)); 500 501 return self.initFromDbRow(aoRow); 501 502 … … 810 811 """ 811 812 TestCaseData.initFromDbWithGenId(self, oDb, idGenTestCase); 812 if tsNow ==None and not oDb.isTsInfinity(self.tsExpire):813 if tsNow is None and not oDb.isTsInfinity(self.tsExpire): 813 814 tsNow = self.tsEffective; 814 815 return self._initExtraMembersFromDb(oDb, tsNow); … … 890 891 oVar = copy.copy(self.aoTestCaseArgs[iVar]); 891 892 oVar.idTestCase = self.idTestCase; 892 dCurErrors = oVar.validateAndConvert(oDb );893 dCurErrors = oVar.validateAndConvert(oDb, ModelDataBase.ksValidateFor_Other); 893 894 if len(dCurErrors) == 0: 894 895 pass; ## @todo figure out the ID? … … 915 916 return (aoNewValues, None if len(asErrors) == 0 else ' <br>'.join(asErrors)); 916 917 917 def _validateAndConvertWorker(self, asAllowNullAttributes, oDb ):918 dErrors = TestCaseData._validateAndConvertWorker(self, asAllowNullAttributes, oDb );918 def _validateAndConvertWorker(self, asAllowNullAttributes, oDb, enmValidateFor = ModelDataBase.ksValidateFor_Other): 919 dErrors = TestCaseData._validateAndConvertWorker(self, asAllowNullAttributes, oDb, enmValidateFor); 919 920 920 921 # Validate dependencies a wee bit for paranoid reasons. The scheduler … … 1127 1128 # 1128 1129 assert isinstance(oData, TestCaseDataEx); 1129 dErrors = oData.validateAndConvert(self._oDb );1130 dErrors = oData.validateAndConvert(self._oDb, oData.ksValidateFor_Add); 1130 1131 if len(dErrors) > 0: 1131 raise TM ExceptionBase('Invalid input data: %s' % (dErrors,));1132 raise TMInvalidData('Invalid input data: %s' % (dErrors,)); 1132 1133 1133 1134 # … … 1171 1172 # 1172 1173 assert isinstance(oData, TestCaseDataEx); 1173 dErrors = oData.validateAndConvert(self._oDb );1174 dErrors = oData.validateAndConvert(self._oDb, oData.ksValidateFor_Edit); 1174 1175 if len(dErrors) > 0: 1175 raise TM ExceptionBase('Invalid input data: %s' % (dErrors,));1176 raise TMInvalidData('Invalid input data: %s' % (dErrors,)); 1176 1177 1177 1178 # -
trunk/src/VBox/ValidationKit/testmanager/core/testcaseargs.py
r56295 r61220 36 36 # Validation Kit imports. 37 37 from common import utils; 38 from testmanager.core.base import ModelDataBase, ModelDataBaseTestCase, ModelLogicBase, TMExceptionBase; 38 from testmanager.core.base import ModelDataBase, ModelDataBaseTestCase, ModelLogicBase, TMExceptionBase, \ 39 TMRowNotFound; 39 40 from testmanager.core.testcase import TestCaseData, TestCaseDependencyLogic, TestCaseGlobalRsrcDepLogic; 40 41 … … 92 93 """ 93 94 if aoRow is None: 94 raise TM ExceptionBase('TestBoxStatus not found.');95 raise TMRowNotFound('TestBoxStatus not found.'); 95 96 96 97 self.idTestCase = aoRow[0]; … … 118 119 aoRow = oDb.fetchOne() 119 120 if aoRow is None: 120 raise TM ExceptionBase('idTestCaseArgs=%s not found (tsNow=%s sPeriodBack=%s)'121 121 raise TMRowNotFound('idTestCaseArgs=%s not found (tsNow=%s sPeriodBack=%s)' 122 % (idTestCaseArgs, tsNow, sPeriodBack,)); 122 123 return self.initFromDbRow(aoRow); 123 124 … … 188 189 def initFromDbWithId(self, oDb, idTestCaseArgs, tsNow = None, sPeriodBack = None): 189 190 _ = oDb; _ = idTestCaseArgs; _ = tsNow; _ = sPeriodBack; 190 raise Exception('Not supported.');191 raise TMExceptionBase('Not supported.'); 191 192 192 193 def initFromDbWithGenId(self, oDb, idGenTestCaseArgs): 193 194 _ = oDb; _ = idGenTestCaseArgs; 194 raise Exception('Use initFromDbWithGenIdEx...');195 raise TMExceptionBase('Use initFromDbWithGenIdEx...'); 195 196 196 197 def initFromDbWithGenIdEx(self, oDb, idGenTestCaseArgs, tsConfigEff = None, tsRsrcEff = None): -
trunk/src/VBox/ValidationKit/testmanager/core/testgroup.py
r56295 r61220 34 34 35 35 # Validation Kit imports. 36 from testmanager.core.base import ModelDataBase, ModelDataBaseTestCase, ModelLogicBase, TMExceptionBase 36 from testmanager.core.base import ModelDataBase, ModelDataBaseTestCase, ModelLogicBase, TMRowInUse, \ 37 TMTooManyRows, TMInvalidData, TMRowNotFound, TMRowAlreadyExists; 37 38 from testmanager.core.testcase import TestCaseData, TestCaseDataEx; 38 39 … … 75 76 """ 76 77 if aoRow is None: 77 raise TM ExceptionBase('Test group member not found.')78 raise TMRowNotFound('Test group member not found.') 78 79 79 80 self.idTestGroup = aoRow[0]; … … 144 145 return asAttributes; 145 146 146 def _validateAndConvertWorker(self, asAllowNullAttributes, oDb ):147 dErrors = TestGroupMemberData._validateAndConvertWorker(self, asAllowNullAttributes, oDb );147 def _validateAndConvertWorker(self, asAllowNullAttributes, oDb, enmValidateFor = ModelDataBase.ksValidateFor_Other): 148 dErrors = TestGroupMemberData._validateAndConvertWorker(self, asAllowNullAttributes, oDb, enmValidateFor); 148 149 if self.ksParam_idTestCase not in dErrors: 149 150 self.oTestCase = TestCaseDataEx() … … 230 231 """ 231 232 if aoRow is None: 232 raise TM ExceptionBase('Test group not found.')233 raise TMRowNotFound('Test group not found.') 233 234 234 235 self.idTestGroup = aoRow[0] … … 251 252 aoRow = oDb.fetchOne() 252 253 if aoRow is None: 253 raise TM ExceptionBase('idTestGroup=%s not found (tsNow=%s sPeriodBack=%s)' % (idTestGroup, tsNow, sPeriodBack,));254 raise TMRowNotFound('idTestGroup=%s not found (tsNow=%s sPeriodBack=%s)' % (idTestGroup, tsNow, sPeriodBack,)); 254 255 return self.initFromDbRow(aoRow); 255 256 … … 355 356 aoNewMembers.append(oNewMember); 356 357 357 dErrors = oNewMember.validateAndConvert(oDb );358 dErrors = oNewMember.validateAndConvert(oDb, ModelDataBase.ksValidateFor_Other); 358 359 if len(dErrors) > 0: 359 360 asErrors.append(str(dErrors)); 360 361 361 362 if len(asErrors) == 0: 362 for i in range(len(aoNewMembers)):363 for i, _ in enumerate(aoNewMembers): 363 364 idTestCase = aoNewMembers[i]; 364 365 for j in range(i + 1, len(aoNewMembers)): … … 416 417 # 417 418 assert isinstance(oData, TestGroupDataEx); 418 dErrors = oData.validateAndConvert(self._oDb );419 dErrors = oData.validateAndConvert(self._oDb, oData.ksValidateFor_Add); 419 420 if len(dErrors) > 0: 420 raise TM ExceptionBase('addEntry invalid input: %s' % (dErrors,));421 raise TMInvalidData('addEntry invalid input: %s' % (dErrors,)); 421 422 self._assertUniq(oData, None); 422 423 … … 449 450 # 450 451 assert isinstance(oData, TestGroupDataEx); 451 dErrors = oData.validateAndConvert(self._oDb );452 dErrors = oData.validateAndConvert(self._oDb, oData.ksValidateFor_Edit); 452 453 if len(dErrors) > 0: 453 raise TM ExceptionBase('editEntry invalid input: %s' % (dErrors,));454 raise TMInvalidData('editEntry invalid input: %s' % (dErrors,)); 454 455 self._assertUniq(oData, oData.idTestGroup); 455 456 … … 481 482 oNewMember.idTestGroup = oData.idTestGroup; 482 483 if oNewMember.idTestCase in dNew: 483 raise TM ExceptionBase('Duplicate test group member: idTestCase=%d (%s / %s)'484 % (oNewMember.idTestCase, oNewMember, dNew[oNewMember.idTestCase],));484 raise TMRowAlreadyExists('Duplicate test group member: idTestCase=%d (%s / %s)' 485 % (oNewMember.idTestCase, oNewMember, dNew[oNewMember.idTestCase],)); 485 486 dNew[oNewMember.idTestCase] = oNewMember; 486 487 … … 525 526 if len(aoGroups) > 0: 526 527 asGroups = ['%s (#%d)' % (sName, idSchedGroup) for idSchedGroup, sName in aoGroups]; 527 raise TM ExceptionBase('Test group #%d is member of one oremore scheduling groups: %s'528 528 raise TMRowInUse('Test group #%d is member of one or more scheduling groups: %s' 529 % (idTestGroup, ', '.join(asGroups),)); 529 530 else: 530 531 self._oDb.execute('UPDATE SchedGroupMembers\n' … … 645 646 aRows = self._oDb.fetchAll() 646 647 if len(aRows) not in (0, 1): 647 raise TM ExceptionBase('Found more than one test groups with the same credentials. Database structure is corrupted.')648 raise TMTooManyRows('Found more than one test groups with the same credentials. Database structure is corrupted.') 648 649 try: 649 650 return TestGroupData().initFromDbRow(aRows[0]) … … 664 665 , ( oData.sName, )) 665 666 if self._oDb.getRowCount() > 0: 666 raise TM ExceptionBase('A Test group with name "%s" already exist.' % (oData.sName,));667 raise TMRowAlreadyExists('A Test group with name "%s" already exist.' % (oData.sName,)); 667 668 return True; 668 669 -
trunk/src/VBox/ValidationKit/testmanager/core/testresults.py
r61218 r61220 37 37 from common import constants; 38 38 from testmanager import config; 39 from testmanager.core.base import ModelDataBase, ModelLogicBase, ModelDataBaseTestCase, TMExceptionBase, TMTooManyRows; 39 from testmanager.core.base import ModelDataBase, ModelLogicBase, ModelDataBaseTestCase, TMExceptionBase, \ 40 TMTooManyRows, TMInvalidData, TMRowNotFound, TMRowAlreadyExists; 40 41 from testmanager.core.testgroup import TestGroupData; 41 42 from testmanager.core.build import BuildDataEx; … … 112 113 """ 113 114 if aoRow is None: 114 raise TM ExceptionBase('Test result record not found.')115 raise TMRowNotFound('Test result record not found.') 115 116 116 117 self.idTestResult = aoRow[0] … … 205 206 """ 206 207 if aoRow is None: 207 raise TM ExceptionBase('Test result value record not found.')208 raise TMRowNotFound('Test result value record not found.') 208 209 209 210 self.idTestResultValue = aoRow[0]; … … 271 272 """ 272 273 if aoRow is None: 273 raise TM ExceptionBase('Test result value record not found.')274 raise TMRowNotFound('Test result value record not found.') 274 275 275 276 self.idTestResultMsg = aoRow[0]; … … 333 334 """ 334 335 if aoRow is None: 335 raise TM ExceptionBase('Test result file record not found.')336 raise TMRowNotFound('Test result file record not found.') 336 337 337 338 self.idTestResultFile = aoRow[0]; … … 418 419 419 420 ksIdAttr = 'idTestResult'; 421 kfIdAttrIsForForeign = True; # Modifies the 'add' validation. 420 422 421 423 ksParam_idTestResult = 'TestResultFailure_idTestResult'; … … 443 445 """ 444 446 if aoRow is None: 445 raise TM ExceptionBase('Test result file record not found.')447 raise TMRowNotFound('Test result file record not found.') 446 448 447 449 self.idTestResult = aoRow[0]; … … 464 466 aoRow = oDb.fetchOne() 465 467 if aoRow is None: 466 raise TM ExceptionBase('idTestResult=%s not found (tsNow=%s, sPeriodBack=%s)' % (idTestResult, tsNow, sPeriodBack));468 raise TMRowNotFound('idTestResult=%s not found (tsNow=%s, sPeriodBack=%s)' % (idTestResult, tsNow, sPeriodBack)); 467 469 return self.initFromDbRow(aoRow); 468 470 … … 552 554 """ 553 555 if aoRow is None: 554 raise TM ExceptionBase('Test result record not found.')556 raise TMRowNotFound('Test result record not found.') 555 557 556 558 self.idTestSet = aoRow[0]; … … 1115 1117 aRows = self._oDb.fetchAll() 1116 1118 if len(aRows) not in (0, 1): 1117 raise TM ExceptionBase('Found more than one test result with the same credentials. Database structure is corrupted.')1119 raise TMTooManyRows('Found more than one test result with the same credentials. Database structure is corrupted.') 1118 1120 try: 1119 1121 return TestResultData().initFromDbRow(aRows[0]) … … 1165 1167 aaoRows = self._oDb.fetchAll(); 1166 1168 if len(aaoRows) == 0: 1167 raise TM ExceptionBase('No test results for idTestSet=%d.' % (idTestSet,));1169 raise TMRowNotFound('No test results for idTestSet=%d.' % (idTestSet,)); 1168 1170 1169 1171 # Set up the root node first. … … 1941 1943 """ 1942 1944 1945 # 1946 # Validate inputs and read in the old(/current) data. 1947 # 1948 assert isinstance(oData, TestResultFailureData); 1949 dErrors = oData.validateAndConvert(self._oDb, oData.ksValidateFor_AddForeignId); 1950 if len(dErrors) > 0: 1951 raise TMInvalidData('editEntry invalid input: %s' % (dErrors,)); 1952 1943 1953 # Check if it exist first (we're adding, not editing, collisions not allowed). 1944 1954 oOldData = self.getById(oData.idTestResult); 1945 1955 if oOldData is not None: 1946 raise TM ExceptionBase('TestResult %d already have a failure reason associated with it:'1947 '%s\n'1948 'Perhaps someone else beat you to it? Or did you try resubmit?'1949 % (oData.idTestResult, oOldData));1956 raise TMRowAlreadyExists('TestResult %d already have a failure reason associated with it:' 1957 '%s\n' 1958 'Perhaps someone else beat you to it? Or did you try resubmit?' 1959 % (oData.idTestResult, oOldData)); 1950 1960 1951 1961 # … … 1965 1975 # 1966 1976 assert isinstance(oData, TestResultFailureData); 1967 dErrors = oData.validateAndConvert(self._oDb );1977 dErrors = oData.validateAndConvert(self._oDb, oData.ksValidateFor_Edit); 1968 1978 if len(dErrors) > 0: 1969 raise TM ExceptionBase('editEntry invalid input: %s' % (dErrors,));1979 raise TMInvalidData('editEntry invalid input: %s' % (dErrors,)); 1970 1980 1971 1981 oOldData = self.getById(oData.idTestResult) … … 1993 2003 self._readdEntry(uidAuthor, oData, tsCurMinusOne); 1994 2004 self._historizeEntry(idTestResult); 1995 self._oDb.execute('UPDATE TestResultFail lures\n'2005 self._oDb.execute('UPDATE TestResultFailures\n' 1996 2006 'SET tsExpire = CURRENT_TIMESTAMP\n' 1997 2007 'WHERE idTestResult = %s\n' -
trunk/src/VBox/ValidationKit/testmanager/core/testset.py
r56295 r61220 38 38 from common import utils; 39 39 from testmanager import config; 40 from testmanager.core.base import ModelDataBase, ModelDataBaseTestCase, ModelLogicBase, TMExceptionBase; 40 from testmanager.core.base import ModelDataBase, ModelDataBaseTestCase, ModelLogicBase, \ 41 TMExceptionBase, TMTooManyRows, TMRowNotFound; 41 42 from testmanager.core.testbox import TestBoxData; 42 43 from testmanager.core.testresults import TestResultFileDataEx; … … 136 137 137 138 if aoRow is None: 138 raise TM ExceptionBase('TestSet not found.');139 raise TMRowNotFound('TestSet not found.'); 139 140 140 141 self.idTestSet = aoRow[0]; … … 170 171 aoRow = oDb.fetchOne() 171 172 if aoRow is None: 172 raise TM ExceptionBase('idTestSet=%s not found' % (idTestSet,));173 raise TMRowNotFound('idTestSet=%s not found' % (idTestSet,)); 173 174 return self.initFromDbRow(aoRow); 174 175 … … 605 606 aRows = self._oDb.fetchAll() 606 607 if len(aRows) not in (0, 1): 607 raise TM ExceptionBase('Found more than one test sets with the same credentials. Database structure is corrupted.')608 raise TMTooManyRows('Found more than one test sets with the same credentials. Database structure is corrupted.') 608 609 try: 609 610 return TestSetData().initFromDbRow(aRows[0]) -
trunk/src/VBox/ValidationKit/testmanager/core/useraccount.py
r61217 r61220 35 35 # Validation Kit imports. 36 36 from testmanager import config; 37 from testmanager.core.base import ModelDataBase, ModelLogicBase, ModelDataBaseTestCase, TM ExceptionBase;37 from testmanager.core.base import ModelDataBase, ModelLogicBase, ModelDataBaseTestCase, TMTooManyRows, TMRowNotFound; 38 38 39 39 … … 75 75 """ 76 76 if aoRow is None: 77 raise TM ExceptionBase('User not found.');77 raise TMRowNotFound('User not found.'); 78 78 79 79 self.uid = aoRow[0]; … … 98 98 aoRow = oDb.fetchOne() 99 99 if aoRow is None: 100 raise TM ExceptionBase('uid=%s not found (tsNow=%s sPeriodBack=%s)' % (uid, tsNow, sPeriodBack,));100 raise TMRowNotFound('uid=%s not found (tsNow=%s sPeriodBack=%s)' % (uid, tsNow, sPeriodBack,)); 101 101 return self.initFromDbRow(aoRow); 102 102 … … 190 190 aRows = self._oDb.fetchAll() 191 191 if len(aRows) not in (0, 1): 192 raise TM ExceptionBase('Found more than one user account with the same credentials. Database structure is corrupted.')192 raise TMTooManyRows('Found more than one user account with the same credentials. Database structure is corrupted.') 193 193 194 194 try: -
trunk/src/VBox/ValidationKit/testmanager/core/vcsrevisions.py
r61149 r61220 159 159 160 160 # Check VcsRevisionData before do anything 161 dDataErrors = oData.validateAndConvert(self._oDb );161 dDataErrors = oData.validateAndConvert(self._oDb, oData.ksValidateFor_Add); 162 162 if len(dDataErrors) > 0: 163 163 raise TMExceptionBase('Invalid data passed to addVcsRevision(): %s' % (dDataErrors,)); -
trunk/src/VBox/ValidationKit/testmanager/core/webservergluebase.py
r56295 r61220 499 499 fnWrite('<h2>%s</h2>\n' 500 500 '<table border="1"><tr><th>index</th><th>value</th></tr>\n' % (sName,)); 501 for i in range(len(aoStuff)):501 for i, _ in enumerate(aoStuff): 502 502 fnWrite(' <tr><td>' + str(i) + '</td><td>' + webutils.escapeElem(str(aoStuff[i])) + '</td></tr>\n'); 503 503 fnWrite('</table>\n'); 504 504 else: 505 for i in range(len(sName) - 1):506 fnWrite('%s ' % ( sName[i],));505 for ch in sName[:-1]: 506 fnWrite('%s ' % (ch,)); 507 507 fnWrite('%s\n\n' % (sName[-1],)); 508 508 509 509 fnWrite('Index Value\n'); 510 510 fnWrite('------------------------------------------------------------------------\n'); 511 for i in range(len(aoStuff)):512 fnWrite('%5u %s\n' % (i, str( aoStuff[i])));511 for i, oStuff in enumerate(aoStuff): 512 fnWrite('%5u %s\n' % (i, str(oStuff))); 513 513 fnWrite('\n'); 514 514 -
trunk/src/VBox/ValidationKit/testmanager/webui/wuiadmin.py
r61217 r61220 130 130 ksActionBuildBlacklistEditPost = 'BuildBlacklistEditPost'; 131 131 132 ksActionFailureCategoryList = 'FailureCategoryList' 133 ksActionFailureCategoryShowAdd = 'FailureCategoryShowAdd' 134 ksActionFailureCategoryShowEdit = 'FailureCategoryShowEdit' 135 ksActionFailureCategoryAdd = 'FailureCategoryAdd' 136 ksActionFailureCategoryEdit = 'FailureCategoryEdit' 137 ksActionFailureCategoryDel = 'FailureCategoryDel' 132 ksActionFailureCategoryList = 'FailureCategoryList'; 133 ksActionFailureCategoryAdd = 'FailureCategoryAdd'; 134 ksActionFailureCategoryAddPost = 'FailureCategoryAddPost'; 135 ksActionFailureCategoryDetails = 'FailureCategoryDetails'; 136 ksActionFailureCategoryDoRemove = 'FailureCategoryDoRemove'; 137 ksActionFailureCategoryEdit = 'FailureCategoryEdit'; 138 ksActionFailureCategoryEditPost = 'FailureCategoryEditPost'; 138 139 139 140 ksActionFailureReasonList = 'FailureReasonList' 141 ksActionFailureReasonAdd = 'FailureReasonAdd' 142 ksActionFailureReasonAddPost = 'FailureReasonAddPost' 140 143 ksActionFailureReasonDetails = 'FailureReasonDetails' 141 ksActionFailureReasonShowAdd = 'FailureReasonShowAdd' 142 ksActionFailureReasonShowEdit = 'FailureReasonShowEdit' 143 ksActionFailureReasonAdd = 'FailureReasonAdd' 144 ksActionFailureReasonDoRemove = 'FailureReasonDoRemove' 144 145 ksActionFailureReasonEdit = 'FailureReasonEdit' 145 ksActionFailureReason Del = 'FailureReasonDel'146 ksActionFailureReasonEditPost = 'FailureReasonEditPost' 146 147 147 148 ksActionBuildSrcList = 'BuildSrcList' … … 329 330 # Failure Category actions 330 331 # 331 d[self.ksActionFailureCategoryList] = lambda: self._actionGenericListing( 332 FailureCategoryLogic, 333 WuiFailureCategoryList) 334 335 d[self.ksActionFailureCategoryShowAdd] = lambda: self._actionGenericFormAdd( 336 FailureCategoryData, 337 WuiFailureCategory) 338 339 d[self.ksActionFailureCategoryShowEdit] = lambda: self._actionGenericFormEditL( 340 FailureCategoryLogic, 341 FailureCategoryData.ksParam_idFailureCategory, 342 WuiFailureCategory) 343 344 d[self.ksActionFailureCategoryAdd] = lambda: self._actionGenericFormAddPost( 345 FailureCategoryData, 346 FailureCategoryLogic, 347 WuiFailureCategory, 348 self.ksActionFailureCategoryList) 349 350 d[self.ksActionFailureCategoryEdit] = lambda: self._actionGenericFormEditPost( 351 FailureCategoryData, 352 FailureCategoryLogic, 353 WuiFailureCategory, 354 self.ksActionFailureCategoryList) 355 356 d[self.ksActionFailureCategoryDel] = lambda: self._actionGenericDoDelOld( 357 FailureCategoryLogic, 358 FailureCategoryData.ksParam_idFailureCategory, 359 self.ksActionFailureCategoryList) 332 d[self.ksActionFailureCategoryList] = \ 333 lambda: self._actionGenericListing(FailureCategoryLogic, WuiFailureCategoryList); 334 d[self.ksActionFailureCategoryAdd] = \ 335 lambda: self._actionGenericFormAdd(FailureCategoryData, WuiFailureCategory); 336 d[self.ksActionFailureCategoryAddPost] = \ 337 lambda: self._actionGenericFormAddPost(FailureCategoryData, FailureCategoryLogic, WuiFailureCategory, 338 self.ksActionFailureCategoryList) 339 d[self.ksActionFailureCategoryDetails] = \ 340 lambda: self._actionGenericFormDetails(FailureCategoryData, FailureCategoryLogic, WuiFailureCategory); 341 342 d[self.ksActionFailureCategoryDoRemove] = \ 343 lambda: self._actionGenericDoRemove(FailureCategoryLogic, FailureCategoryData.ksParam_idFailureCategory, 344 self.ksActionFailureCategoryList); 345 d[self.ksActionFailureCategoryEdit] = \ 346 lambda: self._actionGenericFormEdit(FailureCategoryData, WuiFailureCategory, 347 FailureCategoryData.ksParam_idFailureCategory); 348 d[self.ksActionFailureCategoryEditPost] = \ 349 lambda: self._actionGenericFormEditPost(FailureCategoryData, FailureCategoryLogic, WuiFailureCategory, 350 self.ksActionFailureCategoryList); 360 351 361 352 # 362 353 # Failure Reason actions 363 354 # 364 d[self.ksActionFailureReasonList] = lambda: self._actionGenericListing( 365 FailureReasonLogic, 366 WuiAdminFailureReasonList) 367 368 d[self.ksActionFailureReasonDetails] = lambda: self._actionGenericFormDetails(FailureReasonData, 369 FailureReasonLogic, 370 WuiAdminFailureReason, 371 'idFailureReason'); 372 d[self.ksActionFailureReasonShowEdit] = lambda: self._actionGenericFormEditL( 373 FailureReasonLogic, 374 FailureReasonData.ksParam_idFailureReason, 375 WuiAdminFailureReason) 376 377 d[self.ksActionFailureReasonAdd] = lambda: self._actionGenericFormAddPost( 378 FailureReasonData, 379 FailureReasonLogic, 380 WuiAdminFailureReason, 381 self.ksActionFailureReasonList) 382 383 d[self.ksActionFailureReasonEdit] = lambda: self._actionGenericFormEditPost( 384 FailureReasonData, 385 FailureReasonLogic, 386 WuiAdminFailureReason, 387 self.ksActionFailureReasonList) 388 389 d[self.ksActionFailureReasonDel] = lambda: self._actionGenericDoDelOld(FailureReasonLogic, 390 FailureReasonData.ksParam_idFailureReason, 391 self.ksActionFailureReasonList) 355 d[self.ksActionFailureReasonList] = \ 356 lambda: self._actionGenericListing(FailureReasonLogic, WuiAdminFailureReasonList) 357 358 d[self.ksActionFailureReasonAdd] = \ 359 lambda: self._actionGenericFormAdd(FailureReasonData, WuiAdminFailureReason); 360 d[self.ksActionFailureReasonAddPost] = \ 361 lambda: self._actionGenericFormAddPost(FailureReasonData, FailureReasonLogic, WuiAdminFailureReason, 362 self.ksActionFailureReasonList); 363 d[self.ksActionFailureReasonDetails] = \ 364 lambda: self._actionGenericFormDetails(FailureReasonData, FailureReasonLogic, WuiAdminFailureReason); 365 d[self.ksActionFailureReasonDoRemove] = \ 366 lambda: self._actionGenericDoRemove(FailureReasonLogic, FailureReasonData.ksParam_idFailureReason, 367 self.ksActionFailureReasonList); 368 d[self.ksActionFailureReasonEdit] = \ 369 lambda: self._actionGenericFormEdit(FailureReasonData, WuiAdminFailureReason); 370 371 d[self.ksActionFailureReasonEditPost] = \ 372 lambda: self._actionGenericFormEditPost(FailureReasonData, FailureReasonLogic, WuiAdminFailureReason,\ 373 self.ksActionFailureReasonList) 392 374 393 375 # … … 466 448 [ 'Failure Categories', self._sActionUrlBase + self.ksActionFailureCategoryList ], 467 449 [ 'Failure Reasons', self._sActionUrlBase + self.ksActionFailureReasonList ], 468 [ 'New Failure Category', self._sActionUrlBase + self.ksActionFailureCategory ShowAdd ],469 [ 'New Failure Reason', self._sActionUrlBase + self.ksActionFailureReason ShowAdd ],450 [ 'New Failure Category', self._sActionUrlBase + self.ksActionFailureCategoryAdd ], 451 [ 'New Failure Reason', self._sActionUrlBase + self.ksActionFailureReasonAdd ], 470 452 ] 471 453 ], -
trunk/src/VBox/ValidationKit/testmanager/webui/wuiadminbuildblacklist.py
r56295 r61220 73 73 from testmanager.webui.wuiadmin import WuiAdmin 74 74 raise WuiException('Please <a href="%s?%s=%s">add</a> some Failure Reasons first.' 75 % (WuiAdmin.ksScriptName, WuiAdmin.ksParamAction, WuiAdmin.ksActionFailureReason ShowAdd));75 % (WuiAdmin.ksScriptName, WuiAdmin.ksParamAction, WuiAdmin.ksActionFailureReasonAdd)); 76 76 77 77 asTypes = self.getListOfItems(self.asTypes, oData.asTypes) -
trunk/src/VBox/ValidationKit/testmanager/webui/wuiadminfailurereason.py
r56295 r61220 48 48 """ 49 49 50 sTitle = 'Failure Reason'; 50 51 if sMode == WuiFormContentBase.ksMode_Add: 51 sTitle = 'Add Failure Reason' 52 sSubmitAction = oDisp.ksActionFailureReasonAdd 52 sTitle = 'Add' + sTitle; 53 53 elif sMode == WuiFormContentBase.ksMode_Edit: 54 sTitle = 'Edit Failure Reason' 55 sSubmitAction = oDisp.ksActionFailureReasonEdit 54 sTitle = 'Edit' + sTitle; 56 55 else: 57 raise WuiException('Unknown parameter')56 assert sMode == WuiFormContentBase.ksMode_Show; 58 57 59 WuiFormContentBase.__init__(self, oFailureReasonData, sMode, 'FailureReason', oDisp, sTitle, 60 sSubmitAction = sSubmitAction, fEditable = False); ## @todo non-standard action names. 58 WuiFormContentBase.__init__(self, oFailureReasonData, sMode, 'FailureReason', oDisp, sTitle); 61 59 62 60 def _populateForm(self, oForm, oData): … … 69 67 from testmanager.webui.wuiadmin import WuiAdmin 70 68 sExceptionMsg = 'Please <a href="%s?%s=%s">add</a> Failure Category first.' % \ 71 (WuiAdmin.ksScriptName, WuiAdmin.ksParamAction, WuiAdmin.ksActionFailureCategory ShowAdd)69 (WuiAdmin.ksScriptName, WuiAdmin.ksParamAction, WuiAdmin.ksActionFailureCategoryAdd) 72 70 73 71 raise WuiException(sExceptionMsg) … … 90 88 91 89 return True 90 92 91 93 92 class WuiAdminFailureReasonList(WuiListContentBase): … … 117 116 oEntry.iTicket, 118 117 oEntry.asUrls, 119 [ WuiTmLink('Modify', WuiAdmin.ksScriptName, 120 { WuiAdmin.ksParamAction: WuiAdmin.ksActionFailureReasonShowEdit, 118 [ WuiTmLink('Details', WuiAdmin.ksScriptName, 119 { WuiAdmin.ksParamAction: WuiAdmin.ksActionFailureReasonDetails, 120 FailureReasonData.ksParam_idFailureReason: oEntry.idFailureReason } ), 121 WuiTmLink('Modify', WuiAdmin.ksScriptName, 122 { WuiAdmin.ksParamAction: WuiAdmin.ksActionFailureReasonEdit, 121 123 FailureReasonData.ksParam_idFailureReason: oEntry.idFailureReason } ), 122 124 WuiTmLink('Remove', WuiAdmin.ksScriptName, 123 { WuiAdmin.ksParamAction: WuiAdmin.ksActionFailureReasonD el,125 { WuiAdmin.ksParamAction: WuiAdmin.ksActionFailureReasonDoRemove, 124 126 FailureReasonData.ksParam_idFailureReason: oEntry.idFailureReason }, 125 127 sConfirm = 'Are you sure you want to remove failure reason #%d?' % (oEntry.idFailureReason,)), -
trunk/src/VBox/ValidationKit/testmanager/webui/wuiadminsystemlog.py
r56295 r61220 52 52 oEntry = self._aoEntries[iEntry]; 53 53 54 oAction = '';55 54 if oEntry.sEvent == SystemLogData.ksEvent_TestBoxUnknown \ 56 55 and oEntry.sLogText.find('addr=') >= 0 \ … … 69 68 { WuiAdmin.ksParamAction: WuiAdmin.ksActionUserAdd, 70 69 UserAccountData.ksParam_sLoginName: sUserName }); 70 else: 71 oAction = ''; # pylint: disable=R0204 71 72 72 73 return [oEntry.tsCreated, oEntry.sEvent, oEntry.sLogText, oAction]; -
trunk/src/VBox/ValidationKit/testmanager/webui/wuiadmintestbox.py
r56295 r61220 34 34 35 35 # Validation Kit imports. 36 from common import utils; 36 37 from testmanager.webui.wuicontentbase import WuiListContentWithActionBase, WuiFormContentBase, WuiLinkBase, WuiSvnLink, \ 37 38 WuiTmLink, WuiSpanText, WuiRawHtml; … … 40 41 from testmanager.core.testbox import TestBoxData; 41 42 from testmanager.core.testset import TestSetData; 42 from common import utils;43 43 from testmanager.core.db import isDbTimestampInfinity; 44 44 … … 215 215 else: 216 216 from testmanager.webui.wuimain import WuiMain; 217 oState = WuiTmLink(oEntry.oStatus.enmState, WuiMain.ksScriptName, 217 oState = WuiTmLink(oEntry.oStatus.enmState, WuiMain.ksScriptName, # pylint: disable=R0204 218 218 { WuiMain.ksParamAction: WuiMain.ksActionTestResultDetails, 219 219 TestSetData.ksParam_idTestSet: oEntry.oStatus.idTestSet, }, -
trunk/src/VBox/ValidationKit/testmanager/webui/wuibase.py
r61217 r61220 36 36 from common import webutils, utils; 37 37 from testmanager import config; 38 from testmanager.core.base import ModelDataBase, TMExceptionBase;38 from testmanager.core.base import ModelDataBase, ModelLogicBase, TMExceptionBase; 39 39 from testmanager.core.db import TMDatabaseConnection; 40 40 from testmanager.core.systemlog import SystemLogLogic, SystemLogData; … … 733 733 oFormType is a WuiFormContentBase child class. 734 734 """ 735 assert issubclass(oDataType, ModelDataBase); 736 from testmanager.webui.wuicontentbase import WuiFormContentBase; 737 assert issubclass(oFormType, WuiFormContentBase); 738 735 739 oData = oDataType().initFromParams(oDisp = self, fStrict = False); 736 740 sRedirectTo = self.getRedirectToParameter(sRedirectTo); … … 742 746 return True 743 747 744 def _actionGenericFormDetails(self, oDataType, oLogicType, oFormType, sIdAttr , sGenIdAttr = None): # pylint: disable=R0914748 def _actionGenericFormDetails(self, oDataType, oLogicType, oFormType, sIdAttr = None, sGenIdAttr = None): # pylint: disable=R0914 745 749 """ 746 750 Generic handler for showing a details form/page. … … 751 755 sIdParamName is the name of the ID parameter (not idGen!). 752 756 """ 757 # Input. 758 assert issubclass(oDataType, ModelDataBase); 759 assert issubclass(oLogicType, ModelLogicBase); 760 from testmanager.webui.wuicontentbase import WuiFormContentBase; 761 assert issubclass(oFormType, WuiFormContentBase); 762 763 if sIdAttr is None: 764 sIdAttr = oDataType.ksIdAttr; 765 if sGenIdAttr is None: 766 sGenIdAttr = getattr(oDataType, 'ksGenIdAttr', None); 767 753 768 # Parameters. 754 769 idGenObject = -1; … … 784 799 785 800 786 def _actionGenericFormEdit(self, oDataType, oFormType, sIdParamName , sRedirectTo = None):801 def _actionGenericFormEdit(self, oDataType, oFormType, sIdParamName = None, sRedirectTo = None): 787 802 """ 788 803 Generic edit something form display request handler. … … 792 807 sIdParamName is the name of the ID parameter (not idGen!). 793 808 """ 809 assert issubclass(oDataType, ModelDataBase); 810 from testmanager.webui.wuicontentbase import WuiFormContentBase; 811 assert issubclass(oFormType, WuiFormContentBase); 812 813 if sIdParamName is None: 814 sIdParamName = getattr(oDataType, 'ksParam_' + oDataType.ksIdAttr); 815 assert len(sIdParamName) > 1; 794 816 795 817 tsNow = self.getEffectiveDateParam(); … … 839 861 sGenIdParamName is the name of the generation ID parameter, None if not applicable. 840 862 """ 863 # Input. 864 assert issubclass(oDataType, ModelDataBase); 865 from testmanager.webui.wuicontentbase import WuiFormContentBase; 866 assert issubclass(oFormType, WuiFormContentBase); 867 841 868 # Parameters. 842 869 idGenObject = -1; … … 876 903 fnLogicAction is a method taking a oDataType instance and uidAuthor as arguments. 877 904 """ 905 assert issubclass(oDataType, ModelDataBase); 906 from testmanager.webui.wuicontentbase import WuiFormContentBase; 907 assert issubclass(oFormType, WuiFormContentBase); 908 878 909 # 879 910 # Read and validate parameters. … … 883 914 self._checkForUnknownParameters(); 884 915 self._assertPostRequest(); 885 dErrors = oData.validateAndConvert(self._oDb); 916 if sMode == WuiFormContentBase.ksMode_Add and getattr(oData, 'kfIdAttrIsForForeign', False): 917 enmValidateFor = oData.ksValidateFor_AddForeignId; 918 elif sMode == WuiFormContentBase.ksMode_Add: 919 enmValidateFor = oData.ksValidateFor_Add; 920 else: 921 enmValidateFor = oData.ksValidateFor_Edit; 922 dErrors = oData.validateAndConvert(self._oDb, enmValidateFor); 886 923 if len(dErrors) == 0: 887 924 oData.convertFromParamNull(); … … 907 944 else: 908 945 oForm = oFormType(oData, sMode, oDisp = self); 946 oForm.setRedirectTo(sRedirectTo); 909 947 (self._sPageTitle, self._sPageBody) = oForm.showForm(dErrors = dErrors); 910 948 return True; … … 919 957 sRedirAction is what action to redirect to on success. 920 958 """ 959 assert issubclass(oDataType, ModelDataBase); 960 assert issubclass(oLogicType, ModelLogicBase); 961 from testmanager.webui.wuicontentbase import WuiFormContentBase; 962 assert issubclass(oFormType, WuiFormContentBase); 963 921 964 oLogic = oLogicType(self._oDb); 922 from testmanager.webui.wuicontentbase import WuiFormContentBase;923 965 return self._actionGenericFormPost(WuiFormContentBase.ksMode_Add, oLogic.addEntry, oDataType, oFormType, 924 966 '?' + webutils.encodeUrlParams({self.ksParamAction: sRedirAction}), fStrict=fStrict) … … 932 974 sRedirAction is what action to redirect to on success. 933 975 """ 976 assert issubclass(oDataType, ModelDataBase); 977 assert issubclass(oLogicType, ModelLogicBase); 978 from testmanager.webui.wuicontentbase import WuiFormContentBase; 979 assert issubclass(oFormType, WuiFormContentBase); 980 934 981 oLogic = oLogicType(self._oDb); 935 from testmanager.webui.wuicontentbase import WuiFormContentBase;936 982 return self._actionGenericFormPost(WuiFormContentBase.ksMode_Edit, oLogic.editEntry, oDataType, oFormType, 937 983 '?' + webutils.encodeUrlParams({self.ksParamAction: sRedirAction}), -
trunk/src/VBox/ValidationKit/testmanager/webui/wuifailurecategory.py
r56295 r61220 33 33 from testmanager.webui.wuicontentbase import WuiFormContentBase, WuiListContentBase, WuiTmLink 34 34 from testmanager.core.failurecategory import FailureCategoryData 35 from testmanager.webui.wuibase import WuiException36 35 37 36 … … 41 40 """ 42 41 43 def __init__(self, o FailureCategoryData, sMode, oDisp):42 def __init__(self, oData, sMode, oDisp): 44 43 """ 45 44 Prepare & initialize parent 46 45 """ 47 46 47 sTitle = 'Failure Category'; 48 48 if sMode == WuiFormContentBase.ksMode_Add: 49 sTitle = 'Add Failure Category' 50 sSubmitAction = oDisp.ksActionFailureCategoryAdd 49 sTitle = 'Add ' + sTitle; 51 50 elif sMode == WuiFormContentBase.ksMode_Edit: 52 sTitle = 'Edit Failure Category' 53 sSubmitAction = oDisp.ksActionFailureCategoryEdit 51 sTitle = 'Edit ' + sTitle; 54 52 else: 55 raise WuiException('Unknown parameter')53 assert sMode == WuiFormContentBase.ksMode_Show; 56 54 57 WuiFormContentBase.__init__(self, oFailureCategoryData, sMode, 'FailureCategory', oDisp, sTitle, 58 sSubmitAction = sSubmitAction, fEditable = False); ## @todo non-standard action names. 55 WuiFormContentBase.__init__(self, oData, sMode, 'FailureCategory', oDisp, sTitle); 59 56 60 57 def _populateForm(self, oForm, oData): … … 73 70 74 71 return True 72 75 73 76 74 class WuiFailureCategoryList(WuiListContentBase): … … 94 92 oEntry.sShort, 95 93 oEntry.sFull, 96 [ WuiTmLink('Modify', WuiAdmin.ksScriptName, 97 { WuiAdmin.ksParamAction: WuiAdmin.ksActionFailureCategoryShowEdit, 94 [ WuiTmLink('Details', WuiAdmin.ksScriptName, 95 { WuiAdmin.ksParamAction: WuiAdmin.ksActionFailureCategoryDetails, 96 FailureCategoryData.ksParam_idFailureCategory: oEntry.idFailureCategory }), 97 WuiTmLink('Modify', WuiAdmin.ksScriptName, 98 { WuiAdmin.ksParamAction: WuiAdmin.ksActionFailureCategoryEdit, 98 99 FailureCategoryData.ksParam_idFailureCategory: oEntry.idFailureCategory }), 99 100 WuiTmLink('Remove', WuiAdmin.ksScriptName, 100 { WuiAdmin.ksParamAction: WuiAdmin.ksActionFailureCategoryD el,101 { WuiAdmin.ksParamAction: WuiAdmin.ksActionFailureCategoryDoRemove, 101 102 FailureCategoryData.ksParam_idFailureCategory: oEntry.idFailureCategory }, 102 103 sConfirm = 'Do you really want to remove failure cateogry #%d?' % (oEntry.idFailureCategory,)), -
trunk/src/VBox/ValidationKit/testmanager/webui/wuihlpform.py
r61217 r61220 56 56 57 57 if sOnSubmit == self.ksOnSubmit_AddReturnToFieldWithCurrentUrl: 58 sOnSubmit = 'return addRedirectToInputFieldWithCurrentUrl(this)';58 sOnSubmit = u'return addRedirectToInputFieldWithCurrentUrl(this)'; 59 59 if sOnSubmit is None: sOnSubmit = u''; 60 60 else: sOnSubmit = u' onsubmit=\"%s\"' % (escapeAttr(sOnSubmit),); -
trunk/src/VBox/ValidationKit/testmanager/webui/wuihlpgraph.py
r56295 r61220 100 100 # Dynamically choose implementation. 101 101 # 102 if True: 102 if True: # pylint: disable=W0125 103 103 from testmanager.webui import wuihlpgraphgooglechart as GraphImplementation; 104 104 else: -
trunk/src/VBox/ValidationKit/testmanager/webui/wuihlpgraphgooglechart.py
r56295 r61220 30 30 31 31 # Validation Kit imports. 32 from common import webutils; 32 33 from testmanager.webui.wuihlpgraphbase import WuiHlpGraphBase; 33 from common import webutils;34 from testmanager.webui import wuihlpgraphsimple; 34 35 35 36 … … 45 46 46 47 ## @todo bar graphs later. 47 from testmanager.webui import wuihlpgraphsimple;48 48 WuiHlpBarGraph = wuihlpgraphsimple.WuiHlpBarGraph; 49 49 -
trunk/src/VBox/ValidationKit/testmanager/webui/wuihlpgraphmatplotlib.py
r56295 r61220 36 36 matplotlib.use('Agg'); # Force backend. 37 37 import matplotlib.pyplot; # pylint: disable=F0401 38 from numpy import arange as numpy_arange; # pylint: disable=E0611 38 from numpy import arange as numpy_arange; # pylint: disable=E0611,E0401 39 39 40 40 # Validation Kit imports. … … 94 94 WuiHlpGraphMatplotlibBase.__init__(self, sId, oData, oDisp); 95 95 self.fpMax = None; 96 self.fpMin = 0 ;96 self.fpMin = 0.0; 97 97 self.cxBarWidth = None; 98 98 … … 138 138 139 139 aoBars = list(); 140 for i in range(len(aoSeries)):140 for i, _ in enumerate(aoSeries): 141 141 sColor = self.calcSeriesColor(i); 142 142 aoBars.append(oSubPlot.bar(oXRange + self.cxBarWidth * i, … … 157 157 oSubPlot.grid(True); 158 158 fpPadding = (fpMax - fpMin) * 0.02; 159 for i in range(len(aoBars)):159 for i, _ in enumerate(aoBars): 160 160 aoRects = aoBars[i] 161 for j in range(len(aoRects)):161 for j, _ in enumerate(aoRects): 162 162 oRect = aoRects[j]; 163 163 fpValue = float(aoTable[j + 1].aoValues[i]); … … 242 242 oSubPlot.grid(True, 'both', axis = 'x'); 243 243 244 if True: 244 if True: # pylint: disable=W0125 245 245 # oSubPlot.axis('off'); 246 246 #oSubPlot.grid(True, 'major', axis = 'none'); … … 284 284 285 285 oFigure = self._createFigure(); 286 from mpl_toolkits.axes_grid.axislines import SubplotZero; 286 from mpl_toolkits.axes_grid.axislines import SubplotZero; # pylint: disable=E0401 287 287 oAxis = SubplotZero(oFigure, 111); 288 288 oFigure.add_subplot(oAxis); -
trunk/src/VBox/ValidationKit/testmanager/webui/wuihlpgraphsimple.py
r56295 r61220 44 44 self.cxMaxBar = 480; 45 45 self.fpMax = None; 46 self.fpMin = 0 ;46 self.fpMin = 0.0; 47 47 48 48 def setRangeMax(self, fpMax): -
trunk/src/VBox/ValidationKit/testmanager/webui/wuireport.py
r56295 r61220 94 94 95 95 #for i in range(len(adPeriods) - 1, -1, -1): 96 for i in range(len(adPeriods)): 97 dStatuses = adPeriods[i]; 96 for i, dStatuses in enumerate(adPeriods): 98 97 cSuccess = dStatuses[ReportModelBase.ksTestStatus_Success] + dStatuses[ReportModelBase.ksTestStatus_Skipped]; 99 98 cTotal = cSuccess + dStatuses[ReportModelBase.ksTestStatus_Failure]; -
trunk/src/VBox/ValidationKit/testmanager/webui/wuitestresult.py
r61217 r61220 182 182 sDisplayName, 183 183 ' id="failure-%u"' % (iFailure,) if oTestResult.isFailure() else '', 184 webutils.escapeElem(oTestResult.enmStatus), webutils.escapeElem(sErrCnt), sChangeReason, 184 webutils.escapeElem(oTestResult.enmStatus), webutils.escapeElem(sErrCnt), 185 sChangeReason if oTestResult.oReason is None else '', 185 186 sResultGraph ); 186 187 iRow += 1; … … 208 209 sHtml += sChildHtml; 209 210 cErrorsBelow += oChild.cErrors; 210 211 if cErrorsBelow >= oTestResult.cErrors:212 sChangeReason = '';213 211 214 212 # Messages. … … 299 297 ' <td>%s</td>\n' \ 300 298 ' <td>%s</td>\n' \ 301 ' <td colspan="2"%s>%s%s </td>\n' \299 ' <td colspan="2"%s>%s%s%s</td>\n' \ 302 300 ' <td>%s</td>\n' \ 303 301 ' </tr>\n' \ … … 309 307 ' id="failure-%u"' % (iFailure,) if oTestResult.isFailure() else '', 310 308 webutils.escapeElem(oTestResult.enmStatus), webutils.escapeElem(sErrCnt), 309 sChangeReason if cErrorsBelow < oTestResult.cErrors and oTestResult.oReason is None else '', 311 310 sResultGraph); 312 311 iRow += 1; … … 314 313 # Failure reason. 315 314 if oTestResult.oReason is not None: 316 sReasonText = '%s / %s' % ( 317 315 sReasonText = '%s / %s' % ( oTestResult.oReason.oFailureReason.oCategory.sShort, 316 oTestResult.oReason.oFailureReason.sShort, ); 318 317 sCommentHtml = ''; 319 318 if oTestResult.oReason.sComment is not None and len(oTestResult.oReason.sComment.strip()) > 0: … … 327 326 oTestResult.idTestResult,}), 328 327 WuiContentBase.ksShortDetailsLinkHtml,); 329 330 328 331 329 sHtml += ' <tr class="%s tmtbl-events-reason tmtbl-events-lvl%s">\n' \ … … 365 363 366 364 # We need the failure reasons for the combobox. 367 aoFailureReasons = FailureReasonLogic(self._oDisp.getDb()).fetchForCombo('T odo: Figure out why');365 aoFailureReasons = FailureReasonLogic(self._oDisp.getDb()).fetchForCombo('Test Sheriff, you figure out why!'); 368 366 assert len(aoFailureReasons) > 0; 369 367
Note:
See TracChangeset
for help on using the changeset viewer.