VirtualBox

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

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