VirtualBox

Changeset 86950 in vbox


Ignore:
Timestamp:
Nov 20, 2020 7:21:17 PM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
141469
Message:

testmanager/status.py: optional output sorting (for debugging).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/testmanager/cgi/status.py

    r86941 r86950  
    160160
    161161
    162 def format_data(target_dict):
    163     content = ""
    164     for key in target_dict:
    165         if "hours_running" in target_dict[key].keys():
    166             content += "{};{};{} | running: {};{} | success: {} | skipped: {} | ".format(key,
    167                                                                                          target_dict[key]["testbox_os"],
    168                                                                                          target_dict[key]["sched_group"],
    169                                                                                          target_dict[key]["running"],
    170                                                                                          target_dict[key]["hours_running"],
    171                                                                                          target_dict[key]["success"],
    172                                                                                          target_dict[key]["skipped"],
    173                                                                                          )
    174         elif "testbox_os" in target_dict[key].keys():
    175             content += "{};{};{} | running: {} | success: {} | skipped: {} | ".format(key,
    176                                                                                       target_dict[key]["testbox_os"],
    177                                                                                       target_dict[key]["sched_group"],
    178                                                                                       target_dict[key]["running"],
    179                                                                                       target_dict[key]["success"],
    180                                                                                       target_dict[key]["skipped"],
    181                                                                                       )
     162def formatDataEntry(sKey, dEntry):
     163    # There are variations in the first and second "columns".
     164    if "hours_running" in dEntry:
     165        sRet = "%s;%s;%s | running: %s;%s" \
     166             % (sKey, dEntry["testbox_os"], dEntry["sched_group"], dEntry["running"], dEntry["hours_running"]);
     167    else:
     168        if "testbox_os" in dEntry:
     169            sRet = "%s;%s;%s" % (sKey, dEntry["testbox_os"], dEntry["sched_group"],);
    182170        else:
    183             content += "{} | running: {} | success: {} | skipped: {} | ".format(key,
    184                                                                                 target_dict[key]["running"],
    185                                                                                 target_dict[key]["success"],
    186                                                                                 target_dict[key]["skipped"],
    187                                                                                 )
    188         content += "bad-testbox: {} | aborted: {} | failure: {} | ".format(
    189                                                                             target_dict[key]["bad-testbox"],
    190                                                                             target_dict[key]["aborted"],
    191                                                                             target_dict[key]["failure"],
    192                                                                             )
    193         content += "timed-out: {} | rebooted: {} | \n".format(
    194                                                              target_dict[key]["timed-out"],
    195                                                              target_dict[key]["rebooted"],
    196                                                              )
    197     return content
     171            sRet = sKey;
     172        sRet += " | running: %s" % (dEntry["running"],)
     173
     174    # The rest is currently identical:
     175    sRet += " | success: %s | skipped: %s | bad-testbox: %s | aborted: %s | failure: %s | timed-out: %s | rebooted: %s | \n" \
     176          % (dEntry["success"], dEntry["skipped"], dEntry["bad-testbox"], dEntry["aborted"],
     177             dEntry["failure"], dEntry["timed-out"], dEntry["rebooted"],);
     178    return sRet;
     179
     180
     181def format_data(dData, fSorted):
     182    sRet = "";
     183    if not fSorted:
     184        for sKey in dData:
     185            sRet += formatDataEntry(sKey, dData[sKey]);
     186    else:
     187        for sKey in sorted(dData.keys()):
     188            sRet += formatDataEntry(sKey, dData[sKey]);
     189    return sRet;
    198190
    199191######
     
    274266        return iValue;
    275267
     268    def _getBoolParam(self, sName, fDefValue = None):
     269        """
     270        Gets a boolean parameter.
     271
     272        Raises exception if not found and no default is provided, or if not a
     273        valid boolean.
     274        """
     275        sValue = self._getStringParam(sName, [ 'True', 'true', '1', 'False', 'false', '0'], sDefValue = str(fDefValue));
     276        return sValue in ('True', 'true', '1',);
     277
    276278    def _checkForUnknownParameters(self):
    277279        """
     
    308310        #
    309311        cHoursBack = self._getIntParam('cHours', 1, 24*14, 12);
     312        fSorted   = self._getBoolParam('fSorted', False);
    310313        self._checkForUnknownParameters();
    311314
     
    393396    WHERE   TestBoxesWithStrings.tsExpire = 'infinity'::TIMESTAMP
    394397      AND   SchedGroupNames.idTestBox = TestBoxesWithStrings.idTestBox
    395 )''', (cHoursBack, cHoursBack,));
     398)
     399''', (cHoursBack, cHoursBack,));
    396400
    397401
     
    401405        dResult = testbox_data_processing(oDb);
    402406        self._oSrvGlue.setContentType('text/plain');
    403         self._oSrvGlue.write(format_data(dResult));
     407        self._oSrvGlue.write(format_data(dResult, fSorted));
    404408
    405409        return True;
     
    415419        sBranch = self._getStringParam('sBranch');
    416420        cHoursBack = self._getIntParam('cHours', 1, 24*14, 6); ## @todo why 6 hours here and 12 for test boxes?
     421        fSorted   = self._getBoolParam('fSorted', False);
    417422        self._checkForUnknownParameters();
    418423
     
    470475        # Format and output it.
    471476        self._oSrvGlue.setContentType('text/plain');
    472         self._oSrvGlue.write(format_data(dResult));
     477        self._oSrvGlue.write(format_data(dResult, fSorted));
    473478
    474479        return True;
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