1 | #!/usr/bin/env python
|
---|
2 | # -*- coding: utf-8 -*-
|
---|
3 | # $Id: del_build.py 82968 2020-02-04 10:35:17Z 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-2020 Oracle Corporation
|
---|
16 |
|
---|
17 | This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
18 | available from http://www.virtualbox.org. This file is free software;
|
---|
19 | you can redistribute it and/or modify it under the terms of the GNU
|
---|
20 | General Public License (GPL) as published by the Free Software
|
---|
21 | Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
22 | VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
23 | hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
24 |
|
---|
25 | The contents of this file may alternatively be used under the terms
|
---|
26 | of the Common Development and Distribution License Version 1.0
|
---|
27 | (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
28 | VirtualBox OSE distribution, in which case the provisions of the
|
---|
29 | CDDL are applicable instead of those of the GPL.
|
---|
30 |
|
---|
31 | You may elect to license modified versions of this file under the
|
---|
32 | terms and conditions of either the GPL or the CDDL or both.
|
---|
33 | """
|
---|
34 | __version__ = "$Revision: 82968 $"
|
---|
35 |
|
---|
36 | # Standard python imports
|
---|
37 | import sys
|
---|
38 | import os
|
---|
39 | from optparse import OptionParser; # pylint: disable=deprecated-module
|
---|
40 |
|
---|
41 | # Add Test Manager's modules path
|
---|
42 | g_ksTestManagerDir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
---|
43 | sys.path.append(g_ksTestManagerDir)
|
---|
44 |
|
---|
45 | # Test Manager imports
|
---|
46 | from testmanager.core.db import TMDatabaseConnection
|
---|
47 | from testmanager.core.build import BuildLogic
|
---|
48 |
|
---|
49 |
|
---|
50 | def markBuildsDeleted():
|
---|
51 | """
|
---|
52 | Marks the builds using the specified binaries as deleted.
|
---|
53 | """
|
---|
54 |
|
---|
55 | oParser = OptionParser()
|
---|
56 | oParser.add_option('-q', '--quiet', dest='fQuiet', action='store_true',
|
---|
57 | help='Quiet execution');
|
---|
58 |
|
---|
59 | (oConfig, asArgs) = oParser.parse_args()
|
---|
60 | if not asArgs:
|
---|
61 | if not oConfig.fQuiet:
|
---|
62 | sys.stderr.write('syntax error: No builds binaries specified\n');
|
---|
63 | return 1;
|
---|
64 |
|
---|
65 |
|
---|
66 | oDb = TMDatabaseConnection()
|
---|
67 | oLogic = BuildLogic(oDb)
|
---|
68 |
|
---|
69 | for sBuildBin in asArgs:
|
---|
70 | try:
|
---|
71 | cBuilds = oLogic.markDeletedByBinaries(sBuildBin, fCommit = True)
|
---|
72 | except:
|
---|
73 | if oConfig.fQuiet:
|
---|
74 | sys.exit(1);
|
---|
75 | raise;
|
---|
76 | else:
|
---|
77 | if not oConfig.fQuiet:
|
---|
78 | print("del_build.py: Marked %u builds associated with '%s' as deleted." % (cBuilds, sBuildBin,));
|
---|
79 |
|
---|
80 | oDb.close()
|
---|
81 | return 0;
|
---|
82 |
|
---|
83 | if __name__ == '__main__':
|
---|
84 | sys.exit(markBuildsDeleted())
|
---|
85 |
|
---|