VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/testmanager/batch/close_orphaned_testsets.py@ 98523

Last change on this file since 98523 was 98103, checked in by vboxsync, 22 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: 3.4 KB
Line 
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3# $Id: close_orphaned_testsets.py 98103 2023-01-17 14:15:46Z vboxsync $
4# pylint: disable=line-too-long
5
6"""
7Maintenance tool for closing orphaned testsets.
8"""
9
10from __future__ import print_function;
11
12__copyright__ = \
13"""
14Copyright (C) 2012-2023 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: 98103 $"
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.testset import TestSetLogic;
57
58
59class CloseOrphanedTestSets(object):
60 """
61 Finds and closes orphaned testsets.
62 """
63
64 def __init__(self):
65 """
66 Parse command line
67 """
68 oParser = OptionParser();
69 oParser.add_option('-d', '--just-do-it', dest='fJustDoIt', action='store_true',
70 help='Do the database changes.');
71
72
73 (self.oConfig, _) = oParser.parse_args();
74
75
76 def main(self):
77 """ Main method. """
78 oDb = TMDatabaseConnection();
79
80 # Get a list of orphans.
81 oLogic = TestSetLogic(oDb);
82 aoOrphans = oLogic.fetchOrphaned();
83 if aoOrphans:
84 # Complete them.
85 if self.oConfig.fJustDoIt:
86 print('Completing %u test sets as abandoned:' % (len(aoOrphans),));
87 for oTestSet in aoOrphans:
88 print('#%-7u: idTestBox=%-3u tsCreated=%s tsDone=%s'
89 % (oTestSet.idTestSet, oTestSet.idTestBox, oTestSet.tsCreated, oTestSet.tsDone));
90 oLogic.completeAsAbandoned(oTestSet.idTestSet);
91 print('Committing...');
92 oDb.commit();
93 else:
94 for oTestSet in aoOrphans:
95 print('#%-7u: idTestBox=%-3u tsCreated=%s tsDone=%s'
96 % (oTestSet.idTestSet, oTestSet.idTestBox, oTestSet.tsCreated, oTestSet.tsDone));
97 print('Not completing any testsets without seeing the --just-do-it option.');
98 else:
99 print('No orphaned test sets.\n');
100 return 0;
101
102
103if __name__ == '__main__':
104 sys.exit(CloseOrphanedTestSets().main())
105
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