Color Oled(SSD1331) connect to STMicroelectronics Nucleo-F466

Dependencies:   ssd1331

Committer:
kadonotakashi
Date:
Thu Oct 11 02:27:46 2018 +0000
Revision:
3:f3764f852aa8
Parent:
0:8fdf9a60065b
Nucreo 446 + SSD1331 test version;

Who changed what in which revision?

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