OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright 2015 The Chromium Authors. All rights reserved. | 2 # Copyright 2015 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Utility for reading / writing command-line flag files on device(s).""" | 6 """Utility for reading / writing command-line flag files on device(s).""" |
7 | 7 |
8 import argparse | 8 import argparse |
| 9 import os |
9 import sys | 10 import sys |
10 | 11 |
11 import devil_chromium | 12 import devil_chromium |
12 | 13 |
13 from devil.android import device_utils | 14 from devil.android import device_utils |
14 from devil.android import device_errors | 15 from devil.android import device_errors |
15 from devil.utils import cmd_helper | 16 from devil.utils import cmd_helper |
16 | 17 |
17 | 18 |
18 def main(): | 19 def main(): |
19 parser = argparse.ArgumentParser(description=__doc__) | 20 parser = argparse.ArgumentParser(description=__doc__) |
20 parser.usage = '''%(prog)s --device-path PATH [--device SERIAL] [flags...] | 21 parser.usage = '''%(prog)s --device-path PATH [--device SERIAL] [flags...] |
21 | 22 |
22 No flags: Prints existing command-line file. | 23 No flags: Prints existing command-line file. |
23 Empty string: Deletes command-line file. | 24 Empty string: Deletes command-line file. |
24 Otherwise: Writes command-line file. | 25 Otherwise: Writes command-line file. |
25 | 26 |
26 ''' | 27 ''' |
27 parser.add_argument('-d', '--device', dest='devices', action='append', | 28 parser.add_argument('-d', '--device', dest='devices', action='append', |
28 default=[], help='Target device serial (repeatable).') | 29 default=[], help='Target device serial (repeatable).') |
29 parser.add_argument('--device-path', required=True, | 30 parser.add_argument('--device-path', required=True, |
30 help='Remote path to flags file.') | 31 help='Remote path to flags file.') |
31 parser.add_argument('-e', '--executable', dest='executable', default='chrome', | 32 parser.add_argument('-e', '--executable', dest='executable', default='chrome', |
32 help='Name of the executable.') | 33 help='Name of the executable.') |
| 34 parser.add_argument('--adb-path', type=os.path.abspath, |
| 35 help='Path to the adb binary.') |
33 args, remote_args = parser.parse_known_args() | 36 args, remote_args = parser.parse_known_args() |
34 | 37 |
35 devil_chromium.Initialize() | 38 devil_chromium.Initialize(adb_path=args.adb_path) |
36 | 39 |
37 as_root = not args.device_path.startswith('/data/local/tmp/') | 40 as_root = not args.device_path.startswith('/data/local/tmp/') |
38 | 41 |
39 devices = device_utils.DeviceUtils.HealthyDevices(device_arg=args.devices, | 42 devices = device_utils.DeviceUtils.HealthyDevices(device_arg=args.devices, |
40 default_retries=0) | 43 default_retries=0) |
41 all_devices = device_utils.DeviceUtils.parallel(devices) | 44 all_devices = device_utils.DeviceUtils.parallel(devices) |
42 | 45 |
43 def print_args(): | 46 def print_args(): |
44 def read_flags(device): | 47 def read_flags(device): |
45 try: | 48 try: |
(...skipping 29 matching lines...) Expand all Loading... |
75 device.RunShellCommand(['chmod', '0664', args.device_path], as_root=as_root) | 78 device.RunShellCommand(['chmod', '0664', args.device_path], as_root=as_root) |
76 | 79 |
77 all_devices.pMap(write_flags).pGet(None) | 80 all_devices.pMap(write_flags).pGet(None) |
78 print 'Wrote flags to %s' % args.device_path | 81 print 'Wrote flags to %s' % args.device_path |
79 print_args() | 82 print_args() |
80 return 0 | 83 return 0 |
81 | 84 |
82 | 85 |
83 if __name__ == '__main__': | 86 if __name__ == '__main__': |
84 sys.exit(main()) | 87 sys.exit(main()) |
OLD | NEW |