Includes library modifications to allow access to AIN_4 (AIN_0 / 5)

Committer:
bryantaylor
Date:
Tue Sep 20 21:26:12 2016 +0000
Revision:
0:eafc3fd41f75
hackathon

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bryantaylor 0:eafc3fd41f75 1 """
bryantaylor 0:eafc3fd41f75 2 mbed SDK
bryantaylor 0:eafc3fd41f75 3 Copyright (c) 2011-2013 ARM Limited
bryantaylor 0:eafc3fd41f75 4
bryantaylor 0:eafc3fd41f75 5 Licensed under the Apache License, Version 2.0 (the "License");
bryantaylor 0:eafc3fd41f75 6 you may not use this file except in compliance with the License.
bryantaylor 0:eafc3fd41f75 7 You may obtain a copy of the License at
bryantaylor 0:eafc3fd41f75 8
bryantaylor 0:eafc3fd41f75 9 http://www.apache.org/licenses/LICENSE-2.0
bryantaylor 0:eafc3fd41f75 10
bryantaylor 0:eafc3fd41f75 11 Unless required by applicable law or agreed to in writing, software
bryantaylor 0:eafc3fd41f75 12 distributed under the License is distributed on an "AS IS" BASIS,
bryantaylor 0:eafc3fd41f75 13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
bryantaylor 0:eafc3fd41f75 14 See the License for the specific language governing permissions and
bryantaylor 0:eafc3fd41f75 15 limitations under the License.
bryantaylor 0:eafc3fd41f75 16 """
bryantaylor 0:eafc3fd41f75 17 import sys
bryantaylor 0:eafc3fd41f75 18 import argparse
bryantaylor 0:eafc3fd41f75 19 import xml.etree.ElementTree as ET
bryantaylor 0:eafc3fd41f75 20 import requests
bryantaylor 0:eafc3fd41f75 21 import urlparse
bryantaylor 0:eafc3fd41f75 22
bryantaylor 0:eafc3fd41f75 23 def create_headers(args):
bryantaylor 0:eafc3fd41f75 24 return { 'X-Api-Key': args.api_key }
bryantaylor 0:eafc3fd41f75 25
bryantaylor 0:eafc3fd41f75 26 def finish_command(command, response):
bryantaylor 0:eafc3fd41f75 27 print(command, response.status_code, response.reason)
bryantaylor 0:eafc3fd41f75 28 print(response.text)
bryantaylor 0:eafc3fd41f75 29
bryantaylor 0:eafc3fd41f75 30 if response.status_code < 400:
bryantaylor 0:eafc3fd41f75 31 sys.exit(0)
bryantaylor 0:eafc3fd41f75 32 else:
bryantaylor 0:eafc3fd41f75 33 sys.exit(2)
bryantaylor 0:eafc3fd41f75 34
bryantaylor 0:eafc3fd41f75 35 def create_build(args):
bryantaylor 0:eafc3fd41f75 36 build = {}
bryantaylor 0:eafc3fd41f75 37 build['buildType'] = args.build_type
bryantaylor 0:eafc3fd41f75 38 build['number'] = args.build_number
bryantaylor 0:eafc3fd41f75 39 build['source'] = args.build_source
bryantaylor 0:eafc3fd41f75 40 build['status'] = 'running'
bryantaylor 0:eafc3fd41f75 41
bryantaylor 0:eafc3fd41f75 42 r = requests.post(urlparse.urljoin(args.url, "api/builds"), headers=create_headers(args), json=build)
bryantaylor 0:eafc3fd41f75 43
bryantaylor 0:eafc3fd41f75 44 if r.status_code < 400:
bryantaylor 0:eafc3fd41f75 45 if args.property_file_format:
bryantaylor 0:eafc3fd41f75 46 print("MBED_BUILD_ID=" + r.text)
bryantaylor 0:eafc3fd41f75 47 else:
bryantaylor 0:eafc3fd41f75 48 print(r.text)
bryantaylor 0:eafc3fd41f75 49
bryantaylor 0:eafc3fd41f75 50 sys.exit(0)
bryantaylor 0:eafc3fd41f75 51 else:
bryantaylor 0:eafc3fd41f75 52 sys.exit(2)
bryantaylor 0:eafc3fd41f75 53
bryantaylor 0:eafc3fd41f75 54 def finish_build(args):
bryantaylor 0:eafc3fd41f75 55 data = {}
bryantaylor 0:eafc3fd41f75 56 data['status'] = 'completed'
bryantaylor 0:eafc3fd41f75 57
bryantaylor 0:eafc3fd41f75 58 r = requests.put(urlparse.urljoin(args.url, "api/builds/" + args.build_id), headers=create_headers(args), json=data)
bryantaylor 0:eafc3fd41f75 59 finish_command('finish-build', r)
bryantaylor 0:eafc3fd41f75 60
bryantaylor 0:eafc3fd41f75 61 def promote_build(args):
bryantaylor 0:eafc3fd41f75 62 data = {}
bryantaylor 0:eafc3fd41f75 63 data['buildType'] = 'Release'
bryantaylor 0:eafc3fd41f75 64
bryantaylor 0:eafc3fd41f75 65 r = requests.put(urlparse.urljoin(args.url, "api/builds/" + args.build_id), headers=create_headers(args), json=data)
bryantaylor 0:eafc3fd41f75 66 finish_command('promote-build', r)
bryantaylor 0:eafc3fd41f75 67
bryantaylor 0:eafc3fd41f75 68 def abort_build(args):
bryantaylor 0:eafc3fd41f75 69 data = {}
bryantaylor 0:eafc3fd41f75 70 data['status'] = 'aborted'
bryantaylor 0:eafc3fd41f75 71
bryantaylor 0:eafc3fd41f75 72 r = requests.put(urlparse.urljoin(args.url, "api/builds/" + args.build_id), headers=create_headers(args), json=data)
bryantaylor 0:eafc3fd41f75 73 finish_command('abort-build', r)
bryantaylor 0:eafc3fd41f75 74
bryantaylor 0:eafc3fd41f75 75 def add_project_runs(args):
bryantaylor 0:eafc3fd41f75 76 '''
bryantaylor 0:eafc3fd41f75 77 -------------------------------------
bryantaylor 0:eafc3fd41f75 78 Notes on 'project_run_data' structure:
bryantaylor 0:eafc3fd41f75 79 --------------------------------------
bryantaylor 0:eafc3fd41f75 80 'projectRuns' - Tree structure used to keep track of what projects have
bryantaylor 0:eafc3fd41f75 81 been logged in different report files. The tree is organized as follows:
bryantaylor 0:eafc3fd41f75 82
bryantaylor 0:eafc3fd41f75 83 'projectRuns': { - Root element of tree
bryantaylor 0:eafc3fd41f75 84
bryantaylor 0:eafc3fd41f75 85 'hostOs': { - Host OS on which project was built/tested
bryantaylor 0:eafc3fd41f75 86 - ex. windows, linux, or mac
bryantaylor 0:eafc3fd41f75 87
bryantaylor 0:eafc3fd41f75 88 'platform': { - Platform for which project was built/tested
bryantaylor 0:eafc3fd41f75 89 (Corresponds to platform names in targets.py)
bryantaylor 0:eafc3fd41f75 90 - ex. K64F, LPC1768, NRF51822, etc.
bryantaylor 0:eafc3fd41f75 91
bryantaylor 0:eafc3fd41f75 92 'toolchain': { - Toolchain with which project was built/tested
bryantaylor 0:eafc3fd41f75 93 (Corresponds to TOOLCHAIN_CLASSES names in toolchains/__init__.py)
bryantaylor 0:eafc3fd41f75 94 - ex. ARM, uARM, GCC_ARM, etc.
bryantaylor 0:eafc3fd41f75 95
bryantaylor 0:eafc3fd41f75 96 'project': { - Project that was build/tested
bryantaylor 0:eafc3fd41f75 97 (Corresponds to test id in tests.py or library id in libraries.py)
bryantaylor 0:eafc3fd41f75 98 - For tests, ex. MBED_A1, MBED_11, DTCT_1 etc.
bryantaylor 0:eafc3fd41f75 99 - For libraries, ex. MBED, RTX, RTOS, etc.
bryantaylor 0:eafc3fd41f75 100
bryantaylor 0:eafc3fd41f75 101 },
bryantaylor 0:eafc3fd41f75 102 ...
bryantaylor 0:eafc3fd41f75 103 },
bryantaylor 0:eafc3fd41f75 104 ...
bryantaylor 0:eafc3fd41f75 105 },
bryantaylor 0:eafc3fd41f75 106 ...
bryantaylor 0:eafc3fd41f75 107 }
bryantaylor 0:eafc3fd41f75 108 }
bryantaylor 0:eafc3fd41f75 109
bryantaylor 0:eafc3fd41f75 110 'platforms_set' - Set of all the platform names mentioned in the given report files
bryantaylor 0:eafc3fd41f75 111
bryantaylor 0:eafc3fd41f75 112 'toolchains_set' - Set of all the toolchain names mentioned in the given report files
bryantaylor 0:eafc3fd41f75 113
bryantaylor 0:eafc3fd41f75 114 'names_set' - Set of all the project names mentioned in the given report files
bryantaylor 0:eafc3fd41f75 115
bryantaylor 0:eafc3fd41f75 116 'hostOses_set' - Set of all the host names given (only given by the command line arguments)
bryantaylor 0:eafc3fd41f75 117 '''
bryantaylor 0:eafc3fd41f75 118
bryantaylor 0:eafc3fd41f75 119 project_run_data = {}
bryantaylor 0:eafc3fd41f75 120 project_run_data['projectRuns'] = {}
bryantaylor 0:eafc3fd41f75 121 project_run_data['platforms_set'] = set()
bryantaylor 0:eafc3fd41f75 122 project_run_data['vendors_set'] = set()
bryantaylor 0:eafc3fd41f75 123 project_run_data['toolchains_set'] = set()
bryantaylor 0:eafc3fd41f75 124 project_run_data['names_set'] = set()
bryantaylor 0:eafc3fd41f75 125 project_run_data['hostOses_set'] = set()
bryantaylor 0:eafc3fd41f75 126 project_run_data['hostOses_set'].add(args.host_os)
bryantaylor 0:eafc3fd41f75 127
bryantaylor 0:eafc3fd41f75 128 if args.build_report:
bryantaylor 0:eafc3fd41f75 129 add_report(project_run_data, args.build_report, True, args.build_id, args.host_os)
bryantaylor 0:eafc3fd41f75 130
bryantaylor 0:eafc3fd41f75 131 if args.test_report:
bryantaylor 0:eafc3fd41f75 132 add_report(project_run_data, args.test_report, False, args.build_id, args.host_os)
bryantaylor 0:eafc3fd41f75 133
bryantaylor 0:eafc3fd41f75 134 ts_data = format_project_run_data(project_run_data, args.limit)
bryantaylor 0:eafc3fd41f75 135 total_result = True
bryantaylor 0:eafc3fd41f75 136
bryantaylor 0:eafc3fd41f75 137 total_parts = len(ts_data)
bryantaylor 0:eafc3fd41f75 138 print "Uploading project runs in %d parts" % total_parts
bryantaylor 0:eafc3fd41f75 139
bryantaylor 0:eafc3fd41f75 140 for index, data in enumerate(ts_data):
bryantaylor 0:eafc3fd41f75 141 r = requests.post(urlparse.urljoin(args.url, "api/projectRuns"), headers=create_headers(args), json=data)
bryantaylor 0:eafc3fd41f75 142 print("add-project-runs part %d/%d" % (index + 1, total_parts), r.status_code, r.reason)
bryantaylor 0:eafc3fd41f75 143 print(r.text)
bryantaylor 0:eafc3fd41f75 144
bryantaylor 0:eafc3fd41f75 145 if r.status_code >= 400:
bryantaylor 0:eafc3fd41f75 146 total_result = False
bryantaylor 0:eafc3fd41f75 147
bryantaylor 0:eafc3fd41f75 148 if total_result:
bryantaylor 0:eafc3fd41f75 149 print "'add-project-runs' completed successfully"
bryantaylor 0:eafc3fd41f75 150 sys.exit(0)
bryantaylor 0:eafc3fd41f75 151 else:
bryantaylor 0:eafc3fd41f75 152 print "'add-project-runs' failed"
bryantaylor 0:eafc3fd41f75 153 sys.exit(2)
bryantaylor 0:eafc3fd41f75 154
bryantaylor 0:eafc3fd41f75 155 def prep_ts_data():
bryantaylor 0:eafc3fd41f75 156 ts_data = {}
bryantaylor 0:eafc3fd41f75 157 ts_data['projectRuns'] = []
bryantaylor 0:eafc3fd41f75 158 ts_data['platforms'] = set()
bryantaylor 0:eafc3fd41f75 159 ts_data['vendors'] = set()
bryantaylor 0:eafc3fd41f75 160 ts_data['toolchains'] = set()
bryantaylor 0:eafc3fd41f75 161 ts_data['names'] = set()
bryantaylor 0:eafc3fd41f75 162 ts_data['hostOses'] = set()
bryantaylor 0:eafc3fd41f75 163 return ts_data
bryantaylor 0:eafc3fd41f75 164
bryantaylor 0:eafc3fd41f75 165 def finish_ts_data(ts_data, project_run_data):
bryantaylor 0:eafc3fd41f75 166 ts_data['platforms'] = list(ts_data['platforms'])
bryantaylor 0:eafc3fd41f75 167 ts_data['vendors'] = list(ts_data['vendors'])
bryantaylor 0:eafc3fd41f75 168 ts_data['toolchains'] = list(ts_data['toolchains'])
bryantaylor 0:eafc3fd41f75 169 ts_data['names'] = list(ts_data['names'])
bryantaylor 0:eafc3fd41f75 170 ts_data['hostOses'] = list(ts_data['hostOses'])
bryantaylor 0:eafc3fd41f75 171
bryantaylor 0:eafc3fd41f75 172 # Add all vendors to every projectRun submission
bryantaylor 0:eafc3fd41f75 173 # TODO Either add "vendor" to the "project_run_data"
bryantaylor 0:eafc3fd41f75 174 # or remove "vendor" entirely from the viewer
bryantaylor 0:eafc3fd41f75 175 ts_data['vendors'] = list(project_run_data['vendors_set'])
bryantaylor 0:eafc3fd41f75 176
bryantaylor 0:eafc3fd41f75 177 def format_project_run_data(project_run_data, limit):
bryantaylor 0:eafc3fd41f75 178 all_ts_data = []
bryantaylor 0:eafc3fd41f75 179 current_limit_count = 0
bryantaylor 0:eafc3fd41f75 180
bryantaylor 0:eafc3fd41f75 181 ts_data = prep_ts_data()
bryantaylor 0:eafc3fd41f75 182 ts_data['projectRuns'] = []
bryantaylor 0:eafc3fd41f75 183
bryantaylor 0:eafc3fd41f75 184 for hostOs_name, hostOs in project_run_data['projectRuns'].iteritems():
bryantaylor 0:eafc3fd41f75 185 for platform_name, platform in hostOs.iteritems():
bryantaylor 0:eafc3fd41f75 186 for toolchain_name, toolchain in platform.iteritems():
bryantaylor 0:eafc3fd41f75 187 for project_name, project in toolchain.iteritems():
bryantaylor 0:eafc3fd41f75 188 if current_limit_count >= limit:
bryantaylor 0:eafc3fd41f75 189 finish_ts_data(ts_data, project_run_data)
bryantaylor 0:eafc3fd41f75 190 all_ts_data.append(ts_data)
bryantaylor 0:eafc3fd41f75 191 ts_data = prep_ts_data()
bryantaylor 0:eafc3fd41f75 192 current_limit_count = 0
bryantaylor 0:eafc3fd41f75 193
bryantaylor 0:eafc3fd41f75 194 ts_data['projectRuns'].append(project)
bryantaylor 0:eafc3fd41f75 195 ts_data['platforms'].add(platform_name)
bryantaylor 0:eafc3fd41f75 196 ts_data['toolchains'].add(toolchain_name)
bryantaylor 0:eafc3fd41f75 197 ts_data['names'].add(project_name)
bryantaylor 0:eafc3fd41f75 198 ts_data['hostOses'].add(hostOs_name)
bryantaylor 0:eafc3fd41f75 199 current_limit_count += 1
bryantaylor 0:eafc3fd41f75 200
bryantaylor 0:eafc3fd41f75 201 if current_limit_count > 0:
bryantaylor 0:eafc3fd41f75 202 finish_ts_data(ts_data, project_run_data)
bryantaylor 0:eafc3fd41f75 203 all_ts_data.append(ts_data)
bryantaylor 0:eafc3fd41f75 204
bryantaylor 0:eafc3fd41f75 205 return all_ts_data
bryantaylor 0:eafc3fd41f75 206
bryantaylor 0:eafc3fd41f75 207 def find_project_run(projectRuns, project):
bryantaylor 0:eafc3fd41f75 208 keys = ['hostOs', 'platform', 'toolchain', 'project']
bryantaylor 0:eafc3fd41f75 209
bryantaylor 0:eafc3fd41f75 210 elem = projectRuns
bryantaylor 0:eafc3fd41f75 211
bryantaylor 0:eafc3fd41f75 212 for key in keys:
bryantaylor 0:eafc3fd41f75 213 if not project[key] in elem:
bryantaylor 0:eafc3fd41f75 214 return None
bryantaylor 0:eafc3fd41f75 215
bryantaylor 0:eafc3fd41f75 216 elem = elem[project[key]]
bryantaylor 0:eafc3fd41f75 217
bryantaylor 0:eafc3fd41f75 218 return elem
bryantaylor 0:eafc3fd41f75 219
bryantaylor 0:eafc3fd41f75 220 def add_project_run(projectRuns, project):
bryantaylor 0:eafc3fd41f75 221 keys = ['hostOs', 'platform', 'toolchain']
bryantaylor 0:eafc3fd41f75 222
bryantaylor 0:eafc3fd41f75 223 elem = projectRuns
bryantaylor 0:eafc3fd41f75 224
bryantaylor 0:eafc3fd41f75 225 for key in keys:
bryantaylor 0:eafc3fd41f75 226 if not project[key] in elem:
bryantaylor 0:eafc3fd41f75 227 elem[project[key]] = {}
bryantaylor 0:eafc3fd41f75 228
bryantaylor 0:eafc3fd41f75 229 elem = elem[project[key]]
bryantaylor 0:eafc3fd41f75 230
bryantaylor 0:eafc3fd41f75 231 elem[project['project']] = project
bryantaylor 0:eafc3fd41f75 232
bryantaylor 0:eafc3fd41f75 233 def update_project_run_results(project_to_update, project, is_build):
bryantaylor 0:eafc3fd41f75 234 if is_build:
bryantaylor 0:eafc3fd41f75 235 project_to_update['buildPass'] = project['buildPass']
bryantaylor 0:eafc3fd41f75 236 project_to_update['buildResult'] = project['buildResult']
bryantaylor 0:eafc3fd41f75 237 project_to_update['buildOutput'] = project['buildOutput']
bryantaylor 0:eafc3fd41f75 238 else:
bryantaylor 0:eafc3fd41f75 239 project_to_update['testPass'] = project['testPass']
bryantaylor 0:eafc3fd41f75 240 project_to_update['testResult'] = project['testResult']
bryantaylor 0:eafc3fd41f75 241 project_to_update['testOutput'] = project['testOutput']
bryantaylor 0:eafc3fd41f75 242
bryantaylor 0:eafc3fd41f75 243 def update_project_run(projectRuns, project, is_build):
bryantaylor 0:eafc3fd41f75 244 found_project = find_project_run(projectRuns, project)
bryantaylor 0:eafc3fd41f75 245 if found_project:
bryantaylor 0:eafc3fd41f75 246 update_project_run_results(found_project, project, is_build)
bryantaylor 0:eafc3fd41f75 247 else:
bryantaylor 0:eafc3fd41f75 248 add_project_run(projectRuns, project)
bryantaylor 0:eafc3fd41f75 249
bryantaylor 0:eafc3fd41f75 250 def add_report(project_run_data, report_file, is_build, build_id, host_os):
bryantaylor 0:eafc3fd41f75 251 tree = None
bryantaylor 0:eafc3fd41f75 252
bryantaylor 0:eafc3fd41f75 253 try:
bryantaylor 0:eafc3fd41f75 254 tree = ET.parse(report_file)
bryantaylor 0:eafc3fd41f75 255 except:
bryantaylor 0:eafc3fd41f75 256 print(sys.exc_info()[0])
bryantaylor 0:eafc3fd41f75 257 print('Invalid path to report: %s', report_file)
bryantaylor 0:eafc3fd41f75 258 sys.exit(1)
bryantaylor 0:eafc3fd41f75 259
bryantaylor 0:eafc3fd41f75 260 test_suites = tree.getroot()
bryantaylor 0:eafc3fd41f75 261
bryantaylor 0:eafc3fd41f75 262 for test_suite in test_suites:
bryantaylor 0:eafc3fd41f75 263 platform = ""
bryantaylor 0:eafc3fd41f75 264 toolchain = ""
bryantaylor 0:eafc3fd41f75 265 vendor = ""
bryantaylor 0:eafc3fd41f75 266 for properties in test_suite.findall('properties'):
bryantaylor 0:eafc3fd41f75 267 for property in properties.findall('property'):
bryantaylor 0:eafc3fd41f75 268 if property.attrib['name'] == 'target':
bryantaylor 0:eafc3fd41f75 269 platform = property.attrib['value']
bryantaylor 0:eafc3fd41f75 270 project_run_data['platforms_set'].add(platform)
bryantaylor 0:eafc3fd41f75 271 elif property.attrib['name'] == 'toolchain':
bryantaylor 0:eafc3fd41f75 272 toolchain = property.attrib['value']
bryantaylor 0:eafc3fd41f75 273 project_run_data['toolchains_set'].add(toolchain)
bryantaylor 0:eafc3fd41f75 274 elif property.attrib['name'] == 'vendor':
bryantaylor 0:eafc3fd41f75 275 vendor = property.attrib['value']
bryantaylor 0:eafc3fd41f75 276 project_run_data['vendors_set'].add(vendor)
bryantaylor 0:eafc3fd41f75 277
bryantaylor 0:eafc3fd41f75 278 for test_case in test_suite.findall('testcase'):
bryantaylor 0:eafc3fd41f75 279 projectRun = {}
bryantaylor 0:eafc3fd41f75 280 projectRun['build'] = build_id
bryantaylor 0:eafc3fd41f75 281 projectRun['hostOs'] = host_os
bryantaylor 0:eafc3fd41f75 282 projectRun['platform'] = platform
bryantaylor 0:eafc3fd41f75 283 projectRun['toolchain'] = toolchain
bryantaylor 0:eafc3fd41f75 284 projectRun['project'] = test_case.attrib['classname'].split('.')[-1]
bryantaylor 0:eafc3fd41f75 285 projectRun['vendor'] = vendor
bryantaylor 0:eafc3fd41f75 286
bryantaylor 0:eafc3fd41f75 287 project_run_data['names_set'].add(projectRun['project'])
bryantaylor 0:eafc3fd41f75 288
bryantaylor 0:eafc3fd41f75 289 should_skip = False
bryantaylor 0:eafc3fd41f75 290 skips = test_case.findall('skipped')
bryantaylor 0:eafc3fd41f75 291
bryantaylor 0:eafc3fd41f75 292 if skips:
bryantaylor 0:eafc3fd41f75 293 should_skip = skips[0].attrib['message'] == 'SKIP'
bryantaylor 0:eafc3fd41f75 294
bryantaylor 0:eafc3fd41f75 295 if not should_skip:
bryantaylor 0:eafc3fd41f75 296 system_outs = test_case.findall('system-out')
bryantaylor 0:eafc3fd41f75 297
bryantaylor 0:eafc3fd41f75 298 output = ""
bryantaylor 0:eafc3fd41f75 299 if system_outs:
bryantaylor 0:eafc3fd41f75 300 output = system_outs[0].text
bryantaylor 0:eafc3fd41f75 301
bryantaylor 0:eafc3fd41f75 302 if is_build:
bryantaylor 0:eafc3fd41f75 303 projectRun['buildOutput'] = output
bryantaylor 0:eafc3fd41f75 304 else:
bryantaylor 0:eafc3fd41f75 305 projectRun['testOutput'] = output
bryantaylor 0:eafc3fd41f75 306
bryantaylor 0:eafc3fd41f75 307 errors = test_case.findall('error')
bryantaylor 0:eafc3fd41f75 308 failures = test_case.findall('failure')
bryantaylor 0:eafc3fd41f75 309 projectRunPass = None
bryantaylor 0:eafc3fd41f75 310 result = None
bryantaylor 0:eafc3fd41f75 311
bryantaylor 0:eafc3fd41f75 312 if errors:
bryantaylor 0:eafc3fd41f75 313 projectRunPass = False
bryantaylor 0:eafc3fd41f75 314 result = errors[0].attrib['message']
bryantaylor 0:eafc3fd41f75 315 elif failures:
bryantaylor 0:eafc3fd41f75 316 projectRunPass = False
bryantaylor 0:eafc3fd41f75 317 result = failures[0].attrib['message']
bryantaylor 0:eafc3fd41f75 318 elif skips:
bryantaylor 0:eafc3fd41f75 319 projectRunPass = True
bryantaylor 0:eafc3fd41f75 320 result = skips[0].attrib['message']
bryantaylor 0:eafc3fd41f75 321 else:
bryantaylor 0:eafc3fd41f75 322 projectRunPass = True
bryantaylor 0:eafc3fd41f75 323 result = 'OK'
bryantaylor 0:eafc3fd41f75 324
bryantaylor 0:eafc3fd41f75 325 if is_build:
bryantaylor 0:eafc3fd41f75 326 projectRun['buildPass'] = projectRunPass
bryantaylor 0:eafc3fd41f75 327 projectRun['buildResult'] = result
bryantaylor 0:eafc3fd41f75 328 else:
bryantaylor 0:eafc3fd41f75 329 projectRun['testPass'] = projectRunPass
bryantaylor 0:eafc3fd41f75 330 projectRun['testResult'] = result
bryantaylor 0:eafc3fd41f75 331
bryantaylor 0:eafc3fd41f75 332 update_project_run(project_run_data['projectRuns'], projectRun, is_build)
bryantaylor 0:eafc3fd41f75 333
bryantaylor 0:eafc3fd41f75 334 def main(arguments):
bryantaylor 0:eafc3fd41f75 335 # Register and parse command line arguments
bryantaylor 0:eafc3fd41f75 336 parser = argparse.ArgumentParser()
bryantaylor 0:eafc3fd41f75 337 parser.add_argument('-u', '--url', required=True, help='url to ci site')
bryantaylor 0:eafc3fd41f75 338 parser.add_argument('-k', '--api-key', required=True, help='api-key for posting data')
bryantaylor 0:eafc3fd41f75 339
bryantaylor 0:eafc3fd41f75 340 subparsers = parser.add_subparsers(help='subcommand help')
bryantaylor 0:eafc3fd41f75 341
bryantaylor 0:eafc3fd41f75 342 create_build_parser = subparsers.add_parser('create-build', help='create a new build')
bryantaylor 0:eafc3fd41f75 343 create_build_parser.add_argument('-b', '--build-number', required=True, help='build number')
bryantaylor 0:eafc3fd41f75 344 create_build_parser.add_argument('-T', '--build-type', choices=['Nightly', 'Limited', 'Pull_Request', 'Release_Candidate'], required=True, help='type of build')
bryantaylor 0:eafc3fd41f75 345 create_build_parser.add_argument('-s', '--build-source', required=True, help='url to source of build')
bryantaylor 0:eafc3fd41f75 346 create_build_parser.add_argument('-p', '--property-file-format', action='store_true', help='print result in the property file format')
bryantaylor 0:eafc3fd41f75 347 create_build_parser.set_defaults(func=create_build)
bryantaylor 0:eafc3fd41f75 348
bryantaylor 0:eafc3fd41f75 349 finish_build_parser = subparsers.add_parser('finish-build', help='finish a running build')
bryantaylor 0:eafc3fd41f75 350 finish_build_parser.add_argument('-b', '--build-id', required=True, help='build id')
bryantaylor 0:eafc3fd41f75 351 finish_build_parser.set_defaults(func=finish_build)
bryantaylor 0:eafc3fd41f75 352
bryantaylor 0:eafc3fd41f75 353 finish_build_parser = subparsers.add_parser('promote-build', help='promote a build to a release')
bryantaylor 0:eafc3fd41f75 354 finish_build_parser.add_argument('-b', '--build-id', required=True, help='build id')
bryantaylor 0:eafc3fd41f75 355 finish_build_parser.set_defaults(func=promote_build)
bryantaylor 0:eafc3fd41f75 356
bryantaylor 0:eafc3fd41f75 357 abort_build_parser = subparsers.add_parser('abort-build', help='abort a running build')
bryantaylor 0:eafc3fd41f75 358 abort_build_parser.add_argument('-b', '--build-id', required=True, help='build id')
bryantaylor 0:eafc3fd41f75 359 abort_build_parser.set_defaults(func=abort_build)
bryantaylor 0:eafc3fd41f75 360
bryantaylor 0:eafc3fd41f75 361 add_project_runs_parser = subparsers.add_parser('add-project-runs', help='add project runs to a build')
bryantaylor 0:eafc3fd41f75 362 add_project_runs_parser.add_argument('-b', '--build-id', required=True, help='build id')
bryantaylor 0:eafc3fd41f75 363 add_project_runs_parser.add_argument('-r', '--build-report', required=False, help='path to junit xml build report')
bryantaylor 0:eafc3fd41f75 364 add_project_runs_parser.add_argument('-t', '--test-report', required=False, help='path to junit xml test report')
bryantaylor 0:eafc3fd41f75 365 add_project_runs_parser.add_argument('-o', '--host-os', required=True, help='host os on which test was run')
bryantaylor 0:eafc3fd41f75 366 add_project_runs_parser.add_argument('-l', '--limit', required=False, type=int, default=1000, help='Limit the number of project runs sent at a time to avoid HTTP errors (default is 1000)')
bryantaylor 0:eafc3fd41f75 367 add_project_runs_parser.set_defaults(func=add_project_runs)
bryantaylor 0:eafc3fd41f75 368
bryantaylor 0:eafc3fd41f75 369 args = parser.parse_args(arguments)
bryantaylor 0:eafc3fd41f75 370 args.func(args)
bryantaylor 0:eafc3fd41f75 371
bryantaylor 0:eafc3fd41f75 372 if __name__ == '__main__':
bryantaylor 0:eafc3fd41f75 373 main(sys.argv[1:])