VirtualBox

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

Last change on this file since 75056 was 70660, checked in by vboxsync, 7 years ago

ValidationKit: Python 3 and pylint 1.8.1 adjustments/fixes.

  • 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 70660 2018-01-21 16:18:58Z vboxsync $
4# pylint: disable=C0301
5
6"""
7Maintenance tool for closing orphaned testsets.
8"""
9
10from __future__ import print_function;
11
12__copyright__ = \
13"""
14Copyright (C) 2012-2017 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: 70660 $"
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