Changeset 65980 in vbox for trunk/src/VBox/ValidationKit
- Timestamp:
- Mar 7, 2017 1:00:36 PM (8 years ago)
- svn:sync-xref-src-repo-rev:
- 113806
- Location:
- trunk/src/VBox/ValidationKit/testmanager/core
- Files:
-
- 23 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/testmanager/core/base.py
r65214 r65980 233 233 # Perform deep conversion on ModelDataBase object and lists of them. 234 234 # 235 elif isinstance(oValue, list) and len(oValue) > 0and isinstance(oValue[0], ModelDataBase):235 elif isinstance(oValue, list) and oValue and isinstance(oValue[0], ModelDataBase): 236 236 oValue = copy.copy(oValue); 237 237 for i, _ in enumerate(oValue): … … 269 269 # Perform deep conversion on ModelDataBase object and lists of them. 270 270 # 271 elif isinstance(oValue, list) and len(oValue) > 0and isinstance(oValue[0], ModelDataBase):271 elif isinstance(oValue, list) and oValue and isinstance(oValue[0], ModelDataBase): 272 272 oValue = copy.copy(oValue); 273 273 for i, _ in enumerate(oValue): … … 316 316 lMax = getattr(self, 'klMax_' + sAttr, None)); 317 317 elif sPrefix == 'f': 318 if oValue is ''and not fAllowNull: oValue = '0'; # HACK ALERT! Checkboxes are only added when checked.318 if not oValue and not fAllowNull: oValue = '0'; # HACK ALERT! Checkboxes are only added when checked. 319 319 (oNewValue, sError) = self.validateBool(oValue, aoNilValues = aoNilValues, fAllowNull = fAllowNull); 320 320 elif sPrefix == 'ts': … … 743 743 def validateListOfSomething(asValues, aoNilValues = tuple([[], None]), fAllowNull = True): 744 744 """ Validate a list of some uniform values. Returns a copy of the list (if list it is). """ 745 if asValues in aoNilValues or ( len(asValues) == 0and not fAllowNull):745 if asValues in aoNilValues or (not asValues and not fAllowNull): 746 746 return (asValues, None if fAllowNull else 'Mandatory.') 747 747 … … 750 750 751 751 asValues = list(asValues); # copy the list. 752 if len(asValues) > 0:752 if asValues: 753 753 oType = type(asValues[0]); 754 754 for i in range(1, len(asValues)): … … 764 764 (asValues, sError) = ModelDataBase.validateListOfSomething(asValues, aoNilValues, fAllowNull); 765 765 766 if sError is None and asValues not in aoNilValues and len(asValues) > 0:766 if sError is None and asValues not in aoNilValues and asValues: 767 767 if not utils.isString(asValues[0]): 768 768 return (asValues, 'Invalid item data type.'); … … 793 793 (asValues, sError) = ModelDataBase.validateListOfSomething(asValues, aoNilValues, fAllowNull); 794 794 795 if sError is None and asValues not in aoNilValues and len(asValues) > 0:795 if sError is None and asValues not in aoNilValues and asValues: 796 796 for i, _ in enumerate(asValues): 797 797 sValue = asValues[i]; … … 1089 1089 1090 1090 def testNullConversion(self): 1091 if len(self.aoSamples[0].getDataAttributes()) == 0:1091 if not self.aoSamples[0].getDataAttributes(): 1092 1092 return; 1093 1093 for oSample in self.aoSamples: … … 1261 1261 else: 1262 1262 assert False; 1263 if len(oCriterion.aoSelected) > 0:1263 if oCriterion.aoSelected: 1264 1264 oCriterion.sState = FilterCriterion.ksState_Selected; 1265 1265 else: -
trunk/src/VBox/ValidationKit/testmanager/core/build.py
r65258 r65980 278 278 , (idBuildCategory,)) 279 279 aaoRows = self._oDb.fetchAll() 280 if len(aaoRows) == 0:280 if not aaoRows: 281 281 return None; 282 282 if len(aaoRows) != 1: … … 307 307 )); 308 308 aaoRows = self._oDb.fetchAll(); 309 if len(aaoRows) == 0:309 if not aaoRows: 310 310 return None; 311 311 if len(aaoRows) > 1: … … 323 323 # Check BuildCategoryData before do anything 324 324 dDataErrors = oData.validateAndConvert(self._oDb, oData.ksValidateFor_Add); 325 if len(dDataErrors) > 0:325 if dDataErrors: 326 326 raise TMInvalidData('Invalid data passed to addBuildCategory(): %s' % (dDataErrors,)); 327 327 … … 432 432 for sBinary in self.sBinaries.split(','): 433 433 sBinary = sBinary.strip(); 434 if len(sBinary) == 0:434 if not sBinary: 435 435 continue; 436 436 # Same URL tests as in webutils.downloadFile(). … … 593 593 # 594 594 dErrors = oData.validateAndConvert(self._oDb, oData.ksValidateFor_Edit); 595 if len(dErrors) > 0:595 if dErrors: 596 596 raise TMInvalidData('editEntry invalid input: %s' % (dErrors,)); 597 597 oOldData = BuildData().initFromDbWithId(self._oDb, oData.idBuild); … … 741 741 for i in range(len(oBuildEx.oCat.asOsArches)): 742 742 asParts = oBuildEx.oCat.asOsArches[i].split('.'); 743 if len(asParts) != 2 or len(asParts[0]) == 0 or len(asParts[1]) == 0:743 if len(asParts) != 2 or not asParts[0] or not asParts[1]: 744 744 raise self._oDb.integrityException('Bad build asOsArches value: %s (idBuild=%s idBuildCategory=%s)' 745 745 % (oBuildEx.asOsArches[i], oBuildEx.idBuild, oBuildEx.idBuildCategory)); -
trunk/src/VBox/ValidationKit/testmanager/core/buildblacklist.py
r65226 r65980 193 193 assert isinstance(oData, BuildBlacklistData); 194 194 dErrors = oData.validateAndConvert(self._oDb, oData.ksValidateFor_Edit); 195 if len(dErrors) > 0:195 if dErrors: 196 196 raise TMInvalidData('editEntry invalid input: %s' % (dErrors,)); 197 197 -
trunk/src/VBox/ValidationKit/testmanager/core/buildsource.py
r65226 r65980 213 213 # 214 214 dErrors = oData.validateAndConvert(self._oDb, oData.ksValidateFor_Add); 215 if len(dErrors) > 0:215 if dErrors: 216 216 raise TMInvalidData('addEntry invalid input: %s' % (dErrors,)); 217 217 self._assertUnique(oData, None); … … 255 255 # 256 256 dErrors = oData.validateAndConvert(self._oDb, oData.ksValidateFor_Edit); 257 if len(dErrors) > 0:257 if dErrors: 258 258 raise TMInvalidData('addEntry invalid input: %s' % (dErrors,)); 259 259 self._assertUnique(oData, oData.idBuildSrc); … … 388 388 389 389 # Types 390 if oBuildSource.asTypes is not None and len(oBuildSource.asTypes) > 0:390 if oBuildSource.asTypes is not None and oBuildSource.asTypes: 391 391 if len(oBuildSource.asTypes) == 1: 392 392 sExtraConditions += oCursor.formatBindArgs(' AND BuildCategories.sType = %s', (oBuildSource.asTypes[0],)); … … 398 398 399 399 # BuildSource OSes.ARCHes. (Paranoia: use a dictionary to avoid duplicate values.) 400 if oBuildSource.asOsArches is not None and len(oBuildSource.asOsArches) > 0:400 if oBuildSource.asOsArches is not None and oBuildSource.asOsArches: 401 401 sExtraConditions += oCursor.formatBindArgs(' AND BuildCategories.asOsArches && %s', (oBuildSource.asOsArches,)); 402 402 -
trunk/src/VBox/ValidationKit/testmanager/core/db.py
r62484 r65980 34 34 import os; 35 35 import sys; 36 import psycopg2; 37 import psycopg2.extensions; 36 import psycopg2; # pylint: disable=import-error 37 import psycopg2.extensions; # pylint: disable=import-error 38 38 39 39 # Validation Kit imports. … … 431 431 oRc = self.executeInternal(oCursor, sInsertSql + 'VALUES' + ', '.join(asValues), None, sCallerName); 432 432 asValues = []; 433 if len(asValues) > 0:433 if asValues: 434 434 oRc = self.executeInternal(oCursor, sInsertSql + 'VALUES' + ', '.join(asValues), None, sCallerName); 435 435 return oRc -
trunk/src/VBox/ValidationKit/testmanager/core/dbobjcache.py
r62484 r65980 156 156 if iRevision not in dRepo: 157 157 aiFiltered.append(iRevision); 158 if len(aiFiltered) > 0:158 if aiFiltered: 159 159 self._oDb.execute('SELECT *\n' 160 160 'FROM VcsRevisions\n' -
trunk/src/VBox/ValidationKit/testmanager/core/failurecategory.py
r65226 r65980 179 179 180 180 # If we're at the end of the log, add the initial entry. 181 if len(aoRows) <= cMaxRows and len(aoRows) > 0:181 if len(aoRows) <= cMaxRows and aoRows: 182 182 oNew = aoRows[-1]; 183 183 aoEntries.append(ChangeLogEntry(oNew.uidAuthor, None, oNew.tsEffective, oNew.tsExpire, oNew, None, [])); … … 233 233 assert isinstance(oData, FailureCategoryData); 234 234 dErrors = oData.validateAndConvert(self._oDb, oData.ksValidateFor_Add); 235 if len(dErrors) > 0:235 if dErrors: 236 236 raise TMInvalidData('editEntry invalid input: %s' % (dErrors,)); 237 237 … … 254 254 assert isinstance(oData, FailureCategoryData); 255 255 dErrors = oData.validateAndConvert(self._oDb, oData.ksValidateFor_Edit); 256 if len(dErrors) > 0:256 if dErrors: 257 257 raise TMInvalidData('editEntry invalid input: %s' % (dErrors,)); 258 258 … … 285 285 , (idFailureCategory,)); 286 286 aaoRows = self._oDb.fetchAll(); 287 if len(aaoRows) > 0:287 if aaoRows: 288 288 raise TMRowInUse('Cannot remove failure reason category %u because its being used by: %s' 289 289 % (idFailureCategory, ', '.join(aoRow[0] for aoRow in aaoRows),)); -
trunk/src/VBox/ValidationKit/testmanager/core/failurereason.py
r65226 r65980 316 316 317 317 # If we're at the end of the log, add the initial entry. 318 if len(aoRows) <= cMaxRows and len(aoRows) > 0:318 if len(aoRows) <= cMaxRows and aoRows: 319 319 oNew = aoRows[-1]; 320 320 aoEntries.append(ChangeLogEntry(oNew.uidAuthor, None, oNew.tsEffective, oNew.tsExpire, oNew, None, [])); … … 348 348 # 349 349 dErrors = oData.validateAndConvert(self._oDb, oData.ksValidateFor_Add); 350 if len(dErrors) > 0:350 if dErrors: 351 351 raise TMInvalidData('addEntry invalid input: %s' % (dErrors,)); 352 352 … … 369 369 assert isinstance(oData, FailureReasonData); 370 370 dErrors = oData.validateAndConvert(self._oDb, oData.ksValidateFor_Edit); 371 if len(dErrors) > 0:371 if dErrors: 372 372 raise TMInvalidData('editEntry invalid input: %s' % (dErrors,)); 373 373 … … 405 405 , (idFailureReason, idFailureReason,)); 406 406 aaoRows = self._oDb.fetchAll(); 407 if len(aaoRows) > 0:407 if aaoRows: 408 408 raise TMRowInUse('Cannot remove failure reason %u because its being used by: %s' 409 409 % (idFailureReason, ', '.join(aoRow[0] for aoRow in aaoRows),)); -
trunk/src/VBox/ValidationKit/testmanager/core/globalresource.py
r65226 r65980 272 272 """ 273 273 # Quit quickly if there is nothing to alloocate. 274 if len(aoGlobalRsrcs) == 0:274 if not aoGlobalRsrcs: 275 275 return True; 276 276 -
trunk/src/VBox/ValidationKit/testmanager/core/report.py
r65430 r65980 143 143 sWhere += self._oDb.formatBindArgs(' = %s\n', (self.aidSubjects[0],)); 144 144 else: 145 assert len(self.aidSubjects) > 0;145 assert self.aidSubjects; 146 146 sWhere += self._oDb.formatBindArgs(' IN (%s', (self.aidSubjects[0],)); 147 147 for i in range(1, len(self.aidSubjects)): … … 1130 1130 if len(self.aidTestBoxes) == 1: 1131 1131 sQuery += ' AND TestSets.idTestBox = %u\n' % (self.aidTestBoxes[0],); 1132 elif len(self.aidTestBoxes) > 0:1132 elif self.aidTestBoxes: 1133 1133 sQuery += ' AND TestSets.idTestBox IN (' + ','.join([str(i) for i in self.aidTestBoxes]) + ')\n'; 1134 1134 1135 1135 if len(self.aidBuildCats) == 1: 1136 1136 sQuery += ' AND TestSets.idBuildCategory = %u\n' % (self.aidBuildCats[0],); 1137 elif len(self.aidBuildCats) > 0:1137 elif self.aidBuildCats: 1138 1138 sQuery += ' AND TestSets.idBuildCategory IN (' + ','.join([str(i) for i in self.aidBuildCats]) + ')\n'; 1139 1139 1140 1140 if len(self.aidTestCases) == 1: 1141 1141 sQuery += ' AND TestSets.idTestCase = %u\n' % (self.aidTestCases[0],); 1142 elif len(self.aidTestCases) > 0:1142 elif self.aidTestCases: 1143 1143 sQuery += ' AND TestSets.idTestCase IN (' + ','.join([str(i) for i in self.aidTestCases]) + ')\n'; 1144 1144 … … 1244 1244 # 2. Query all the testbox data in one go. 1245 1245 aoRet = []; 1246 if len(asIdGenTestBoxes) > 0:1246 if asIdGenTestBoxes: 1247 1247 self._oDb.execute('SELECT *\n' 1248 1248 'FROM TestBoxesWithStrings\n' … … 1267 1267 1268 1268 sSelectedBuildCats = ''; 1269 if len(self.aidBuildCats) > 0:1269 if self.aidBuildCats: 1270 1270 sSelectedBuildCats = ' OR idBuildCategory IN (' + ','.join([str(i) for i in self.aidBuildCats]) + ')\n'; 1271 1271 -
trunk/src/VBox/ValidationKit/testmanager/core/schedgroup.py
r65226 r65980 376 376 377 377 dErrors = oNewMember.validateAndConvert(oDb, ModelDataBase.ksValidateFor_Other); 378 if len(dErrors) > 0:378 if dErrors: 379 379 asErrors.append(str(dErrors)); 380 380 381 if len(asErrors) == 0:381 if not asErrors: 382 382 for i, _ in enumerate(aoNewMembers): 383 383 idTestGroup = aoNewMembers[i]; … … 387 387 break; 388 388 389 return (aoNewMembers, None if len(asErrors) == 0else '<br>\n'.join(asErrors));389 return (aoNewMembers, None if not asErrors else '<br>\n'.join(asErrors)); 390 390 391 391 def _validateAndConvertWorker(self, asAllowNullAttributes, oDb, enmValidateFor = ModelDataBase.ksValidateFor_Other): … … 471 471 # 472 472 dDataErrors = oData.validateAndConvert(self._oDb, oData.ksValidateFor_Add); 473 if len(dDataErrors) > 0:473 if dDataErrors: 474 474 raise TMInvalidData('Invalid data passed to addEntry: %s' % (dDataErrors,)); 475 475 if self.exists(oData.sName): … … 515 515 # 516 516 dErrors = oData.validateAndConvert(self._oDb, oData.ksValidateFor_Edit); 517 if len(dErrors) > 0:517 if dErrors: 518 518 raise TMInvalidData('editEntry got invalid data: %s' % (dErrors,)); 519 519 self._assertUnique(oData.sName, oData.idSchedGroup); … … 572 572 # associated testboxes or testgroups. 573 573 # 574 if len(oData.aoTestBoxes) > 0:574 if oData.aoTestBoxes: 575 575 if fCascade is not True: 576 576 # Complain about there being associated testboxes. … … 587 587 588 588 oData = SchedGroupDataEx().initFromDbWithId(self._oDb, idSchedGroup); 589 if len(oData.aoTestBoxes) != 0:589 if oData.aoTestBoxes: 590 590 raise TMRowInUse('More testboxes was added to the scheduling group as we were trying to delete it.'); 591 591 -
trunk/src/VBox/ValidationKit/testmanager/core/schedulerbase.py
r65732 r65980 103 103 # Associate extra members with the base data. 104 104 # 105 if len(self.aoTestGroups) > 0:105 if self.aoTestGroups: 106 106 # Prep the test groups. 107 107 for oTestGroup in self.aoTestGroups: … … 125 125 # in both directions. 126 126 oTestGroup = self.aoTestGroups[0]; 127 oTestCase = self.aoTestCases[0] if len(self.aoTestCases) > 0else None;127 oTestCase = self.aoTestCases[0] if self.aoTestCases else None; 128 128 for oArgVariation in self.aoArgsVariations: 129 129 if oTestGroup.idTestGroup != oArgVariation.idTestGroup: … … 137 137 138 138 else: 139 assert len(self.aoTestCases) == 0;140 assert len(self.aoArgsVariations) == 0;139 assert not self.aoTestCases; 140 assert not self.aoArgsVariations; 141 141 # done. 142 142 … … 198 198 for oTestGroup in self.aoTestGroups: 199 199 for oTestCase in oTestGroup.aoTestCases: 200 if len(oTestCase.aidPreReqs) == 0:200 if not oTestCase.aidPreReqs: 201 201 continue; 202 202 203 203 # Stupid recursion code using special stack(s). 204 aiIndexes = [ (oTestCase, 0), ];204 aiIndexes = [[oTestCase, 0], ]; 205 205 aidChain = [oTestCase.idTestGroup,]; 206 while len(aiIndexes) > 0:206 while aiIndexes: 207 207 (oCur, i) = aiIndexes[-1]; 208 208 if i >= len(oCur.aidPreReqs): … … 222 222 'TestCase #%s prerequisite #%s creates a cycle!' 223 223 % (oTestCase.idTestCase, idPreReq)); 224 elif len(oDep.aiPreReqs) == 0:224 elif not oDep.aiPreReqs: 225 225 pass; 226 226 elif len(aidChain) >= 10: … … 228 228 'TestCase #%s prerequisite chain is too long!' % (oTestCase.idTestCase,)); 229 229 else: 230 aiIndexes.append( (oDep, 0));230 aiIndexes.append([oDep, 0]); 231 231 aidChain.append(idPreReq); 232 232 … … 238 238 Note! Don't call this before checking for dependency cycles! 239 239 """ 240 if len(self.aoTestGroups) == 0:240 if not self.aoTestGroups: 241 241 return; 242 242 … … 252 252 iGrpPrio = oTestGroup.iSchedPriority; 253 253 254 if len(oTestGroup.aoTestCases) > 0:254 if oTestGroup.aoTestCases: 255 255 iTstPrio = oTestGroup.aoTestCases[0]; 256 256 for oTestCase in oTestGroup.aoTestCases: … … 283 283 while i < len(oTestGroup.aoTestCases): 284 284 oTestCase = oTestGroup.aoTestCases[i]; 285 if len(oTestCase.aidPreReqs) > 0:285 if oTestCase.aidPreReqs: 286 286 for idPreReq in oTestCase.aidPreReqs: 287 287 iPreReq = oTestGroup.aoTestCases.index(oTestGroup.dTestCases[idPreReq]); … … 472 472 def setupSource(self, oDb, idBuildSrc, sOs, sCpuArch, tsNow): 473 473 """ Configures the build cursor for the cache. """ 474 if len(self.aoEntries) == 0and self.oCursor is None:474 if not self.aoEntries and self.oCursor is None: 475 475 oBuildSource = BuildSourceData().initFromDbWithId(oDb, idBuildSrc, tsNow); 476 476 self.oCursor = BuildSourceLogic(oDb).openBuildCursor(oBuildSource, sOs, sCpuArch, tsNow); … … 594 594 aoErrors = oData.checkForGroupDepCycles(); 595 595 aoErrors.extend(oData.checkForMissingTestCaseDeps()); 596 if len(aoErrors) == 0:596 if not aoErrors: 597 597 oData.deepTestGroupSort(); 598 598 … … 609 609 # 610 610 aoItems = list(); 611 if len(oData.aoArgsVariations) > 0:611 if oData.aoArgsVariations: 612 612 aoItems = self._recreateQueueItems(oData); 613 613 self.msgDebug('len(aoItems)=%s' % (len(aoItems),)); 614 614 #for i in range(len(aoItems)): 615 615 # self.msgDebug('aoItems[%2d]=%s' % (i, aoItems[i])); 616 if len(aoItems) > 0:616 if aoItems: 617 617 self._oDb.execute('SELECT offQueue FROM SchedQueues WHERE idSchedGroup = %s ORDER BY idItem LIMIT 1' 618 618 , (self._oSchedGrpData.idSchedGroup,)); … … 653 653 oItem.idGenTestCaseArgs, 654 654 oItem.idTestGroup, 655 oItem.aidTestGroupPreReqs if len(oItem.aidTestGroupPreReqs) > 0else None,655 oItem.aidTestGroupPreReqs if oItem.aidTestGroupPreReqs else None, 656 656 oItem.bmHourlySchedule, 657 657 oItem.cMissingGangMembers … … 696 696 697 697 (aoErrors, asMessages) = oScheduler.recreateQueueWorker(); 698 if len(aoErrors) == 0:698 if not aoErrors: 699 699 SystemLogLogic(oDb).addEntry(SystemLogData.ksEvent_SchedQueueRecreate, 700 700 'User #%d recreated sched queue #%d.' % (uidAuthor, idSchedGroup,)); … … 1021 1021 # Create a SQL values table out of them. 1022 1022 sPreReqSet = '' 1023 if len(dPreReqs) > 0:1023 if dPreReqs: 1024 1024 for idPreReq in sorted(dPreReqs): 1025 1025 sPreReqSet += ', (' + str(idPreReq) + ')'; … … 1046 1046 # satisfied if there are any failure runs. 1047 1047 # 1048 if len(sPreReqSet) > 0:1048 if sPreReqSet: 1049 1049 fDecision = oEntry.getPreReqDecision(sPreReqSet); 1050 1050 if fDecision is None: … … 1303 1303 iWorkItem = 0; 1304 1304 1305 elif len(oTestBoxDataEx.aoInSchedGroups) > 0:1305 elif oTestBoxDataEx.aoInSchedGroups: 1306 1306 # Construct priority table of currently enabled scheduling groups. 1307 1307 aaoList1 = []; -
trunk/src/VBox/ValidationKit/testmanager/core/schedulerbeci.py
r62484 r65980 88 88 for oTestCase in oTestGroup.aoTestCases: 89 89 #self.msgDebug('testcase loop: idTestCase=%s' % (oTestCase.idTestCase,)); 90 if iPrio <= oTestCase.iBeciPrio and len(oTestCase.aoArgsVariations) > 0:90 if iPrio <= oTestCase.iBeciPrio and oTestCase.aoArgsVariations: 91 91 # Get variation. 92 92 iNext = oTestCase.iNextVariation; -
trunk/src/VBox/ValidationKit/testmanager/core/testbox.py
r65425 r65980 644 644 oInSchedGroup.idTestBox = self.idTestBox; 645 645 dCurErrors = oInSchedGroup.validateAndConvert(oDb, ModelDataBase.ksValidateFor_Other); 646 if len(dCurErrors) == 0:646 if not dCurErrors: 647 647 pass; ## @todo figure out the ID? 648 648 else: … … 663 663 break; 664 664 665 return (aoNewValues, dErrors if len(dErrors) > 0else None);665 return (aoNewValues, dErrors if dErrors else None); 666 666 667 667 … … 768 768 from testmanager.core.testboxstatus import TestBoxStatusData; 769 769 770 if aiSortColumns is None or len(aiSortColumns) == 0:770 if not aiSortColumns: 771 771 aiSortColumns = [self.kiSortColumn_sName,]; 772 772 … … 846 846 847 847 # If we're at the end of the log, add the initial entry. 848 if len(aoRows) <= cMaxRows and len(aoRows) > 0:848 if len(aoRows) <= cMaxRows and aoRows: 849 849 oNew = aoRows[-1]; 850 850 aoEntries.append(ChangeLogEntry(oNew.uidAuthor, None, oNew.tsEffective, oNew.tsExpire, oNew, None, [])); … … 862 862 """ 863 863 dDataErrors = oData.validateAndConvert(self._oDb, enmValidateFor); 864 if len(dDataErrors) > 0:864 if dDataErrors: 865 865 raise TMInvalidData('TestBoxLogic.addEntry: %s' % (dDataErrors,)); 866 866 if isinstance(oData, TestBoxDataEx): 867 if len(oData.aoInSchedGroups):867 if oData.aoInSchedGroups: 868 868 sSchedGrps = ', '.join('(%s)' % oCur.idSchedGroup for oCur in oData.aoInSchedGroups); 869 869 self._oDb.execute('SELECT SchedGroupIDs.idSchedGroup\n' … … 874 874 'WHERE SchedGroups.idSchedGroup IS NULL\n'); 875 875 aaoRows = self._oDb.fetchAll(); 876 if len(aaoRows) > 0:876 if aaoRows: 877 877 raise TMInvalidData('TestBoxLogic.addEntry missing scheduling groups: %s' 878 878 % (', '.join(str(aoRow[0]) for aoRow in aaoRows),)); -
trunk/src/VBox/ValidationKit/testmanager/core/testboxcontroller.py
r65335 r65980 372 372 373 373 # Null conversions for new parameters. 374 if len(sReport) == 0:374 if not sReport: 375 375 sReport = None; 376 if len(sCpuName) == 0:376 if not sCpuName: 377 377 sCpuName = None; 378 378 if lCpuRevision <= 0: … … 657 657 # 658 658 sBody = self._getStringParam(constants.tbreq.LOG_PARAM_BODY, fStrip = False); 659 if len(sBody) == 0:659 if not sBody: 660 660 return self._resultResponse(constants.tbresp.STATUS_NACK); 661 661 self._checkForUnknownParameters(); … … 753 753 sXml = self._getStringParam(constants.tbreq.XML_RESULT_PARAM_BODY, fStrip = False); 754 754 self._checkForUnknownParameters(); 755 if len(sXml) == 0: # Used for link check by vboxinstaller.py on Windows.755 if not sXml: # Used for link check by vboxinstaller.py on Windows. 756 756 return self._resultResponse(constants.tbresp.STATUS_ACK); 757 757 -
trunk/src/VBox/ValidationKit/testmanager/core/testcase.py
r65226 r65980 298 298 Test Case depends on 299 299 """ 300 if len(aTestCaseDependencyData) == 0:300 if not aTestCaseDependencyData: 301 301 return [] 302 302 … … 889 889 else: 890 890 assert sAttr == 'aoTestCaseArgs'; 891 if self.aoTestCaseArgs is None or len(self.aoTestCaseArgs) == 0:891 if not self.aoTestCaseArgs: 892 892 return (None, 'The testcase requires at least one argument variation to be valid.'); 893 893 … … 899 899 oVar.idTestCase = self.idTestCase; 900 900 dCurErrors = oVar.validateAndConvert(oDb, ModelDataBase.ksValidateFor_Other); 901 if len(dCurErrors) == 0:901 if not dCurErrors: 902 902 pass; ## @todo figure out the ID? 903 903 else: … … 919 919 break; 920 920 921 return (aoNewValues, dErrors if len(dErrors) > 0else None);922 923 return (aoNewValues, None if len(asErrors) == 0else ' <br>'.join(asErrors));921 return (aoNewValues, dErrors if dErrors else None); 922 923 return (aoNewValues, None if not asErrors else ' <br>'.join(asErrors)); 924 924 925 925 def _validateAndConvertWorker(self, asAllowNullAttributes, oDb, enmValidateFor = ModelDataBase.ksValidateFor_Other): … … 928 928 # Validate dependencies a wee bit for paranoid reasons. The scheduler 929 929 # queue generation code does the real validation here! 930 if len(dErrors) == 0and self.idTestCase is not None:930 if not dErrors and self.idTestCase is not None: 931 931 for oDep in self.aoDepTestCases: 932 932 if oDep.idTestCase == self.idTestCase: … … 1126 1126 1127 1127 # If we're at the end of the log, add the initial entry. 1128 if len(aoRows) <= cMaxRows and len(aoRows) > 0:1128 if len(aoRows) <= cMaxRows and aoRows: 1129 1129 oNew = aoRows[-1]; 1130 1130 aoEntries.append(ChangeLogEntry(oNew.uidAuthor, None, … … 1145 1145 assert isinstance(oData, TestCaseDataEx); 1146 1146 dErrors = oData.validateAndConvert(self._oDb, oData.ksValidateFor_Add); 1147 if len(dErrors) > 0:1147 if dErrors: 1148 1148 raise TMInvalidData('Invalid input data: %s' % (dErrors,)); 1149 1149 … … 1190 1190 assert isinstance(oData, TestCaseDataEx); 1191 1191 dErrors = oData.validateAndConvert(self._oDb, oData.ksValidateFor_Edit); 1192 if len(dErrors) > 0:1192 if dErrors: 1193 1193 raise TMInvalidData('Invalid input data: %s' % (dErrors,)); 1194 1194 … … 1228 1228 if idDep in aidNewDeps: 1229 1229 asKeepers.append(str(idDep)); 1230 if len(asKeepers) > 0:1230 if asKeepers: 1231 1231 sQuery += ' AND idTestCasePreReq NOT IN (' + ', '.join(asKeepers) + ')\n'; 1232 1232 self._oDb.execute(sQuery); … … 1253 1253 if idDep in aidNewDeps: 1254 1254 asKeepers.append(str(idDep)); 1255 if len(asKeepers) > 0:1255 if asKeepers: 1256 1256 sQuery = ' AND idGlobalRsrc NOT IN (' + ', '.join(asKeepers) + ')\n'; 1257 1257 self._oDb.execute(sQuery); … … 1276 1276 for oNewVar in oData.aoTestCaseArgs: 1277 1277 asKeepers.append(self._oDb.formatBindArgs('%s', (oNewVar.sArgs,))); 1278 if len(asKeepers) > 0:1278 if asKeepers: 1279 1279 sQuery += ' AND sArgs NOT IN (' + ', '.join(asKeepers) + ')\n'; 1280 1280 self._oDb.execute(sQuery); -
trunk/src/VBox/ValidationKit/testmanager/core/testcaseargs.py
r65533 r65980 273 273 274 274 # Create a set of global resource IDs. 275 if len(oDataEx.aoGlobalRsrc) == 0:275 if not oDataEx.aoGlobalRsrc: 276 276 return True; 277 277 asIdRsrcs = [str(oDep.idGlobalRsrc) for oDep, _ in oDataEx.aoGlobalRsrc]; -
trunk/src/VBox/ValidationKit/testmanager/core/testgroup.py
r65226 r65980 353 353 354 354 dErrors = oNewMember.validateAndConvert(oDb, ModelDataBase.ksValidateFor_Other); 355 if len(dErrors) > 0:355 if dErrors: 356 356 asErrors.append(str(dErrors)); 357 357 358 if len(asErrors) == 0:358 if not asErrors: 359 359 for i, _ in enumerate(aoNewMembers): 360 360 idTestCase = aoNewMembers[i]; … … 364 364 break; 365 365 366 return (aoNewMembers, None if len(asErrors) == 0else '<br>\n'.join(asErrors));366 return (aoNewMembers, None if not asErrors else '<br>\n'.join(asErrors)); 367 367 368 368 … … 419 419 assert isinstance(oData, TestGroupDataEx); 420 420 dErrors = oData.validateAndConvert(self._oDb, oData.ksValidateFor_Add); 421 if len(dErrors) > 0:421 if dErrors: 422 422 raise TMInvalidData('addEntry invalid input: %s' % (dErrors,)); 423 423 self._assertUniq(oData, None); … … 453 453 assert isinstance(oData, TestGroupDataEx); 454 454 dErrors = oData.validateAndConvert(self._oDb, oData.ksValidateFor_Edit); 455 if len(dErrors) > 0:455 if dErrors: 456 456 raise TMInvalidData('editEntry invalid input: %s' % (dErrors,)); 457 457 self._assertUniq(oData, oData.idTestGroup); … … 502 502 ' AND tsExpire = \'infinity\'::TIMESTAMP\n' 503 503 , ( oData.idTestGroup, )); 504 if len(dNew) > 0:505 sQuery += ' AND idTestCase NOT IN (%s)' % (', '.join([str(iKey) for iKey in dNew .keys()]),);504 if dNew: 505 sQuery += ' AND idTestCase NOT IN (%s)' % (', '.join([str(iKey) for iKey in dNew]),); 506 506 self._oDb.execute(sQuery); 507 507 … … 527 527 , ( idTestGroup, )); 528 528 aoGroups = self._oDb.fetchAll(); 529 if len(aoGroups) > 0:529 if aoGroups: 530 530 asGroups = ['%s (#%d)' % (sName, idSchedGroup) for idSchedGroup, sName in aoGroups]; 531 531 raise TMRowInUse('Test group #%d is member of one or more scheduling groups: %s' -
trunk/src/VBox/ValidationKit/testmanager/core/testresultfailures.py
r62484 r65980 353 353 354 354 # If we're at the end of the log, add the initial entry. 355 if len(aaoRows) <= cMaxRows and len(aaoRows) > 0:355 if len(aaoRows) <= cMaxRows and aaoRows: 356 356 aoNew = aaoRows[-1]; 357 357 tsExpire = aaoRows[-1 - 1][0] if len(aaoRows) > 1 else aoNew[2].tsExpire; … … 387 387 assert isinstance(oData, TestResultFailureData); 388 388 dErrors = oData.validateAndConvert(self._oDb, oData.ksValidateFor_AddForeignId); 389 if len(dErrors) > 0:389 if dErrors: 390 390 raise TMInvalidData('editEntry invalid input: %s' % (dErrors,)); 391 391 … … 416 416 assert isinstance(oData, TestResultFailureData); 417 417 dErrors = oData.validateAndConvert(self._oDb, oData.ksValidateFor_Edit); 418 if len(dErrors) > 0:418 if dErrors: 419 419 raise TMInvalidData('editEntry invalid input: %s' % (dErrors,)); 420 420 -
trunk/src/VBox/ValidationKit/testmanager/core/testresults.py
r65866 r65980 1684 1684 if aoRow[0] in dLeft: 1685 1685 del dLeft[aoRow[0]]; 1686 if len(dLeft) > 0:1686 if dLeft: 1687 1687 if fIdIsName: 1688 1688 for idMissing in dLeft: … … 1719 1719 oMain.cTimes += aoRow[4]; 1720 1720 1721 if len(dLeft) > 0:1721 if dLeft: 1722 1722 pass; ## @todo 1723 1723 … … 2090 2090 2091 2091 aaoRows = self._oDb.fetchAll(); 2092 if len(aaoRows) == 0:2092 if not aaoRows: 2093 2093 raise TMRowNotFound('No test results for idTestSet=%d.' % (idTestSet,)); 2094 2094 … … 2557 2557 # Validate string attributes. 2558 2558 for sAttr in [ 'name', 'text' ]: # 'unit' can be zero length. 2559 if sAttr in dAttribs and len(dAttribs[sAttr]) == 0:2559 if sAttr in dAttribs and not dAttribs[sAttr]: 2560 2560 return 'Element %s has an empty %s attribute value.' % (sName, sAttr,); 2561 2561 … … 2622 2622 dAttribs = {}; 2623 2623 sElement = sElement.strip(); 2624 while len(sElement) > 0:2624 while sElement: 2625 2625 # Extract attribute name. 2626 2626 off = sElement.find('='); … … 2678 2678 """ 2679 2679 if sName == 'Test': 2680 iNestingDepth = aoStack[0].iNestingDepth + 1 if len(aoStack) > 0else 0;2680 iNestingDepth = aoStack[0].iNestingDepth + 1 if aoStack else 0; 2681 2681 aoStack.insert(0, self._newTestResult(idTestResultParent = aoStack[0].idTestResult, idTestSet = idTestSet, 2682 2682 tsCreated = dAttribs['timestamp'], sName = dAttribs['name'], … … 2748 2748 """ 2749 2749 aoStack = self._getResultStack(idTestSet); # [0] == top; [-1] == bottom. 2750 if len(aoStack) == 0:2750 if not aoStack: 2751 2751 return ('No open results', True); 2752 2752 self._oDb.dprint('** processXmlStream len(aoStack)=%s' % (len(aoStack),)); … … 2760 2760 fExpectCloseTest = False; 2761 2761 sXml = sXml.strip(); 2762 while len(sXml) > 0:2762 while sXml: 2763 2763 if sXml.startswith('</Test>'): # Only closing tag. 2764 2764 offNext = len('</Test>'); … … 2821 2821 if sError is None and fExpectCloseTest: 2822 2822 sError = 'Expected </Test> before the end of the XML section.' 2823 elif sError is None and len(aaiHints) > 0:2823 elif sError is None and aaiHints: 2824 2824 sError = 'Expected </PopHint> before the end of the XML section.' 2825 if len(aaiHints) > 0:2825 if aaiHints: 2826 2826 self._doPopHint(aoStack, aaiHints[-1][0], dCounts, idTestSet); 2827 2827 … … 2833 2833 'idTestSet=%s idTestResult=%s XML="%s" %s' 2834 2834 % ( idTestSet, 2835 aoStack[0].idTestResult if len(aoStack) > 0else -1,2836 sXml[: 30 if len(sXml) >= 30 else len(sXml)],2835 aoStack[0].idTestResult if aoStack else -1, 2836 sXml[:min(len(sXml), 30)], 2837 2837 sError, ), 2838 2838 cHoursRepeat = 6, fCommit = True); -
trunk/src/VBox/ValidationKit/testmanager/core/testset.py
r65317 r65980 377 377 , (idTestSet, TestSetData.ksTestStatus_Running, oData.idTestResult)); 378 378 aaoRows = self._oDb.fetchAll(); 379 if len(aaoRows):379 if aaoRows: 380 380 idStr = self.strTabString('Unclosed test result', fCommit = fCommit); 381 381 for aoRow in aaoRows: -
trunk/src/VBox/ValidationKit/testmanager/core/vcsrevisions.py
r65226 r65980 143 143 if len(aaoRows) == 1: 144 144 return VcsRevisionData().initFromDbRow(aaoRows[0]); 145 if len(aaoRows) != 0:145 if aaoRows: 146 146 raise TMExceptionBase('VcsRevisions has a primary key problem: %u duplicates' % (len(aaoRows),)); 147 147 return None … … 160 160 # Check VcsRevisionData before do anything 161 161 dDataErrors = oData.validateAndConvert(self._oDb, oData.ksValidateFor_Add); 162 if len(dDataErrors) > 0:162 if dDataErrors: 163 163 raise TMExceptionBase('Invalid data passed to addVcsRevision(): %s' % (dDataErrors,)); 164 164 -
trunk/src/VBox/ValidationKit/testmanager/core/webservergluebase.py
r65032 r65980 260 260 if self._sBodyType is None: 261 261 self._sBodyType = 'html'; 262 elif self._sBodyType is not'html':262 elif self._sBodyType != 'html': 263 263 raise WebServerGlueException('Cannot use writeParameter when body type is "%s"' % (self._sBodyType, )); 264 264 … … 277 277 if self._sBodyType is None: 278 278 self._sBodyType = 'html'; 279 elif self._sBodyType is not'html':279 elif self._sBodyType != 'html': 280 280 raise WebServerGlueException('Cannot use writeParameter when body type is "%s"' % (self._sBodyType, )); 281 281 … … 304 304 self._sBodyType = 'form'; 305 305 306 elif self._sBodyType is not'form':306 elif self._sBodyType != 'form': 307 307 raise WebServerGlueException('Cannot use writeParams when body type is "%s"' % (self._sBodyType, )); 308 308
Note:
See TracChangeset
for help on using the changeset viewer.