VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/testmanager/batch/add_build.py@ 98586

Last change on this file since 98586 was 98103, checked in by vboxsync, 2 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: 6.0 KB
Line 
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3# $Id: add_build.py 98103 2023-01-17 14:15:46Z vboxsync $
4# pylint: disable=line-too-long
5
6"""
7Interface used by the tinderbox server side software to add a fresh build.
8"""
9
10__copyright__ = \
11"""
12Copyright (C) 2012-2023 Oracle and/or its affiliates.
13
14This file is part of VirtualBox base platform packages, as
15available from https://www.virtualbox.org.
16
17This program is free software; you can redistribute it and/or
18modify it under the terms of the GNU General Public License
19as published by the Free Software Foundation, in version 3 of the
20License.
21
22This program is distributed in the hope that it will be useful, but
23WITHOUT ANY WARRANTY; without even the implied warranty of
24MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25General Public License for more details.
26
27You should have received a copy of the GNU General Public License
28along with this program; if not, see <https://www.gnu.org/licenses>.
29
30The contents of this file may alternatively be used under the terms
31of the Common Development and Distribution License Version 1.0
32(CDDL), a copy of it is provided in the "COPYING.CDDL" file included
33in the VirtualBox distribution, in which case the provisions of the
34CDDL are applicable instead of those of the GPL.
35
36You may elect to license modified versions of this file under the
37terms and conditions of either the GPL or the CDDL or both.
38
39SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
40"""
41__version__ = "$Revision: 98103 $"
42
43# Standard python imports
44import sys;
45import os;
46from optparse import OptionParser; # pylint: disable=deprecated-module
47
48# Add Test Manager's modules path
49g_ksTestManagerDir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))));
50sys.path.append(g_ksTestManagerDir);
51
52# Test Manager imports
53from testmanager.core.db import TMDatabaseConnection;
54from testmanager.core.build import BuildDataEx, BuildLogic, BuildCategoryData;
55
56class Build(object): # pylint: disable=too-few-public-methods
57 """
58 Add build info into Test Manager database.
59 """
60
61 def __init__(self):
62 """
63 Parse command line.
64 """
65
66 oParser = OptionParser();
67 oParser.add_option('-q', '--quiet', dest = 'fQuiet', action = 'store_true',
68 help = 'Quiet execution');
69 oParser.add_option('-b', '--branch', dest = 'sBranch', metavar = '<branch>',
70 help = 'branch name (default: trunk)', default = 'trunk');
71 oParser.add_option('-p', '--product', dest = 'sProductName', metavar = '<name>',
72 help = 'The product name.');
73 oParser.add_option('-r', '--revision', dest = 'iRevision', metavar = '<rev>',
74 help = 'revision number');
75 oParser.add_option('-R', '--repository', dest = 'sRepository', metavar = '<repository>',
76 help = 'Version control repository name.');
77 oParser.add_option('-t', '--type', dest = 'sBuildType', metavar = '<type>',
78 help = 'build type (debug, release etc.)');
79 oParser.add_option('-v', '--version', dest = 'sProductVersion', metavar = '<ver>',
80 help = 'The product version number (suitable for RTStrVersionCompare)');
81 oParser.add_option('-o', '--os-arch', dest = 'asTargetOsArches', metavar = '<os.arch>', action = 'append',
82 help = 'Target OS and architecture. This option can be repeated.');
83 oParser.add_option('-l', '--log', dest = 'sBuildLogPath', metavar = '<url>',
84 help = 'URL to the build logs (optional).');
85 oParser.add_option('-f', '--file', dest = 'asFiles', metavar = '<file|url>', action = 'append',
86 help = 'URLs or build share relative path to a build output file. This option can be repeated.');
87
88 (self.oConfig, _) = oParser.parse_args();
89
90 # Check command line
91 asMissing = [];
92 if self.oConfig.sBranch is None: asMissing.append('--branch');
93 if self.oConfig.iRevision is None: asMissing.append('--revision');
94 if self.oConfig.sProductVersion is None: asMissing.append('--version');
95 if self.oConfig.sProductName is None: asMissing.append('--product');
96 if self.oConfig.sBuildType is None: asMissing.append('--type');
97 if self.oConfig.asTargetOsArches is None: asMissing.append('--os-arch');
98 if self.oConfig.asFiles is None: asMissing.append('--file');
99 if asMissing:
100 sys.stderr.write('syntax error: Missing: %s\n' % (asMissing,));
101 sys.exit(1);
102 # Temporary default.
103 if self.oConfig.sRepository is None:
104 self.oConfig.sRepository = 'vbox';
105
106 def add(self):
107 """
108 Add build data record into database.
109 """
110 oDb = TMDatabaseConnection()
111
112 # Assemble the build data.
113 oBuildData = BuildDataEx()
114 oBuildData.idBuildCategory = None;
115 oBuildData.iRevision = self.oConfig.iRevision
116 oBuildData.sVersion = self.oConfig.sProductVersion
117 oBuildData.sLogUrl = self.oConfig.sBuildLogPath
118 oBuildData.sBinaries = ','.join(self.oConfig.asFiles);
119 oBuildData.oCat = BuildCategoryData().initFromValues(sProduct = self.oConfig.sProductName,
120 sRepository = self.oConfig.sRepository,
121 sBranch = self.oConfig.sBranch,
122 sType = self.oConfig.sBuildType,
123 asOsArches = self.oConfig.asTargetOsArches);
124
125 # Add record to database
126 try:
127 BuildLogic(oDb).addEntry(oBuildData, fCommit = True);
128 except:
129 if self.oConfig.fQuiet:
130 sys.exit(1);
131 raise;
132 oDb.close();
133 return 0;
134
135if __name__ == '__main__':
136 sys.exit(Build().add());
137
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