VirtualBox

Ignore:
Timestamp:
Feb 10, 2023 6:01:38 PM (2 years ago)
Author:
vboxsync
Message:

testmanager/status.py: The enmStatus in the select result is either None or a valid TestStatus_T value, so a simple check for None suffices in testbox_data_processing. In dict_update it isn't needed to check if enmStatus is None anymore. Since dictionaries are passed by reference, dict_update doesn't need to return the target dictionary. Misc style cleanups. bugref:10364

File:
1 edited

Legend:

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

    r98536 r98537  
    6464
    6565def testbox_data_processing(oDb):
    66     testboxes_dict = {}
     66    dTestBoxes = {}
    6767    while True:
    68         line = oDb.fetchOne();
    69         if line is None:
     68        # Fetch the next row and unpack it.
     69        aoRow = oDb.fetchOne();
     70        if aoRow is None:
    7071            break;
    71         testbox_name = line[0]
    72         test_result = line[1]
    73         oTimeDeltaSinceStarted = line[2]
    74         test_box_os = line[3]
    75         test_sched_group = line[4]
    76 
    77         # idle testboxes might have an assigned testsets, skipping them
    78         if test_result not in g_kdTestStatuses:
    79             continue
    80 
    81         testboxes_dict = dict_update(testboxes_dict, testbox_name, test_result)
    82 
    83         if "testbox_os" not in testboxes_dict[testbox_name]:
    84             testboxes_dict[testbox_name].update({"testbox_os": test_box_os})
    85 
    86         if "sched_group" not in testboxes_dict[testbox_name]:
    87             testboxes_dict[testbox_name].update({"sched_group": test_sched_group})
    88         elif test_sched_group not in testboxes_dict[testbox_name]["sched_group"]:
    89             testboxes_dict[testbox_name]["sched_group"] += "," + test_sched_group
    90 
    91         if test_result == "running":
    92             testboxes_dict[testbox_name].update({"hours_running": timeDeltaToHours(oTimeDeltaSinceStarted)})
    93 
    94     return testboxes_dict;
    95 
    96 
    97 def os_results_separating(vb_dict, test_name, testbox_os, test_result):
    98     if testbox_os == "linux":
    99         dict_update(vb_dict, test_name + " / linux", test_result)
    100     elif testbox_os == "win":
    101         dict_update(vb_dict, test_name + " / windows", test_result)
    102     elif testbox_os == "darwin":
    103         dict_update(vb_dict, test_name + " / darwin", test_result)
    104     elif testbox_os == "solaris":
    105         dict_update(vb_dict, test_name + " / solaris", test_result)
     72        sTextBoxName           = aoRow[0];
     73        enmStatus              = aoRow[1];
     74        oTimeDeltaSinceStarted = aoRow[2];
     75        sTestBoxOs             = aoRow[3]
     76        sSchedGroupNames       = aoRow[4];
     77
     78        # Idle testboxes will not have an assigned test set, so enmStatus
     79        # will be None.  Skip these.
     80        if enmStatus:
     81            dict_update(dTestBoxes, sTextBoxName, enmStatus)
     82
     83            if "testbox_os" not in dTestBoxes[sTextBoxName]:
     84                dTestBoxes[sTextBoxName].update({"testbox_os": sTestBoxOs})
     85
     86            if "sched_group" not in dTestBoxes[sTextBoxName]:
     87                dTestBoxes[sTextBoxName].update({"sched_group": sSchedGroupNames})
     88            elif sSchedGroupNames not in dTestBoxes[sTextBoxName]["sched_group"]:
     89                dTestBoxes[sTextBoxName]["sched_group"] += "," + sSchedGroupNames
     90
     91            if enmStatus == "running":
     92                dTestBoxes[sTextBoxName].update({"hours_running": timeDeltaToHours(oTimeDeltaSinceStarted)})
     93
     94    return dTestBoxes;
     95
     96
     97def os_results_separating(dResult, sTestName, sTestBoxOs, enmStatus):
     98    if sTestBoxOs == "linux":
     99        dict_update(dResult, sTestName + " / linux", enmStatus)
     100    elif sTestBoxOs == "win":
     101        dict_update(dResult, sTestName + " / windows", enmStatus)
     102    elif sTestBoxOs == "darwin":
     103        dict_update(dResult, sTestName + " / darwin", enmStatus)
     104    elif sTestBoxOs == "solaris":
     105        dict_update(dResult, sTestName + " / solaris", enmStatus)
    106106    else:
    107         dict_update(vb_dict, test_name + " / other", test_result)
    108 
    109 
    110 # const/immutable.
     107        dict_update(dResult, sTestName + " / other", enmStatus)
     108
     109
     110## Template dictionary for new dTarget[] entries in dict_update.
     111# This _MUST_ include all values of the TestStatus_T SQL enum type.
    111112g_kdTestStatuses = {
    112113    'running': 0,
     
    120121}
    121122
    122 def dict_update(target_dict, key_name, test_result):
    123     if key_name not in target_dict:
    124         target_dict.update({key_name: g_kdTestStatuses.copy()})
    125     if test_result in g_kdTestStatuses:
    126         target_dict[key_name][test_result] += 1
    127     return target_dict
     123def dict_update(dTarget, sKeyName, enmStatus):
     124    if sKeyName not in dTarget:
     125        dTarget.update({sKeyName: g_kdTestStatuses.copy()})
     126    dTarget[sKeyName][enmStatus] += 1
    128127
    129128
Note: See TracChangeset for help on using the changeset viewer.

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