VirtualBox

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

Last change on this file since 78138 was 76553, checked in by vboxsync, 6 years ago

scm --update-copyright-year

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 4.2 KB
Line 
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3# $Id: regen_sched_queues.py 76553 2019-01-01 01:45:53Z vboxsync $
4# pylint: disable=C0301
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-2019 Oracle Corporation
15
16This file is part of VirtualBox Open Source Edition (OSE), as
17available from http://www.virtualbox.org. This file is free software;
18you can redistribute it and/or modify it under the terms of the GNU
19General Public License (GPL) as published by the Free Software
20Foundation, in version 2 as it comes in the "COPYING" file of the
21VirtualBox OSE distribution. VirtualBox OSE is distributed in the
22hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
23
24The contents of this file may alternatively be used under the terms
25of the Common Development and Distribution License Version 1.0
26(CDDL) only, as it comes in the "COPYING.CDDL" file of the
27VirtualBox OSE distribution, in which case the provisions of the
28CDDL are applicable instead of those of the GPL.
29
30You may elect to license modified versions of this file under the
31terms and conditions of either the GPL or the CDDL or both.
32"""
33__version__ = "$Revision: 76553 $"
34
35# Standard python imports
36import sys;
37import os;
38from optparse import OptionParser; # pylint: disable=deprecated-module
39
40# Add Test Manager's modules path
41g_ksTestManagerDir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))));
42sys.path.append(g_ksTestManagerDir);
43
44# Test Manager imports
45from testmanager.core.db import TMDatabaseConnection;
46from testmanager.core.schedulerbase import SchedulerBase;
47from testmanager.core.schedgroup import SchedGroupLogic;
48
49
50
51class RegenSchedQueues(object): # pylint: disable=R0903
52 """
53 Regenerates all the scheduling queues.
54 """
55
56 def __init__(self):
57 """
58 Parse command line.
59 """
60
61 oParser = OptionParser();
62 oParser.add_option('-q', '--quiet', dest = 'fQuiet', action = 'store_true', default = False,
63 help = 'Quiet execution');
64 oParser.add_option('-u', '--uid', dest = 'uid', action = 'store', type = 'int', default = 1,
65 help = 'User ID to accredit with this job');
66 oParser.add_option('--profile', dest = 'fProfile', action = 'store_true', default = False,
67 help = 'User ID to accredit with this job');
68
69 (self.oConfig, _) = oParser.parse_args();
70
71
72 def doIt(self):
73 """
74 Does the job.
75 """
76 oDb = TMDatabaseConnection();
77
78 aoGroups = SchedGroupLogic(oDb).getAll();
79 iRc = 0;
80 for oGroup in aoGroups:
81 if not self.oConfig.fQuiet:
82 print('%s (ID %#d):' % (oGroup.sName, oGroup.idSchedGroup,));
83 try:
84 (aoErrors, asMessages) = SchedulerBase.recreateQueue(oDb, self.oConfig.uid, oGroup.idSchedGroup, 2);
85 except Exception as oXcpt:
86 oDb.rollback();
87 print(' !!Hit exception processing "%s": %s' % (oGroup.sName, oXcpt,));
88 else:
89 if not aoErrors:
90 if not self.oConfig.fQuiet:
91 print(' Successfully regenerated.');
92 else:
93 iRc = 1;
94 print(' %d errors:' % (len(aoErrors,)));
95 for oError in aoErrors:
96 if oError[1] is None:
97 print(' !!%s' % (oError[0],));
98 else:
99 print(' !!%s (%s)' % (oError[0], oError[1]));
100 if asMessages and not self.oConfig.fQuiet:
101 print(' %d messages:' % (len(asMessages),));
102 for sMsg in asMessages:
103 print(' ##%s' % (sMsg,));
104 return iRc;
105
106 @staticmethod
107 def main():
108 """ Main function. """
109 oMain = RegenSchedQueues();
110 if oMain.oConfig.fProfile is not True:
111 iRc = oMain.doIt();
112 else:
113 import cProfile;
114 oProfiler = cProfile.Profile();
115 iRc = oProfiler.runcall(oMain.doIt);
116 oProfiler.print_stats(sort = 'time');
117 oProfiler = None;
118 return iRc;
119
120if __name__ == '__main__':
121 sys.exit(RegenSchedQueues().main());
122
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