blob: 2b2d6069c9a1fca84fd95d186a213b1c657f05b9 [file] [log] [blame]
Kuang-che Wu875c89a2020-01-08 14:30:55 +08001#!/usr/bin/env python3
Kuang-che Wu6e4beca2018-06-27 17:45:02 +08002# -*- coding: utf-8 -*-
Kuang-che Wu2ea804f2017-11-28 17:11:41 +08003# Copyright 2017 The Chromium OS Authors. All rights reserved.
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
Kuang-che Wu68db08a2018-03-30 11:50:34 +08006"""Helper script to manipulate chromeos DUT or query info."""
Kuang-che Wu2ea804f2017-11-28 17:11:41 +08007from __future__ import print_function
Kuang-che Wu5157dee2020-07-18 01:13:41 +08008import asyncio
Kuang-che Wu2ea804f2017-11-28 17:11:41 +08009import argparse
10import json
11import logging
Kuang-che Wu0c9b7942019-10-30 16:55:39 +080012import random
13import time
Kuang-che Wu2ea804f2017-11-28 17:11:41 +080014
Kuang-che Wufe1e88a2019-09-10 21:52:25 +080015from bisect_kit import cli
Kuang-che Wu2ea804f2017-11-28 17:11:41 +080016from bisect_kit import common
Kuang-che Wuc45cfa42019-01-15 00:15:01 +080017from bisect_kit import cros_lab_util
Kuang-che Wu2ea804f2017-11-28 17:11:41 +080018from bisect_kit import cros_util
Kuang-che Wu22aa9d42019-01-25 10:35:33 +080019from bisect_kit import errors
Kuang-che Wu2ea804f2017-11-28 17:11:41 +080020
Zheng-Jie Chang17f36c82020-06-16 05:21:59 +080021DEFAULT_DUT_POOL = 'DUT_POOL_QUOTA'
Kuang-che Wu2ea804f2017-11-28 17:11:41 +080022logger = logging.getLogger(__name__)
23
Kuang-che Wu25723422020-09-24 22:20:26 +080024models_to_avoid = {
25 # model: reason
26 'kasumi': 'b/160458394 stateful partition is too small',
27 'mimrock': 'b/160458394 stateful partition is too small',
28 'vorticon': 'b/160458394 stateful partition is too small',
29}
30
Kuang-che Wu2ea804f2017-11-28 17:11:41 +080031
32def cmd_version_info(opts):
33 info = cros_util.version_info(opts.board, opts.version)
34 if opts.name:
35 if opts.name not in info:
36 logger.error('unknown name=%s', opts.name)
37 print(info[opts.name])
38 else:
39 print(json.dumps(info, sort_keys=True, indent=4))
40
41
42def cmd_query_dut_board(opts):
43 assert cros_util.is_dut(opts.dut)
44 print(cros_util.query_dut_board(opts.dut))
45
46
47def cmd_reboot(opts):
48 assert cros_util.is_dut(opts.dut)
Kuang-che Wu2ac9a922020-09-03 16:50:12 +080049 cros_util.reboot(
50 opts.dut, force_reboot_callback=cros_lab_util.reboot_via_servo)
Kuang-che Wu2ea804f2017-11-28 17:11:41 +080051
52
Kuang-che Wuc45cfa42019-01-15 00:15:01 +080053def _get_label_by_prefix(info, prefix):
54 for label in info['Labels']:
55 if label.startswith(prefix + ':'):
56 return label
57 return None
58
59
Kuang-che Wuca456462019-11-04 17:32:55 +080060def cmd_lease_dut(opts):
Kuang-che Wu5157dee2020-07-18 01:13:41 +080061 if opts.duration is not None and opts.duration < 60:
62 raise errors.ArgumentError('--duration', 'must be at least 60 seconds')
Kuang-che Wu22aa9d42019-01-25 10:35:33 +080063 host = cros_lab_util.dut_host_name(opts.dut)
Kuang-che Wu220cc162019-10-31 00:29:37 +080064 logger.info('trying to lease %s', host)
65 if cros_lab_util.skylab_lease_dut(host, opts.duration):
Kuang-che Wuca456462019-11-04 17:32:55 +080066 logger.info('leased %s', host)
Kuang-che Wu22aa9d42019-01-25 10:35:33 +080067 else:
Kuang-che Wuca456462019-11-04 17:32:55 +080068 raise Exception('unable to lease %s' % host)
Kuang-che Wu22aa9d42019-01-25 10:35:33 +080069
70
Kuang-che Wuca456462019-11-04 17:32:55 +080071def cmd_release_dut(opts):
Kuang-che Wu22aa9d42019-01-25 10:35:33 +080072 host = cros_lab_util.dut_host_name(opts.dut)
Kuang-che Wu220cc162019-10-31 00:29:37 +080073 cros_lab_util.skylab_release_dut(host)
Kuang-che Wuca456462019-11-04 17:32:55 +080074 logger.info('%s released', host)
Kuang-che Wu22aa9d42019-01-25 10:35:33 +080075
76
Kuang-che Wu1e56ce22020-06-29 11:21:51 +080077def verify_dimensions_by_lab(dimensions):
78 result = []
79 bots_dimensions = cros_lab_util.swarming_bots_dimensions()
80 for dimension in dimensions:
81 key, value = dimension.split(':', 1)
82 if value in bots_dimensions.get(key, []):
83 result.append(dimension)
84 else:
85 logger.warning('dimension=%s is unknown in the lab, typo? ignored',
86 dimension)
87 return result
88
89
Kuang-che Wueac89bd2020-10-23 16:07:15 +080090def select_available_bots_randomly(dimensions,
91 variants,
92 num=1,
93 is_busy=None,
94 filter_func=None):
Kuang-che Wu1e56ce22020-06-29 11:21:51 +080095 bots = []
96 for variant in variants:
97 # There might be thousand bots available, set 'limit' to reduce swarming
98 # API cost. This is not uniform random, but should be good enough.
99 bots += cros_lab_util.swarming_bots_list(
100 dimensions + [variant], is_busy=is_busy, limit=10)
Kuang-che Wu25723422020-09-24 22:20:26 +0800101
Kuang-che Wueac89bd2020-10-23 16:07:15 +0800102 if filter_func:
103 bots = list(filter(filter_func, bots))
104 return random.sample(bots, min(num, len(bots)))
Kuang-che Wu5157dee2020-07-18 01:13:41 +0800105
106
Kuang-che Wub529d2d2020-09-10 12:26:56 +0800107def filter_dimensions_by_board(boards_with_prebuilt, dimensions):
108 result = []
109 for dimension in dimensions:
110 bots = cros_lab_util.swarming_bots_list([dimension], is_busy=None, limit=1)
111 if not bots:
112 continue
113 board = bots[0]['dimensions']['label-board'][0]
114 if board not in boards_with_prebuilt:
115 logger.warning(
116 'dimension=%s (board=%s) does not have corresponding '
117 'prebuilt image, ignore', dimension, board)
118 continue
119 result.append(dimension)
120 return result
121
122
Kuang-che Wueac89bd2020-10-23 16:07:15 +0800123def is_acceptable_bot(boards_with_prebuilt, bot):
124 model = bot['dimensions']['label-model'][0]
125 if model in models_to_avoid:
126 logger.warning('model=%s is bad (reason:%s), ignore', model,
127 models_to_avoid[model])
128 return False
129
Kuang-che Wu04619772020-10-22 18:57:07 +0800130 # Sometimes swarming database has inconsistent records. For example,
131 # label-model=kefka + label-board=strago are incorrect (should be
132 # label-board=kefka). It is probably human errors (strago is kefka's
133 # reference board).
Kuang-che Wueac89bd2020-10-23 16:07:15 +0800134 board = bot['dimensions']['label-board'][0]
135 if board not in boards_with_prebuilt:
136 logger.warning('%s has unexpected board=%s, ignore',
137 bot['dimensions']['dut_name'][0], board)
138 return False
139
140 return True
Kuang-che Wu04619772020-10-22 18:57:07 +0800141
142
Kuang-che Wu5157dee2020-07-18 01:13:41 +0800143async def lease_dut_parallelly(duration, bots, timeout=None):
144 tasks = []
145 hosts = []
146 for bot in bots:
147 host = bot['dimensions']['dut_name'][0]
148 hosts.append(host)
149 tasks.append(
150 asyncio.create_task(cros_lab_util.async_lease(host, duration=duration)))
151
152 try:
153 logger.info('trying to lease %d DUTs: %s', len(hosts), hosts)
154 for coro in asyncio.as_completed(tasks, timeout=timeout):
155 host = await coro
156 if host:
157 logger.info('leased %s', host)
Kuang-che Wub529d2d2020-09-10 12:26:56 +0800158 # Unfinished lease tasks will be cancelled when asyncio.run is
159 # finishing.
Kuang-che Wu5157dee2020-07-18 01:13:41 +0800160 return host
161 return None
162 except asyncio.TimeoutError:
163 return None
Kuang-che Wu1e56ce22020-06-29 11:21:51 +0800164
165
Kuang-che Wu22aa9d42019-01-25 10:35:33 +0800166def do_allocate_dut(opts):
167 """Helper of cmd_allocate_dut.
168
169 Returns:
Kuang-che Wub529d2d2020-09-10 12:26:56 +0800170 (todo, host, board_to_build)
Kuang-che Wu22aa9d42019-01-25 10:35:33 +0800171 todo: 'ready' or 'wait'
Kuang-che Wuca456462019-11-04 17:32:55 +0800172 host: leased host name
Kuang-che Wub529d2d2020-09-10 12:26:56 +0800173 board_to_build: board name for building image
Kuang-che Wu22aa9d42019-01-25 10:35:33 +0800174 """
Kuang-che Wu1e56ce22020-06-29 11:21:51 +0800175 if not opts.dut_name and not opts.pool:
176 raise errors.ArgumentError('--pool',
177 'need to be specified if not --dut_name')
Kuang-che Wu7e8abe62020-07-02 09:42:27 +0800178 if opts.version_hint:
179 for v in opts.version_hint.split(','):
180 if cros_util.is_cros_version(v) or cros_util.is_cros_snapshot_version(v):
181 continue
182 raise errors.ArgumentError(
183 '--version_hint',
184 'should be Chrome OS version numbers, separated by comma')
Kuang-che Wu5157dee2020-07-18 01:13:41 +0800185 if opts.duration is not None and opts.duration < 60:
186 raise errors.ArgumentError('--duration', 'must be at least 60 seconds')
Kuang-che Wu22aa9d42019-01-25 10:35:33 +0800187
Kuang-che Wuc26dcdf2019-11-01 16:30:06 +0800188 t0 = time.time()
Zheng-Jie Chang17f36c82020-06-16 05:21:59 +0800189 dimensions = ['dut_state:ready']
Kuang-che Wu1e56ce22020-06-29 11:21:51 +0800190 if not opts.dut_name:
Zheng-Jie Chang17f36c82020-06-16 05:21:59 +0800191 dimensions.append('label-pool:' + opts.pool)
192
Kuang-che Wu1e56ce22020-06-29 11:21:51 +0800193 variants = []
194 if opts.board:
195 for board in opts.board.split(','):
Kuang-che Wu1e56ce22020-06-29 11:21:51 +0800196 variants.append('label-board:' +
197 cros_lab_util.normalize_board_name(board))
Kuang-che Wu0c9b7942019-10-30 16:55:39 +0800198 if opts.model:
Kuang-che Wu1e56ce22020-06-29 11:21:51 +0800199 for model in opts.model.split(','):
Kuang-che Wu25723422020-09-24 22:20:26 +0800200 if model in models_to_avoid:
201 logger.warning('model=%s is bad (reason:%s), ignore', model,
202 models_to_avoid[model])
203 continue
Kuang-che Wu1e56ce22020-06-29 11:21:51 +0800204 variants.append('label-model:' + model)
Kuang-che Wu25723422020-09-24 22:20:26 +0800205 if not variants:
206 raise errors.ArgumentError('--model',
207 'all specified models are not supported')
Kuang-che Wu0c9b7942019-10-30 16:55:39 +0800208 if opts.sku:
Kuang-che Wu1e56ce22020-06-29 11:21:51 +0800209 for sku in opts.sku.split(','):
210 variants.append('label-hwid_sku:' + cros_lab_util.normalize_sku_name(sku))
211 if opts.dut_name:
212 for dut_name in opts.dut_name.split(','):
213 variants.append('dut_name:' + dut_name)
214
Kuang-che Wub529d2d2020-09-10 12:26:56 +0800215 variants = verify_dimensions_by_lab(variants)
216 variants = sorted(set(variants)) # dedup
217 if not variants:
218 raise errors.NoDutAvailable(
219 'Invalid constraints: %s;%s;%s;%s' %
220 (opts.board, opts.model, opts.sku, opts.dut_name))
221
222 # Filter variants by prebuilt images.
223 if opts.version_hint:
224 if not opts.builder_hint:
225 opts.builder_hint = opts.board
226 if not opts.builder_hint:
227 raise errors.ArgumentError('--builder_hint',
228 'must be specified along with --version_hint')
229 boards_with_prebuilt = []
230 versions = opts.version_hint.split(',')
231 for builder in opts.builder_hint.split(','):
232 if not all(cros_util.has_test_image(builder, v) for v in versions):
233 logger.warning(
234 'builder=%s does not have prebuilt test image for %s, ignore',
235 builder, opts.version_hint)
236 continue
237 boards_with_prebuilt.append(cros_lab_util.normalize_board_name(builder))
238 logger.info('boards with prebuilt: %s', boards_with_prebuilt)
239 if not boards_with_prebuilt:
240 raise errors.ArgumentError(
241 '--version_hint',
242 'given builders have no prebuilt for %s' % opts.version_hint)
243 variants = filter_dimensions_by_board(boards_with_prebuilt, variants)
244 if not variants:
245 raise errors.NoDutAvailable(
246 'Devices with specified constraints have no prebuilt. '
247 'Wrong version number?')
Kuang-che Wu0c9b7942019-10-30 16:55:39 +0800248
Kuang-che Wuc26dcdf2019-11-01 16:30:06 +0800249 while True:
Kuang-che Wueac89bd2020-10-23 16:07:15 +0800250 filter_func = lambda bot: is_acceptable_bot(boards_with_prebuilt, bot)
Kuang-che Wu5157dee2020-07-18 01:13:41 +0800251 # Query every time because each iteration takes a few minutes
252 bots = select_available_bots_randomly(
Kuang-che Wueac89bd2020-10-23 16:07:15 +0800253 dimensions,
254 variants,
255 num=opts.parallel,
256 is_busy=False,
257 filter_func=filter_func)
Kuang-che Wu5157dee2020-07-18 01:13:41 +0800258 if not bots:
259 bots = select_available_bots_randomly(
Kuang-che Wueac89bd2020-10-23 16:07:15 +0800260 dimensions,
261 variants,
262 num=opts.parallel,
263 is_busy=True,
264 filter_func=filter_func)
Kuang-che Wu5157dee2020-07-18 01:13:41 +0800265 if not bots:
Kuang-che Wu0c9b7942019-10-30 16:55:39 +0800266 raise errors.NoDutAvailable(
Kuang-che Wu1e56ce22020-06-29 11:21:51 +0800267 'no bots satisfy constraints; all are in maintenance state?')
Kuang-che Wu0c9b7942019-10-30 16:55:39 +0800268
Kuang-che Wuc26dcdf2019-11-01 16:30:06 +0800269 remaining_time = opts.time_limit - (time.time() - t0)
270 if remaining_time <= 0:
271 break
Kuang-che Wu5157dee2020-07-18 01:13:41 +0800272 timeout = min(120, remaining_time)
273 host = asyncio.run(lease_dut_parallelly(opts.duration, bots, timeout))
274 if host:
Kuang-che Wub529d2d2020-09-10 12:26:56 +0800275 # Resolve what board we should build during bisection.
276 board_to_build = None
277 bots = cros_lab_util.swarming_bots_list(['dut_name:' + host])
278 host_board = bots[0]['dimensions']['label-board'][0]
279 if opts.builder_hint:
280 for builder in opts.builder_hint.split(','):
281 if cros_lab_util.normalize_board_name(builder) == host_board:
282 board_to_build = builder
283 break
Kuang-che Wu04619772020-10-22 18:57:07 +0800284 else:
285 raise errors.DutLeaseException('DUT with unexpected board:%s' %
286 host_board)
Kuang-che Wub529d2d2020-09-10 12:26:56 +0800287 else:
288 board_to_build = host_board
289
290 return 'ready', host, board_to_build
Kuang-che Wuc26dcdf2019-11-01 16:30:06 +0800291 time.sleep(1)
Kuang-che Wu0c9b7942019-10-30 16:55:39 +0800292
Kuang-che Wuc26dcdf2019-11-01 16:30:06 +0800293 logger.warning('unable to lease DUT in time limit')
Kuang-che Wub529d2d2020-09-10 12:26:56 +0800294 return 'wait', None, None
Kuang-che Wu0c9b7942019-10-30 16:55:39 +0800295
296
Kuang-che Wu22aa9d42019-01-25 10:35:33 +0800297def cmd_allocate_dut(opts):
Kuang-che Wuca456462019-11-04 17:32:55 +0800298 leased_dut = None
Kuang-che Wu22aa9d42019-01-25 10:35:33 +0800299 try:
Kuang-che Wub529d2d2020-09-10 12:26:56 +0800300 todo, host, board = do_allocate_dut(opts)
Kuang-che Wu5157dee2020-07-18 01:13:41 +0800301 leased_dut = cros_lab_util.dut_name_to_address(host) if host else None
Kuang-che Wub529d2d2020-09-10 12:26:56 +0800302 result = {'result': todo, 'leased_dut': leased_dut, 'board': board}
Kuang-che Wu22aa9d42019-01-25 10:35:33 +0800303 print(json.dumps(result))
304 except Exception as e:
305 logger.exception('cmd_allocate_dut failed')
306 exception_name = e.__class__.__name__
307 result = {
308 'result': 'failed',
309 'exception': exception_name,
310 'text': str(e),
311 }
312 print(json.dumps(result))
Kuang-che Wu22aa9d42019-01-25 10:35:33 +0800313
314
Kuang-che Wua8c3c3e2019-08-28 18:49:28 +0800315def cmd_repair_dut(opts):
316 cros_lab_util.repair(opts.dut)
317
318
Kuang-che Wufe1e88a2019-09-10 21:52:25 +0800319@cli.fatal_error_handler
Kuang-che Wu2ea804f2017-11-28 17:11:41 +0800320def main():
321 common.init()
322 parser = argparse.ArgumentParser()
Kuang-che Wufe1e88a2019-09-10 21:52:25 +0800323 cli.patching_argparser_exit(parser)
Kuang-che Wu2ea804f2017-11-28 17:11:41 +0800324 common.add_common_arguments(parser)
325 subparsers = parser.add_subparsers(
326 dest='command', title='commands', metavar='<command>')
327
328 parser_version_info = subparsers.add_parser(
329 'version_info',
330 help='Query version info of given chromeos build',
331 description='Given chromeos `board` and `version`, '
332 'print version information of components.')
333 parser_version_info.add_argument(
334 'board', help='ChromeOS board name, like "samus".')
335 parser_version_info.add_argument(
336 'version',
337 type=cros_util.argtype_cros_version,
338 help='ChromeOS version, like "9876.0.0" or "R62-9876.0.0"')
339 parser_version_info.add_argument(
340 'name',
341 nargs='?',
342 help='Component name. If specified, output its version string. '
343 'Otherwise output all version info as dict in json format.')
344 parser_version_info.set_defaults(func=cmd_version_info)
345
346 parser_query_dut_board = subparsers.add_parser(
347 'query_dut_board', help='Query board name of given DUT')
348 parser_query_dut_board.add_argument('dut')
349 parser_query_dut_board.set_defaults(func=cmd_query_dut_board)
350
351 parser_reboot = subparsers.add_parser(
352 'reboot',
353 help='Reboot a DUT',
354 description='Reboot a DUT and verify the reboot is successful.')
355 parser_reboot.add_argument('dut')
356 parser_reboot.set_defaults(func=cmd_reboot)
357
Kuang-che Wuca456462019-11-04 17:32:55 +0800358 parser_lease_dut = subparsers.add_parser(
359 'lease_dut',
360 help='Lease a DUT in the lab',
361 description='Lease a DUT in the lab. '
362 'This is implemented by `skylab lease-dut` with additional checking.')
363 # "skylab lease-dut" doesn't take reason, so this is not required=True.
364 parser_lease_dut.add_argument('--session', help='session name')
365 parser_lease_dut.add_argument('dut')
366 parser_lease_dut.add_argument(
367 '--duration',
368 type=float,
369 help='duration in seconds; will be round to minutes')
370 parser_lease_dut.set_defaults(func=cmd_lease_dut)
371
372 parser_release_dut = subparsers.add_parser(
373 'release_dut',
374 help='Release a DUT in the lab',
375 description='Release a DUT in the lab. '
376 'This is implemented by `skylab release-dut` with additional checking.')
377 parser_release_dut.add_argument('--session', help='session name')
378 parser_release_dut.add_argument('dut')
379 parser_release_dut.set_defaults(func=cmd_release_dut)
380
Kuang-che Wu22aa9d42019-01-25 10:35:33 +0800381 parser_allocate_dut = subparsers.add_parser(
382 'allocate_dut',
383 help='Allocate a DUT in the lab',
Kuang-che Wuca456462019-11-04 17:32:55 +0800384 description='Allocate a DUT in the lab. It will lease a DUT in the lab '
385 'for bisecting. The caller (bisect-kit runner) of this command should '
386 'retry this command again later if no DUT available now.')
Kuang-che Wu22aa9d42019-01-25 10:35:33 +0800387 parser_allocate_dut.add_argument(
388 '--session', required=True, help='session name')
389 parser_allocate_dut.add_argument(
Kuang-che Wub529d2d2020-09-10 12:26:56 +0800390 '--pool',
391 help='Pool to search DUT (default: %(default)s)',
392 default=DEFAULT_DUT_POOL)
Kuang-che Wu1e56ce22020-06-29 11:21:51 +0800393 group = parser_allocate_dut.add_mutually_exclusive_group(required=True)
394 group.add_argument('--board', help='allocation criteria; comma separated')
395 group.add_argument('--model', help='allocation criteria; comma separated')
396 group.add_argument('--sku', help='allocation criteria; comma separated')
397 group.add_argument('--dut_name', help='allocation criteria; comma separated')
Kuang-che Wu22aa9d42019-01-25 10:35:33 +0800398 parser_allocate_dut.add_argument(
Kuang-che Wu1e56ce22020-06-29 11:21:51 +0800399 '--version_hint', help='chromeos version; comma separated')
Kuang-che Wub529d2d2020-09-10 12:26:56 +0800400 parser_allocate_dut.add_argument(
401 '--builder_hint', help='chromeos builder; comma separated')
Kuang-che Wuc26dcdf2019-11-01 16:30:06 +0800402 # Pubsub ack deadline is 10 minutes (b/143663659). Default 9 minutes with 1
403 # minute buffer.
Kuang-che Wu22aa9d42019-01-25 10:35:33 +0800404 parser_allocate_dut.add_argument(
Kuang-che Wu0c9b7942019-10-30 16:55:39 +0800405 '--time_limit',
406 type=int,
Kuang-che Wuc26dcdf2019-11-01 16:30:06 +0800407 default=9 * 60,
Kuang-che Wu0c9b7942019-10-30 16:55:39 +0800408 help='Time limit to attempt lease in seconds (default: %(default)s)')
409 parser_allocate_dut.add_argument(
410 '--duration',
411 type=float,
412 help='lease duration in seconds; will be round to minutes')
Kuang-che Wu5157dee2020-07-18 01:13:41 +0800413 parser_allocate_dut.add_argument(
414 '--parallel',
415 type=int,
416 default=1,
417 help='Submit multiple lease tasks to speed up (default: %(default)d)')
Kuang-che Wu22aa9d42019-01-25 10:35:33 +0800418 parser_allocate_dut.set_defaults(func=cmd_allocate_dut)
419
Kuang-che Wua8c3c3e2019-08-28 18:49:28 +0800420 parser_repair_dut = subparsers.add_parser(
421 'repair_dut',
422 help='Repair a DUT in the lab',
423 description='Repair a DUT in the lab. '
424 'This is simply wrapper of "deploy repair" with additional checking.')
425 parser_repair_dut.add_argument('dut')
426 parser_repair_dut.set_defaults(func=cmd_repair_dut)
427
Kuang-che Wu2ea804f2017-11-28 17:11:41 +0800428 opts = parser.parse_args()
429 common.config_logging(opts)
Kuang-che Wud3a4e842019-12-11 12:15:23 +0800430
431 # It's optional by default since python3.
432 if not opts.command:
433 parser.error('command is missing')
Kuang-che Wu2ea804f2017-11-28 17:11:41 +0800434 opts.func(opts)
435
436
437if __name__ == '__main__':
438 main()