VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/testmanager/batch/regen_sched_queues.py@ 106670

Last change on this file since 106670 was 106061, checked in by vboxsync, 5 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 4.5 KB
Line 
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3# $Id: regen_sched_queues.py 106061 2024-09-16 14:03:52Z vboxsync $
4# pylint: disable=line-too-long
5
6"""
7Interface used by the admin to regenerate scheduling queues.
8"""
9
10from __future__ import print_function;
11
12__copyright__ = \
13"""
14Copyright (C) 2012-2024 Oracle and/or its affiliates.
15
16This file is part of VirtualBox base platform packages, as
17available from https://www.virtualbox.org.
18
19This program is free software; you can redistribute it and/or
20modify it under the terms of the GNU General Public License
21as published by the Free Software Foundation, in version 3 of the
22License.
23
24This program is distributed in the hope that it will be useful, but
25WITHOUT ANY WARRANTY; without even the implied warranty of
26MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27General Public License for more details.
28
29You should have received a copy of the GNU General Public License
30along with this program; if not, see <https://www.gnu.org/licenses>.
31
32The contents of this file may alternatively be used under the terms
33of the Common Development and Distribution License Version 1.0
34(CDDL), a copy of it is provided in the "COPYING.CDDL" file included
35in the VirtualBox distribution, in which case the provisions of the
36CDDL are applicable instead of those of the GPL.
37
38You may elect to license modified versions of this file under the
39terms and conditions of either the GPL or the CDDL or both.
40
41SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
42"""
43__version__ = "$Revision: 106061 $"
44
45# Standard python imports
46import sys;
47import os;
48from optparse import OptionParser; # pylint: disable=deprecated-module
49
50# Add Test Manager's modules path
51g_ksTestManagerDir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))));
52sys.path.append(g_ksTestManagerDir);
53
54# Test Manager imports
55from testmanager.core.db import TMDatabaseConnection;
56from testmanager.core.schedulerbase import SchedulerBase;
57from testmanager.core.schedgroup import SchedGroupLogic;
58
59
60
61class RegenSchedQueues(object): # pylint: disable=too-few-public-methods
62 """
63 Regenerates all the scheduling queues.
64 """
65
66 def __init__(self):
67 """
68 Parse command line.
69 """
70
71 oParser = OptionParser();
72 oParser.add_option('-q', '--quiet', dest = 'fQuiet', action = 'store_true', default = False,
73 help = 'Quiet execution');
74 oParser.add_option('-u', '--uid', dest = 'uid', action = 'store', type = 'int', default = 1,
75 help = 'User ID to accredit with this job');
76 oParser.add_option('--profile', dest = 'fProfile', action = 'store_true', default = False,
77 help = 'User ID to accredit with this job');
78
79 (self.oConfig, _) = oParser.parse_args();
80
81
82 def doIt(self):
83 """
84 Does the job.
85 """
86 oDb = TMDatabaseConnection();
87
88 aoGroups = SchedGroupLogic(oDb).getAll();
89 iRc = 0;
90 for oGroup in aoGroups:
91 if not self.oConfig.fQuiet:
92 print('%s (ID %#d):' % (oGroup.sName, oGroup.idSchedGroup,));
93 try:
94 (aoErrors, asMessages) = SchedulerBase.recreateQueue(oDb, self.oConfig.uid, oGroup.idSchedGroup, 2);
95 except Exception as oXcpt:
96 oDb.rollback();
97 print(' !!Hit exception processing "%s": %s' % (oGroup.sName, oXcpt,));
98 else:
99 if not aoErrors:
100 if not self.oConfig.fQuiet:
101 print(' Successfully regenerated.');
102 else:
103 iRc = 1;
104 print(' %d errors:' % (len(aoErrors,)));
105 for oError in aoErrors:
106 if oError[1] is None:
107 print(' !!%s' % (oError[0],));
108 else:
109 print(' !!%s (%s)' % (oError[0], oError[1]));
110 if asMessages and not self.oConfig.fQuiet:
111 print(' %d messages:' % (len(asMessages),));
112 for sMsg in asMessages:
113 print(' ##%s' % (sMsg,));
114 return iRc;
115
116 @staticmethod
117 def main():
118 """ Main function. """
119 oMain = RegenSchedQueues();
120 if oMain.oConfig.fProfile is not True:
121 iRc = oMain.doIt();
122 else:
123 import cProfile;
124 oProfiler = cProfile.Profile();
125 iRc = oProfiler.runcall(oMain.doIt);
126 oProfiler.print_stats(sort = 'time');
127 oProfiler = None;
128 return iRc;
129
130if __name__ == '__main__':
131 sys.exit(RegenSchedQueues().main());
132
Note: See TracBrowser for help on using the repository browser.

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