VirtualBox

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

Last change on this file since 90160 was 82968, checked in by vboxsync, 5 years 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.2 KB
Line 
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3# $Id: close_orphaned_testsets.py 82968 2020-02-04 10:35:17Z 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-2020 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: 82968 $"
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.testset import TestSetLogic;
47
48
49class CloseOrphanedTestSets(object):
50 """
51 Finds and closes orphaned testsets.
52 """
53
54 def __init__(self):
55 """
56 Parse command line
57 """
58 oParser = OptionParser();
59 oParser.add_option('-d', '--just-do-it', dest='fJustDoIt', action='store_true',
60 help='Do the database changes.');
61
62
63 (self.oConfig, _) = oParser.parse_args();
64
65
66 def main(self):
67 """ Main method. """
68 oDb = TMDatabaseConnection();
69
70 # Get a list of orphans.
71 oLogic = TestSetLogic(oDb);
72 aoOrphans = oLogic.fetchOrphaned();
73 if aoOrphans:
74 # Complete them.
75 if self.oConfig.fJustDoIt:
76 print('Completing %u test sets as abandoned:' % (len(aoOrphans),));
77 for oTestSet in aoOrphans:
78 print('#%-7u: idTestBox=%-3u tsCreated=%s tsDone=%s'
79 % (oTestSet.idTestSet, oTestSet.idTestBox, oTestSet.tsCreated, oTestSet.tsDone));
80 oLogic.completeAsAbandoned(oTestSet.idTestSet);
81 print('Committing...');
82 oDb.commit();
83 else:
84 for oTestSet in aoOrphans:
85 print('#%-7u: idTestBox=%-3u tsCreated=%s tsDone=%s'
86 % (oTestSet.idTestSet, oTestSet.idTestBox, oTestSet.tsCreated, oTestSet.tsDone));
87 print('Not completing any testsets without seeing the --just-do-it option.');
88 else:
89 print('No orphaned test sets.\n');
90 return 0;
91
92
93if __name__ == '__main__':
94 sys.exit(CloseOrphanedTestSets().main())
95
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