1 | #!/usr/bin/env python
|
---|
2 | # -*- coding: utf-8 -*-
|
---|
3 | # $Id: del_build.py 106061 2024-09-16 14:03:52Z vboxsync $
|
---|
4 | # pylint: disable=line-too-long
|
---|
5 |
|
---|
6 | """
|
---|
7 | Interface used by the tinderbox server side software to mark build binaries
|
---|
8 | deleted.
|
---|
9 | """
|
---|
10 |
|
---|
11 | from __future__ import print_function;
|
---|
12 |
|
---|
13 | __copyright__ = \
|
---|
14 | """
|
---|
15 | Copyright (C) 2012-2024 Oracle and/or its affiliates.
|
---|
16 |
|
---|
17 | This file is part of VirtualBox base platform packages, as
|
---|
18 | available from https://www.virtualbox.org.
|
---|
19 |
|
---|
20 | This program is free software; you can redistribute it and/or
|
---|
21 | modify it under the terms of the GNU General Public License
|
---|
22 | as published by the Free Software Foundation, in version 3 of the
|
---|
23 | License.
|
---|
24 |
|
---|
25 | This program is distributed in the hope that it will be useful, but
|
---|
26 | WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
27 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
28 | General Public License for more details.
|
---|
29 |
|
---|
30 | You should have received a copy of the GNU General Public License
|
---|
31 | along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
32 |
|
---|
33 | The contents of this file may alternatively be used under the terms
|
---|
34 | of the Common Development and Distribution License Version 1.0
|
---|
35 | (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
|
---|
36 | in the VirtualBox distribution, in which case the provisions of the
|
---|
37 | CDDL are applicable instead of those of the GPL.
|
---|
38 |
|
---|
39 | You may elect to license modified versions of this file under the
|
---|
40 | terms and conditions of either the GPL or the CDDL or both.
|
---|
41 |
|
---|
42 | SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
|
---|
43 | """
|
---|
44 | __version__ = "$Revision: 106061 $"
|
---|
45 |
|
---|
46 | # Standard python imports
|
---|
47 | import sys
|
---|
48 | import os
|
---|
49 | from optparse import OptionParser; # pylint: disable=deprecated-module
|
---|
50 |
|
---|
51 | # Add Test Manager's modules path
|
---|
52 | g_ksTestManagerDir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
---|
53 | sys.path.append(g_ksTestManagerDir)
|
---|
54 |
|
---|
55 | # Test Manager imports
|
---|
56 | from testmanager.core.db import TMDatabaseConnection
|
---|
57 | from testmanager.core.build import BuildLogic
|
---|
58 |
|
---|
59 |
|
---|
60 | def markBuildsDeleted():
|
---|
61 | """
|
---|
62 | Marks the builds using the specified binaries as deleted.
|
---|
63 | """
|
---|
64 |
|
---|
65 | oParser = OptionParser()
|
---|
66 | oParser.add_option('-q', '--quiet', dest='fQuiet', action='store_true',
|
---|
67 | help='Quiet execution');
|
---|
68 |
|
---|
69 | (oConfig, asArgs) = oParser.parse_args()
|
---|
70 | if not asArgs:
|
---|
71 | if not oConfig.fQuiet:
|
---|
72 | sys.stderr.write('syntax error: No builds binaries specified\n');
|
---|
73 | return 1;
|
---|
74 |
|
---|
75 |
|
---|
76 | oDb = TMDatabaseConnection()
|
---|
77 | oLogic = BuildLogic(oDb)
|
---|
78 |
|
---|
79 | for sBuildBin in asArgs:
|
---|
80 | try:
|
---|
81 | cBuilds = oLogic.markDeletedByBinaries(sBuildBin, fCommit = True)
|
---|
82 | except:
|
---|
83 | if oConfig.fQuiet:
|
---|
84 | sys.exit(1);
|
---|
85 | raise;
|
---|
86 | if not oConfig.fQuiet:
|
---|
87 | print("del_build.py: Marked %u builds associated with '%s' as deleted." % (cBuilds, sBuildBin,));
|
---|
88 |
|
---|
89 | oDb.close()
|
---|
90 | return 0;
|
---|
91 |
|
---|
92 | if __name__ == '__main__':
|
---|
93 | sys.exit(markBuildsDeleted())
|
---|
94 |
|
---|