VirtualBox

Changeset 65980 in vbox for trunk/src/VBox/ValidationKit


Ignore:
Timestamp:
Mar 7, 2017 1:00:36 PM (8 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
113806
Message:

testmanager/core: pylint 2.0.0 fixes.

Location:
trunk/src/VBox/ValidationKit/testmanager/core
Files:
23 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/testmanager/core/base.py

    r65214 r65980  
    233233        # Perform deep conversion on ModelDataBase object and lists of them.
    234234        #
    235         elif isinstance(oValue, list) and len(oValue) > 0 and isinstance(oValue[0], ModelDataBase):
     235        elif isinstance(oValue, list) and oValue and isinstance(oValue[0], ModelDataBase):
    236236            oValue = copy.copy(oValue);
    237237            for i, _ in enumerate(oValue):
     
    269269        # Perform deep conversion on ModelDataBase object and lists of them.
    270270        #
    271         elif isinstance(oValue, list) and len(oValue) > 0 and isinstance(oValue[0], ModelDataBase):
     271        elif isinstance(oValue, list) and oValue and isinstance(oValue[0], ModelDataBase):
    272272            oValue = copy.copy(oValue);
    273273            for i, _ in enumerate(oValue):
     
    316316                                                    lMax = getattr(self, 'klMax_' + sAttr, None));
    317317        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.
    319319            (oNewValue, sError) = self.validateBool(oValue, aoNilValues = aoNilValues, fAllowNull = fAllowNull);
    320320        elif sPrefix == 'ts':
     
    743743    def validateListOfSomething(asValues, aoNilValues = tuple([[], None]), fAllowNull = True):
    744744        """ 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) == 0 and not fAllowNull):
     745        if asValues in aoNilValues  or  (not asValues and not fAllowNull):
    746746            return (asValues, None if fAllowNull else 'Mandatory.')
    747747
     
    750750
    751751        asValues = list(asValues); # copy the list.
    752         if len(asValues) > 0:
     752        if asValues:
    753753            oType = type(asValues[0]);
    754754            for i in range(1, len(asValues)):
     
    764764        (asValues, sError) = ModelDataBase.validateListOfSomething(asValues, aoNilValues, fAllowNull);
    765765
    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:
    767767            if not utils.isString(asValues[0]):
    768768                return (asValues, 'Invalid item data type.');
     
    793793        (asValues, sError) = ModelDataBase.validateListOfSomething(asValues, aoNilValues, fAllowNull);
    794794
    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:
    796796            for i, _ in enumerate(asValues):
    797797                sValue = asValues[i];
     
    10891089
    10901090    def testNullConversion(self):
    1091         if len(self.aoSamples[0].getDataAttributes()) == 0:
     1091        if not self.aoSamples[0].getDataAttributes():
    10921092            return;
    10931093        for oSample in self.aoSamples:
     
    12611261        else:
    12621262            assert False;
    1263         if len(oCriterion.aoSelected) > 0:
     1263        if oCriterion.aoSelected:
    12641264            oCriterion.sState = FilterCriterion.ksState_Selected;
    12651265        else:
  • trunk/src/VBox/ValidationKit/testmanager/core/build.py

    r65258 r65980  
    278278                          , (idBuildCategory,))
    279279        aaoRows = self._oDb.fetchAll()
    280         if len(aaoRows) == 0:
     280        if not aaoRows:
    281281            return None;
    282282        if len(aaoRows) != 1:
     
    307307                          ));
    308308        aaoRows = self._oDb.fetchAll();
    309         if len(aaoRows) == 0:
     309        if not aaoRows:
    310310            return None;
    311311        if len(aaoRows) > 1:
     
    323323        # Check BuildCategoryData before do anything
    324324        dDataErrors = oData.validateAndConvert(self._oDb, oData.ksValidateFor_Add);
    325         if len(dDataErrors) > 0:
     325        if dDataErrors:
    326326            raise TMInvalidData('Invalid data passed to addBuildCategory(): %s' % (dDataErrors,));
    327327
     
    432432        for sBinary in self.sBinaries.split(','):
    433433            sBinary = sBinary.strip();
    434             if len(sBinary) == 0:
     434            if not sBinary:
    435435                continue;
    436436            # Same URL tests as in webutils.downloadFile().
     
    593593        #
    594594        dErrors = oData.validateAndConvert(self._oDb, oData.ksValidateFor_Edit);
    595         if len(dErrors) > 0:
     595        if dErrors:
    596596            raise TMInvalidData('editEntry invalid input: %s' % (dErrors,));
    597597        oOldData = BuildData().initFromDbWithId(self._oDb, oData.idBuild);
     
    741741        for i in range(len(oBuildEx.oCat.asOsArches)):
    742742            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]:
    744744                raise self._oDb.integrityException('Bad build asOsArches value: %s (idBuild=%s idBuildCategory=%s)'
    745745                                                   % (oBuildEx.asOsArches[i], oBuildEx.idBuild, oBuildEx.idBuildCategory));
  • trunk/src/VBox/ValidationKit/testmanager/core/buildblacklist.py

    r65226 r65980  
    193193        assert isinstance(oData, BuildBlacklistData);
    194194        dErrors = oData.validateAndConvert(self._oDb, oData.ksValidateFor_Edit);
    195         if len(dErrors) > 0:
     195        if dErrors:
    196196            raise TMInvalidData('editEntry invalid input: %s' % (dErrors,));
    197197
  • trunk/src/VBox/ValidationKit/testmanager/core/buildsource.py

    r65226 r65980  
    213213        #
    214214        dErrors = oData.validateAndConvert(self._oDb, oData.ksValidateFor_Add);
    215         if len(dErrors) > 0:
     215        if dErrors:
    216216            raise TMInvalidData('addEntry invalid input: %s' % (dErrors,));
    217217        self._assertUnique(oData, None);
     
    255255        #
    256256        dErrors = oData.validateAndConvert(self._oDb, oData.ksValidateFor_Edit);
    257         if len(dErrors) > 0:
     257        if dErrors:
    258258            raise TMInvalidData('addEntry invalid input: %s' % (dErrors,));
    259259        self._assertUnique(oData, oData.idBuildSrc);
     
    388388
    389389        # Types
    390         if oBuildSource.asTypes is not None  and  len(oBuildSource.asTypes) > 0:
     390        if oBuildSource.asTypes is not None  and  oBuildSource.asTypes:
    391391            if len(oBuildSource.asTypes) == 1:
    392392                sExtraConditions += oCursor.formatBindArgs('   AND BuildCategories.sType = %s', (oBuildSource.asTypes[0],));
     
    398398
    399399        # 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:
    401401            sExtraConditions += oCursor.formatBindArgs('  AND BuildCategories.asOsArches && %s', (oBuildSource.asOsArches,));
    402402
  • trunk/src/VBox/ValidationKit/testmanager/core/db.py

    r62484 r65980  
    3434import os;
    3535import sys;
    36 import psycopg2;
    37 import psycopg2.extensions;
     36import psycopg2;                            # pylint: disable=import-error
     37import psycopg2.extensions;                 # pylint: disable=import-error
    3838
    3939# Validation Kit imports.
     
    431431                oRc = self.executeInternal(oCursor, sInsertSql + 'VALUES' + ', '.join(asValues), None, sCallerName);
    432432                asValues = [];
    433         if len(asValues) > 0:
     433        if asValues:
    434434            oRc = self.executeInternal(oCursor, sInsertSql + 'VALUES' + ', '.join(asValues), None, sCallerName);
    435435        return oRc
  • trunk/src/VBox/ValidationKit/testmanager/core/dbobjcache.py

    r62484 r65980  
    156156                if iRevision not in dRepo:
    157157                    aiFiltered.append(iRevision);
    158         if len(aiFiltered) > 0:
     158        if aiFiltered:
    159159            self._oDb.execute('SELECT *\n'
    160160                              'FROM   VcsRevisions\n'
  • trunk/src/VBox/ValidationKit/testmanager/core/failurecategory.py

    r65226 r65980  
    179179
    180180        # 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:
    182182            oNew = aoRows[-1];
    183183            aoEntries.append(ChangeLogEntry(oNew.uidAuthor, None, oNew.tsEffective, oNew.tsExpire, oNew, None, []));
     
    233233        assert isinstance(oData, FailureCategoryData);
    234234        dErrors = oData.validateAndConvert(self._oDb, oData.ksValidateFor_Add);
    235         if len(dErrors) > 0:
     235        if dErrors:
    236236            raise TMInvalidData('editEntry invalid input: %s' % (dErrors,));
    237237
     
    254254        assert isinstance(oData, FailureCategoryData);
    255255        dErrors = oData.validateAndConvert(self._oDb, oData.ksValidateFor_Edit);
    256         if len(dErrors) > 0:
     256        if dErrors:
    257257            raise TMInvalidData('editEntry invalid input: %s' % (dErrors,));
    258258
     
    285285                          , (idFailureCategory,));
    286286        aaoRows = self._oDb.fetchAll();
    287         if len(aaoRows) > 0:
     287        if aaoRows:
    288288            raise TMRowInUse('Cannot remove failure reason category %u because its being used by: %s'
    289289                             % (idFailureCategory, ', '.join(aoRow[0] for aoRow in aaoRows),));
  • trunk/src/VBox/ValidationKit/testmanager/core/failurereason.py

    r65226 r65980  
    316316
    317317        # 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:
    319319            oNew = aoRows[-1];
    320320            aoEntries.append(ChangeLogEntry(oNew.uidAuthor, None, oNew.tsEffective, oNew.tsExpire, oNew, None, []));
     
    348348        #
    349349        dErrors = oData.validateAndConvert(self._oDb, oData.ksValidateFor_Add);
    350         if len(dErrors) > 0:
     350        if dErrors:
    351351            raise TMInvalidData('addEntry invalid input: %s' % (dErrors,));
    352352
     
    369369        assert isinstance(oData, FailureReasonData);
    370370        dErrors = oData.validateAndConvert(self._oDb, oData.ksValidateFor_Edit);
    371         if len(dErrors) > 0:
     371        if dErrors:
    372372            raise TMInvalidData('editEntry invalid input: %s' % (dErrors,));
    373373
     
    405405                          , (idFailureReason, idFailureReason,));
    406406        aaoRows = self._oDb.fetchAll();
    407         if len(aaoRows) > 0:
     407        if aaoRows:
    408408            raise TMRowInUse('Cannot remove failure reason %u because its being used by: %s'
    409409                             % (idFailureReason, ', '.join(aoRow[0] for aoRow in aaoRows),));
  • trunk/src/VBox/ValidationKit/testmanager/core/globalresource.py

    r65226 r65980  
    272272        """
    273273        # Quit quickly if there is nothing to alloocate.
    274         if len(aoGlobalRsrcs) == 0:
     274        if not aoGlobalRsrcs:
    275275            return True;
    276276
  • trunk/src/VBox/ValidationKit/testmanager/core/report.py

    r65430 r65980  
    143143            sWhere += self._oDb.formatBindArgs(' = %s\n', (self.aidSubjects[0],));
    144144        else:
    145             assert len(self.aidSubjects) > 0;
     145            assert self.aidSubjects;
    146146            sWhere += self._oDb.formatBindArgs(' IN (%s', (self.aidSubjects[0],));
    147147            for i in range(1, len(self.aidSubjects)):
     
    11301130            if len(self.aidTestBoxes) == 1:
    11311131                sQuery += '     AND TestSets.idTestBox = %u\n' % (self.aidTestBoxes[0],);
    1132             elif len(self.aidTestBoxes) > 0:
     1132            elif self.aidTestBoxes:
    11331133                sQuery += '     AND TestSets.idTestBox IN (' + ','.join([str(i) for i in self.aidTestBoxes]) + ')\n';
    11341134
    11351135            if len(self.aidBuildCats) == 1:
    11361136                sQuery += '     AND TestSets.idBuildCategory = %u\n' % (self.aidBuildCats[0],);
    1137             elif len(self.aidBuildCats) > 0:
     1137            elif self.aidBuildCats:
    11381138                sQuery += '     AND TestSets.idBuildCategory IN (' + ','.join([str(i) for i in self.aidBuildCats]) + ')\n';
    11391139
    11401140            if len(self.aidTestCases) == 1:
    11411141                sQuery += '     AND TestSets.idTestCase = %u\n' % (self.aidTestCases[0],);
    1142             elif len(self.aidTestCases) > 0:
     1142            elif self.aidTestCases:
    11431143                sQuery += '     AND TestSets.idTestCase IN (' + ','.join([str(i) for i in self.aidTestCases]) + ')\n';
    11441144
     
    12441244        # 2. Query all the testbox data in one go.
    12451245        aoRet = [];
    1246         if len(asIdGenTestBoxes) > 0:
     1246        if asIdGenTestBoxes:
    12471247            self._oDb.execute('SELECT   *\n'
    12481248                              'FROM     TestBoxesWithStrings\n'
     
    12671267
    12681268        sSelectedBuildCats = '';
    1269         if len(self.aidBuildCats) > 0:
     1269        if self.aidBuildCats:
    12701270            sSelectedBuildCats = '   OR idBuildCategory IN (' + ','.join([str(i) for i in self.aidBuildCats]) + ')\n';
    12711271
  • trunk/src/VBox/ValidationKit/testmanager/core/schedgroup.py

    r65226 r65980  
    376376
    377377            dErrors = oNewMember.validateAndConvert(oDb, ModelDataBase.ksValidateFor_Other);
    378             if len(dErrors) > 0:
     378            if dErrors:
    379379                asErrors.append(str(dErrors));
    380380
    381         if len(asErrors) == 0:
     381        if not asErrors:
    382382            for i, _ in enumerate(aoNewMembers):
    383383                idTestGroup = aoNewMembers[i];
     
    387387                        break;
    388388
    389         return (aoNewMembers, None if len(asErrors) == 0 else '<br>\n'.join(asErrors));
     389        return (aoNewMembers, None if not asErrors else '<br>\n'.join(asErrors));
    390390
    391391    def _validateAndConvertWorker(self, asAllowNullAttributes, oDb, enmValidateFor = ModelDataBase.ksValidateFor_Other):
     
    471471        #
    472472        dDataErrors = oData.validateAndConvert(self._oDb, oData.ksValidateFor_Add);
    473         if len(dDataErrors) > 0:
     473        if dDataErrors:
    474474            raise TMInvalidData('Invalid data passed to addEntry: %s' % (dDataErrors,));
    475475        if self.exists(oData.sName):
     
    515515        #
    516516        dErrors = oData.validateAndConvert(self._oDb, oData.ksValidateFor_Edit);
    517         if len(dErrors) > 0:
     517        if dErrors:
    518518            raise TMInvalidData('editEntry got invalid data: %s' % (dErrors,));
    519519        self._assertUnique(oData.sName, oData.idSchedGroup);
     
    572572        # associated testboxes or testgroups.
    573573        #
    574         if len(oData.aoTestBoxes) > 0:
     574        if oData.aoTestBoxes:
    575575            if fCascade is not True:
    576576                # Complain about there being associated testboxes.
     
    587587
    588588                oData = SchedGroupDataEx().initFromDbWithId(self._oDb, idSchedGroup);
    589                 if len(oData.aoTestBoxes) != 0:
     589                if oData.aoTestBoxes:
    590590                    raise TMRowInUse('More testboxes was added to the scheduling group as we were trying to delete it.');
    591591
  • trunk/src/VBox/ValidationKit/testmanager/core/schedulerbase.py

    r65732 r65980  
    103103        # Associate extra members with the base data.
    104104        #
    105         if len(self.aoTestGroups) > 0:
     105        if self.aoTestGroups:
    106106            # Prep the test groups.
    107107            for oTestGroup in self.aoTestGroups:
     
    125125            # in both directions.
    126126            oTestGroup = self.aoTestGroups[0];
    127             oTestCase  = self.aoTestCases[0] if len(self.aoTestCases) > 0 else None;
     127            oTestCase  = self.aoTestCases[0] if self.aoTestCases else None;
    128128            for oArgVariation in self.aoArgsVariations:
    129129                if oTestGroup.idTestGroup != oArgVariation.idTestGroup:
     
    137137
    138138        else:
    139             assert len(self.aoTestCases)      == 0;
    140             assert len(self.aoArgsVariations) == 0;
     139            assert not self.aoTestCases;
     140            assert not self.aoArgsVariations;
    141141        # done.
    142142
     
    198198        for oTestGroup in self.aoTestGroups:
    199199            for oTestCase in oTestGroup.aoTestCases:
    200                 if len(oTestCase.aidPreReqs) == 0:
     200                if not oTestCase.aidPreReqs:
    201201                    continue;
    202202
    203203                # Stupid recursion code using special stack(s).
    204                 aiIndexes = [(oTestCase, 0), ];
     204                aiIndexes = [[oTestCase, 0], ];
    205205                aidChain  = [oTestCase.idTestGroup,];
    206                 while len(aiIndexes) > 0:
     206                while aiIndexes:
    207207                    (oCur, i) = aiIndexes[-1];
    208208                    if i >= len(oCur.aidPreReqs):
     
    222222                                                 'TestCase #%s prerequisite #%s creates a cycle!'
    223223                                                 % (oTestCase.idTestCase, idPreReq));
    224                         elif len(oDep.aiPreReqs) == 0:
     224                        elif not oDep.aiPreReqs:
    225225                            pass;
    226226                        elif len(aidChain) >= 10:
     
    228228                                                 'TestCase #%s prerequisite chain is too long!'  % (oTestCase.idTestCase,));
    229229                        else:
    230                             aiIndexes.append((oDep, 0));
     230                            aiIndexes.append([oDep, 0]);
    231231                            aidChain.append(idPreReq);
    232232
     
    238238        Note! Don't call this before checking for dependency cycles!
    239239        """
    240         if len(self.aoTestGroups) == 0:
     240        if not self.aoTestGroups:
    241241            return;
    242242
     
    252252            iGrpPrio = oTestGroup.iSchedPriority;
    253253
    254             if len(oTestGroup.aoTestCases) > 0:
     254            if oTestGroup.aoTestCases:
    255255                iTstPrio = oTestGroup.aoTestCases[0];
    256256                for oTestCase in oTestGroup.aoTestCases:
     
    283283            while i < len(oTestGroup.aoTestCases):
    284284                oTestCase = oTestGroup.aoTestCases[i];
    285                 if len(oTestCase.aidPreReqs) > 0:
     285                if oTestCase.aidPreReqs:
    286286                    for idPreReq in oTestCase.aidPreReqs:
    287287                        iPreReq = oTestGroup.aoTestCases.index(oTestGroup.dTestCases[idPreReq]);
     
    472472        def setupSource(self, oDb, idBuildSrc, sOs, sCpuArch, tsNow):
    473473            """ Configures the build cursor for the cache. """
    474             if len(self.aoEntries) == 0 and self.oCursor is None:
     474            if not self.aoEntries and self.oCursor is None:
    475475                oBuildSource = BuildSourceData().initFromDbWithId(oDb, idBuildSrc, tsNow);
    476476                self.oCursor = BuildSourceLogic(oDb).openBuildCursor(oBuildSource, sOs, sCpuArch, tsNow);
     
    594594        aoErrors = oData.checkForGroupDepCycles();
    595595        aoErrors.extend(oData.checkForMissingTestCaseDeps());
    596         if len(aoErrors) == 0:
     596        if not aoErrors:
    597597            oData.deepTestGroupSort();
    598598
     
    609609            #
    610610            aoItems = list();
    611             if len(oData.aoArgsVariations) > 0:
     611            if oData.aoArgsVariations:
    612612                aoItems = self._recreateQueueItems(oData);
    613613                self.msgDebug('len(aoItems)=%s' % (len(aoItems),));
    614614                #for i in range(len(aoItems)):
    615615                #    self.msgDebug('aoItems[%2d]=%s' % (i, aoItems[i]));
    616             if len(aoItems) > 0:
     616            if aoItems:
    617617                self._oDb.execute('SELECT offQueue FROM SchedQueues WHERE idSchedGroup = %s ORDER BY idItem LIMIT 1'
    618618                                  , (self._oSchedGrpData.idSchedGroup,));
     
    653653                                            oItem.idGenTestCaseArgs,
    654654                                            oItem.idTestGroup,
    655                                             oItem.aidTestGroupPreReqs if len(oItem.aidTestGroupPreReqs) > 0 else None,
     655                                            oItem.aidTestGroupPreReqs if oItem.aidTestGroupPreReqs else None,
    656656                                            oItem.bmHourlySchedule,
    657657                                            oItem.cMissingGangMembers
     
    696696
    697697            (aoErrors, asMessages) = oScheduler.recreateQueueWorker();
    698             if len(aoErrors) == 0:
     698            if not aoErrors:
    699699                SystemLogLogic(oDb).addEntry(SystemLogData.ksEvent_SchedQueueRecreate,
    700700                                             'User #%d recreated sched queue #%d.' % (uidAuthor, idSchedGroup,));
     
    10211021        # Create a SQL values table out of them.
    10221022        sPreReqSet = ''
    1023         if len(dPreReqs) > 0:
     1023        if dPreReqs:
    10241024            for idPreReq in sorted(dPreReqs):
    10251025                sPreReqSet += ', (' + str(idPreReq) + ')';
     
    10461046            # satisfied if there are any failure runs.
    10471047            #
    1048             if len(sPreReqSet) > 0:
     1048            if sPreReqSet:
    10491049                fDecision = oEntry.getPreReqDecision(sPreReqSet);
    10501050                if fDecision is None:
     
    13031303            iWorkItem = 0;
    13041304
    1305         elif len(oTestBoxDataEx.aoInSchedGroups) > 0:
     1305        elif oTestBoxDataEx.aoInSchedGroups:
    13061306            # Construct priority table of currently enabled scheduling groups.
    13071307            aaoList1 = [];
  • trunk/src/VBox/ValidationKit/testmanager/core/schedulerbeci.py

    r62484 r65980  
    8888                    for oTestCase in oTestGroup.aoTestCases:
    8989                        #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:
    9191                            # Get variation.
    9292                            iNext = oTestCase.iNextVariation;
  • trunk/src/VBox/ValidationKit/testmanager/core/testbox.py

    r65425 r65980  
    644644            oInSchedGroup.idTestBox = self.idTestBox;
    645645            dCurErrors = oInSchedGroup.validateAndConvert(oDb, ModelDataBase.ksValidateFor_Other);
    646             if len(dCurErrors) == 0:
     646            if not dCurErrors:
    647647                pass; ## @todo figure out the ID?
    648648            else:
     
    663663                    break;
    664664
    665         return (aoNewValues, dErrors if len(dErrors) > 0 else None);
     665        return (aoNewValues, dErrors if dErrors else None);
    666666
    667667
     
    768768        from testmanager.core.testboxstatus import TestBoxStatusData;
    769769
    770         if aiSortColumns is None or len(aiSortColumns) == 0:
     770        if not aiSortColumns:
    771771            aiSortColumns = [self.kiSortColumn_sName,];
    772772
     
    846846
    847847        # 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:
    849849            oNew = aoRows[-1];
    850850            aoEntries.append(ChangeLogEntry(oNew.uidAuthor, None, oNew.tsEffective, oNew.tsExpire, oNew, None, []));
     
    862862        """
    863863        dDataErrors = oData.validateAndConvert(self._oDb, enmValidateFor);
    864         if len(dDataErrors) > 0:
     864        if dDataErrors:
    865865            raise TMInvalidData('TestBoxLogic.addEntry: %s' % (dDataErrors,));
    866866        if isinstance(oData, TestBoxDataEx):
    867             if len(oData.aoInSchedGroups):
     867            if oData.aoInSchedGroups:
    868868                sSchedGrps = ', '.join('(%s)' % oCur.idSchedGroup for oCur in oData.aoInSchedGroups);
    869869                self._oDb.execute('SELECT   SchedGroupIDs.idSchedGroup\n'
     
    874874                                  'WHERE    SchedGroups.idSchedGroup IS NULL\n');
    875875                aaoRows = self._oDb.fetchAll();
    876                 if len(aaoRows) > 0:
     876                if aaoRows:
    877877                    raise TMInvalidData('TestBoxLogic.addEntry missing scheduling groups: %s'
    878878                                        % (', '.join(str(aoRow[0]) for aoRow in aaoRows),));
  • trunk/src/VBox/ValidationKit/testmanager/core/testboxcontroller.py

    r65335 r65980  
    372372
    373373        # Null conversions for new parameters.
    374         if len(sReport) == 0:
     374        if not sReport:
    375375            sReport = None;
    376         if len(sCpuName) == 0:
     376        if not sCpuName:
    377377            sCpuName = None;
    378378        if lCpuRevision <= 0:
     
    657657        #
    658658        sBody = self._getStringParam(constants.tbreq.LOG_PARAM_BODY, fStrip = False);
    659         if len(sBody) == 0:
     659        if not sBody:
    660660            return self._resultResponse(constants.tbresp.STATUS_NACK);
    661661        self._checkForUnknownParameters();
     
    753753        sXml = self._getStringParam(constants.tbreq.XML_RESULT_PARAM_BODY, fStrip = False);
    754754        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.
    756756            return self._resultResponse(constants.tbresp.STATUS_ACK);
    757757
  • trunk/src/VBox/ValidationKit/testmanager/core/testcase.py

    r65226 r65980  
    298298        Test Case depends on
    299299        """
    300         if len(aTestCaseDependencyData) == 0:
     300        if not aTestCaseDependencyData:
    301301            return []
    302302
     
    889889        else:
    890890            assert sAttr == 'aoTestCaseArgs';
    891             if self.aoTestCaseArgs is None or len(self.aoTestCaseArgs) == 0:
     891            if not self.aoTestCaseArgs:
    892892                return (None, 'The testcase requires at least one argument variation to be valid.');
    893893
     
    899899                oVar.idTestCase = self.idTestCase;
    900900                dCurErrors = oVar.validateAndConvert(oDb, ModelDataBase.ksValidateFor_Other);
    901                 if len(dCurErrors) == 0:
     901                if not dCurErrors:
    902902                    pass; ## @todo figure out the ID?
    903903                else:
     
    919919                        break;
    920920
    921             return (aoNewValues, dErrors if len(dErrors) > 0 else None);
    922 
    923         return (aoNewValues, None if len(asErrors) == 0 else ' <br>'.join(asErrors));
     921            return (aoNewValues, dErrors if dErrors else None);
     922
     923        return (aoNewValues, None if not asErrors else ' <br>'.join(asErrors));
    924924
    925925    def _validateAndConvertWorker(self, asAllowNullAttributes, oDb, enmValidateFor = ModelDataBase.ksValidateFor_Other):
     
    928928        # Validate dependencies a wee bit for paranoid reasons. The scheduler
    929929        # queue generation code does the real validation here!
    930         if len(dErrors) == 0 and self.idTestCase is not None:
     930        if not dErrors and self.idTestCase is not None:
    931931            for oDep in self.aoDepTestCases:
    932932                if oDep.idTestCase == self.idTestCase:
     
    11261126
    11271127        # 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:
    11291129            oNew = aoRows[-1];
    11301130            aoEntries.append(ChangeLogEntry(oNew.uidAuthor, None,
     
    11451145        assert isinstance(oData, TestCaseDataEx);
    11461146        dErrors = oData.validateAndConvert(self._oDb, oData.ksValidateFor_Add);
    1147         if len(dErrors) > 0:
     1147        if dErrors:
    11481148            raise TMInvalidData('Invalid input data: %s' % (dErrors,));
    11491149
     
    11901190        assert isinstance(oData, TestCaseDataEx);
    11911191        dErrors = oData.validateAndConvert(self._oDb, oData.ksValidateFor_Edit);
    1192         if len(dErrors) > 0:
     1192        if dErrors:
    11931193            raise TMInvalidData('Invalid input data: %s' % (dErrors,));
    11941194
     
    12281228            if idDep in aidNewDeps:
    12291229                asKeepers.append(str(idDep));
    1230         if len(asKeepers) > 0:
     1230        if asKeepers:
    12311231            sQuery += '     AND idTestCasePreReq NOT IN (' + ', '.join(asKeepers) + ')\n';
    12321232        self._oDb.execute(sQuery);
     
    12531253            if idDep in aidNewDeps:
    12541254                asKeepers.append(str(idDep));
    1255         if len(asKeepers) > 0:
     1255        if asKeepers:
    12561256            sQuery = '     AND idGlobalRsrc NOT IN (' + ', '.join(asKeepers) + ')\n';
    12571257        self._oDb.execute(sQuery);
     
    12761276        for oNewVar in oData.aoTestCaseArgs:
    12771277            asKeepers.append(self._oDb.formatBindArgs('%s', (oNewVar.sArgs,)));
    1278         if len(asKeepers) > 0:
     1278        if asKeepers:
    12791279            sQuery += '    AND  sArgs NOT IN (' + ', '.join(asKeepers) + ')\n';
    12801280        self._oDb.execute(sQuery);
  • trunk/src/VBox/ValidationKit/testmanager/core/testcaseargs.py

    r65533 r65980  
    273273
    274274        # Create a set of global resource IDs.
    275         if len(oDataEx.aoGlobalRsrc) == 0:
     275        if not oDataEx.aoGlobalRsrc:
    276276            return True;
    277277        asIdRsrcs = [str(oDep.idGlobalRsrc) for oDep, _ in oDataEx.aoGlobalRsrc];
  • trunk/src/VBox/ValidationKit/testmanager/core/testgroup.py

    r65226 r65980  
    353353
    354354            dErrors = oNewMember.validateAndConvert(oDb, ModelDataBase.ksValidateFor_Other);
    355             if len(dErrors) > 0:
     355            if dErrors:
    356356                asErrors.append(str(dErrors));
    357357
    358         if len(asErrors) == 0:
     358        if not asErrors:
    359359            for i, _ in enumerate(aoNewMembers):
    360360                idTestCase = aoNewMembers[i];
     
    364364                        break;
    365365
    366         return (aoNewMembers, None if len(asErrors) == 0 else '<br>\n'.join(asErrors));
     366        return (aoNewMembers, None if not asErrors else '<br>\n'.join(asErrors));
    367367
    368368
     
    419419        assert isinstance(oData, TestGroupDataEx);
    420420        dErrors = oData.validateAndConvert(self._oDb, oData.ksValidateFor_Add);
    421         if len(dErrors) > 0:
     421        if dErrors:
    422422            raise TMInvalidData('addEntry invalid input: %s' % (dErrors,));
    423423        self._assertUniq(oData, None);
     
    453453        assert isinstance(oData, TestGroupDataEx);
    454454        dErrors = oData.validateAndConvert(self._oDb, oData.ksValidateFor_Edit);
    455         if len(dErrors) > 0:
     455        if dErrors:
    456456            raise TMInvalidData('editEntry invalid input: %s' % (dErrors,));
    457457        self._assertUniq(oData, oData.idTestGroup);
     
    502502                                          '   AND tsExpire    = \'infinity\'::TIMESTAMP\n'
    503503                                          , ( 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]),);
    506506        self._oDb.execute(sQuery);
    507507
     
    527527                              , ( idTestGroup, ));
    528528            aoGroups = self._oDb.fetchAll();
    529             if len(aoGroups) > 0:
     529            if aoGroups:
    530530                asGroups = ['%s (#%d)' % (sName, idSchedGroup) for idSchedGroup, sName in aoGroups];
    531531                raise TMRowInUse('Test group #%d is member of one or more scheduling groups: %s'
  • trunk/src/VBox/ValidationKit/testmanager/core/testresultfailures.py

    r62484 r65980  
    353353
    354354        # 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:
    356356            aoNew    = aaoRows[-1];
    357357            tsExpire = aaoRows[-1 - 1][0] if len(aaoRows) > 1 else aoNew[2].tsExpire;
     
    387387        assert isinstance(oData, TestResultFailureData);
    388388        dErrors = oData.validateAndConvert(self._oDb, oData.ksValidateFor_AddForeignId);
    389         if len(dErrors) > 0:
     389        if dErrors:
    390390            raise TMInvalidData('editEntry invalid input: %s' % (dErrors,));
    391391
     
    416416        assert isinstance(oData, TestResultFailureData);
    417417        dErrors = oData.validateAndConvert(self._oDb, oData.ksValidateFor_Edit);
    418         if len(dErrors) > 0:
     418        if dErrors:
    419419            raise TMInvalidData('editEntry invalid input: %s' % (dErrors,));
    420420
  • trunk/src/VBox/ValidationKit/testmanager/core/testresults.py

    r65866 r65980  
    16841684                if aoRow[0] in dLeft:
    16851685                    del dLeft[aoRow[0]];
    1686             if len(dLeft) > 0:
     1686            if dLeft:
    16871687                if fIdIsName:
    16881688                    for idMissing in dLeft:
     
    17191719                oMain.cTimes += aoRow[4];
    17201720
    1721             if len(dLeft) > 0:
     1721            if dLeft:
    17221722                pass; ## @todo
    17231723
     
    20902090
    20912091        aaoRows = self._oDb.fetchAll();
    2092         if len(aaoRows) == 0:
     2092        if not aaoRows:
    20932093            raise TMRowNotFound('No test results for idTestSet=%d.' % (idTestSet,));
    20942094
     
    25572557        # Validate string attributes.
    25582558        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]:
    25602560                return 'Element %s has an empty %s attribute value.' % (sName, sAttr,);
    25612561
     
    26222622        dAttribs = {};
    26232623        sElement = sElement.strip();
    2624         while len(sElement) > 0:
     2624        while sElement:
    26252625            # Extract attribute name.
    26262626            off = sElement.find('=');
     
    26782678        """
    26792679        if sName == 'Test':
    2680             iNestingDepth = aoStack[0].iNestingDepth + 1 if len(aoStack) > 0 else 0;
     2680            iNestingDepth = aoStack[0].iNestingDepth + 1 if aoStack else 0;
    26812681            aoStack.insert(0, self._newTestResult(idTestResultParent = aoStack[0].idTestResult, idTestSet = idTestSet,
    26822682                                                  tsCreated = dAttribs['timestamp'], sName = dAttribs['name'],
     
    27482748        """
    27492749        aoStack    = self._getResultStack(idTestSet); # [0] == top; [-1] == bottom.
    2750         if len(aoStack) == 0:
     2750        if not aoStack:
    27512751            return ('No open results', True);
    27522752        self._oDb.dprint('** processXmlStream len(aoStack)=%s' % (len(aoStack),));
     
    27602760        fExpectCloseTest = False;
    27612761        sXml = sXml.strip();
    2762         while len(sXml) > 0:
     2762        while sXml:
    27632763            if sXml.startswith('</Test>'): # Only closing tag.
    27642764                offNext = len('</Test>');
     
    28212821        if sError is None and fExpectCloseTest:
    28222822            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:
    28242824            sError = 'Expected </PopHint> before the end of the XML section.'
    2825         if len(aaiHints) > 0:
     2825        if aaiHints:
    28262826            self._doPopHint(aoStack, aaiHints[-1][0], dCounts, idTestSet);
    28272827
     
    28332833                                               'idTestSet=%s idTestResult=%s XML="%s" %s'
    28342834                                               % ( idTestSet,
    2835                                                    aoStack[0].idTestResult if len(aoStack) > 0 else -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)],
    28372837                                                   sError, ),
    28382838                                               cHoursRepeat = 6, fCommit = True);
  • trunk/src/VBox/ValidationKit/testmanager/core/testset.py

    r65317 r65980  
    377377                          , (idTestSet, TestSetData.ksTestStatus_Running, oData.idTestResult));
    378378        aaoRows = self._oDb.fetchAll();
    379         if len(aaoRows):
     379        if aaoRows:
    380380            idStr = self.strTabString('Unclosed test result', fCommit = fCommit);
    381381            for aoRow in aaoRows:
  • trunk/src/VBox/ValidationKit/testmanager/core/vcsrevisions.py

    r65226 r65980  
    143143        if len(aaoRows) == 1:
    144144            return VcsRevisionData().initFromDbRow(aaoRows[0]);
    145         if len(aaoRows) != 0:
     145        if aaoRows:
    146146            raise TMExceptionBase('VcsRevisions has a primary key problem: %u duplicates' % (len(aaoRows),));
    147147        return None
     
    160160        # Check VcsRevisionData before do anything
    161161        dDataErrors = oData.validateAndConvert(self._oDb, oData.ksValidateFor_Add);
    162         if len(dDataErrors) > 0:
     162        if dDataErrors:
    163163            raise TMExceptionBase('Invalid data passed to addVcsRevision(): %s' % (dDataErrors,));
    164164
  • trunk/src/VBox/ValidationKit/testmanager/core/webservergluebase.py

    r65032 r65980  
    260260        if self._sBodyType is None:
    261261            self._sBodyType = 'html';
    262         elif self._sBodyType is not 'html':
     262        elif self._sBodyType != 'html':
    263263            raise WebServerGlueException('Cannot use writeParameter when body type is "%s"' % (self._sBodyType, ));
    264264
     
    277277        if self._sBodyType is None:
    278278            self._sBodyType = 'html';
    279         elif self._sBodyType is not 'html':
     279        elif self._sBodyType != 'html':
    280280            raise WebServerGlueException('Cannot use writeParameter when body type is "%s"' % (self._sBodyType, ));
    281281
     
    304304            self._sBodyType = 'form';
    305305
    306         elif self._sBodyType is not 'form':
     306        elif self._sBodyType != 'form':
    307307            raise WebServerGlueException('Cannot use writeParams when body type is "%s"' % (self._sBodyType, ));
    308308
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette