5.2.1 - Updated I2C files

Dependents:   mbed-TFT-example-NCS36510 mbed-Accelerometer-example-NCS36510 mbed-Accelerometer-example-NCS36510

Committer:
jacobjohnson
Date:
Mon Feb 27 17:45:05 2017 +0000
Revision:
1:f30bdcd2b33b
Parent:
0:098463de4c5d
changed the inputscale from 1 to 7 in analogin_api.c.  This will need to be changed later, and accessed from the main level, but for now this allows the  adc to read a value from 0 to 3.7V, instead of just up to 1V.;

Who changed what in which revision?

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