Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/usr/bin/env python | |
| 2 | |
| 3 # Copyright 2016 The Chromium 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. | |
| 6 | |
| 7 import argparse | |
| 8 import sys | |
| 9 | |
| 10 from devil.utils import battor_device_mapping | |
| 11 | |
| 12 def parse_options(): | |
| 13 """Parses and checks the command-line options. | |
| 14 | |
| 15 Returns: | |
| 16 A tuple containing the options structure. | |
| 17 """ | |
| 18 usage = 'Usage: ./update_mapping.py [options]' | |
| 19 desc = ('Example: ./update_mapping.py -o mapping.json.\n' | |
| 20 'This script generates and stores a file that gives the\n' | |
| 21 'mapping between phone serial numbers and BattOr serial numbers\n' | |
| 22 'Mapping is based on which physical ports on the USB hubs the\n' | |
| 23 'devices are plugged in to. For instance, if there are two hubs,\n' | |
| 24 'the phone connected to port N on the first hub is mapped to the\n' | |
| 25 'BattOr connected to port N on the second hub, for each N.') | |
| 26 parser = argparse.ArgumentParser(usage=usage, description=desc) | |
| 27 parser.add_argument('-o', '--output', dest='out_file', | |
| 28 default='mapping.json', type=str, | |
| 29 action='store', help='mapping file name') | |
| 30 parser.add_argument('-u', '--hubs', dest='hub_types', | |
| 31 default='plugable_7port', type=str, | |
| 32 action='store', help='List of usb hub types. ' | |
| 33 'Supported types:' | |
|
jbudorick
2016/03/31 20:57:31
Would choices be helpful here? https://docs.python
alexandermont
2016/03/31 22:11:18
Done
| |
| 34 ' plugable_7port = Plugable 7-Port Hub') | |
| 35 options = parser.parse_args() | |
| 36 options.hub_types = options.hub_types.split(',') | |
| 37 return options | |
| 38 | |
| 39 def main(): | |
| 40 options = parse_options() | |
| 41 battor_device_mapping.GenerateSerialMapFile(options.out_file, | |
| 42 options.hub_types) | |
| 43 | |
| 44 if __name__ == "__main__": | |
| 45 sys.exit(main()) | |
| OLD | NEW |