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 sys | 9 import sys |
10 | 10 |
(...skipping 26 matching lines...) Expand all Loading... |
37 as_root = not args.device_path.startswith('/data/local/tmp/') | 37 as_root = not args.device_path.startswith('/data/local/tmp/') |
38 | 38 |
39 devices = device_utils.DeviceUtils.HealthyDevices(device_arg=args.devices, | 39 devices = device_utils.DeviceUtils.HealthyDevices(device_arg=args.devices, |
40 default_retries=0) | 40 default_retries=0) |
41 all_devices = device_utils.DeviceUtils.parallel(devices) | 41 all_devices = device_utils.DeviceUtils.parallel(devices) |
42 | 42 |
43 def print_args(): | 43 def print_args(): |
44 def read_flags(device): | 44 def read_flags(device): |
45 try: | 45 try: |
46 return device.ReadFile(args.device_path, as_root=as_root).rstrip() | 46 return device.ReadFile(args.device_path, as_root=as_root).rstrip() |
47 except device_errors.AdbCommandFailedError: | 47 except device_errors.CommandFailedError: |
48 return '' # File might not exist. | 48 return '' # File might not exist. |
49 | 49 |
50 descriptions = all_devices.pMap(lambda d: d.build_description).pGet(None) | 50 descriptions = all_devices.pMap(lambda d: d.build_description).pGet(None) |
51 flags = all_devices.pMap(read_flags).pGet(None) | 51 flags = all_devices.pMap(read_flags).pGet(None) |
52 for d, desc, flags in zip(devices, descriptions, flags): | 52 for d, desc, flags in zip(devices, descriptions, flags): |
53 print ' %s (%s): %r' % (d, desc, flags) | 53 print ' %s (%s): %r' % (d, desc, flags) |
54 | 54 |
55 # No args == print flags. | 55 # No args == print flags. |
56 if not remote_args: | 56 if not remote_args: |
57 print 'Existing flags (in %s):' % args.device_path | 57 print 'Existing flags (in %s):' % args.device_path |
(...skipping 17 matching lines...) Expand all Loading... |
75 device.RunShellCommand(['chmod', '0664', args.device_path], as_root=as_root) | 75 device.RunShellCommand(['chmod', '0664', args.device_path], as_root=as_root) |
76 | 76 |
77 all_devices.pMap(write_flags).pGet(None) | 77 all_devices.pMap(write_flags).pGet(None) |
78 print 'Wrote flags to %s' % args.device_path | 78 print 'Wrote flags to %s' % args.device_path |
79 print_args() | 79 print_args() |
80 return 0 | 80 return 0 |
81 | 81 |
82 | 82 |
83 if __name__ == '__main__': | 83 if __name__ == '__main__': |
84 sys.exit(main()) | 84 sys.exit(main()) |
OLD | NEW |