| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 | 2 |
| 3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 """Takes a screenshot or a screen video capture from an Android device.""" | 7 """Takes a screenshot or a screen video capture from an Android device.""" |
| 8 | 8 |
| 9 import logging | 9 import logging |
| 10 import optparse | 10 import optparse |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 | 68 |
| 69 (options, args) = parser.parse_args() | 69 (options, args) = parser.parse_args() |
| 70 | 70 |
| 71 if len(args) > 1: | 71 if len(args) > 1: |
| 72 parser.error('Too many positional arguments.') | 72 parser.error('Too many positional arguments.') |
| 73 host_file = args[0] if args else options.file | 73 host_file = args[0] if args else options.file |
| 74 | 74 |
| 75 if options.verbose: | 75 if options.verbose: |
| 76 logging.getLogger().setLevel(logging.DEBUG) | 76 logging.getLogger().setLevel(logging.DEBUG) |
| 77 | 77 |
| 78 blacklist = (device_blacklist.Blacklist(options.blacklist_file) | 78 if options.blacklist_file: |
| 79 if options.blacklist_file | 79 blacklist = device_blacklist.Blacklist(options.blacklist_file) |
| 80 else None) | 80 else: |
| 81 blacklist = None |
| 81 | 82 |
| 82 devices = device_utils.DeviceUtils.HealthyDevices(blacklist) | 83 devices = device_utils.DeviceUtils.HealthyDevices(blacklist) |
| 83 if options.device: | 84 if options.device: |
| 84 device = next((d for d in devices if d == options.device), None) | 85 device = next((d for d in devices if d == options.device), None) |
| 85 if not device: | 86 if not device: |
| 86 raise device_errors.DeviceUnreachableError(options.device) | 87 raise device_errors.DeviceUnreachableError(options.device) |
| 87 else: | 88 else: |
| 88 if len(devices) > 1: | 89 if len(devices) > 1: |
| 89 parser.error('Multiple devices are attached. ' | 90 parser.error('Multiple devices are attached. ' |
| 90 'Please specify device serial number with --device.') | 91 'Please specify device serial number with --device.') |
| 91 elif len(devices) == 1: | 92 elif len(devices) == 1: |
| 92 device = devices[0] | 93 device = devices[0] |
| 93 else: | 94 else: |
| 94 raise device_errors.NoDevicesError() | 95 raise device_errors.NoDevicesError() |
| 95 | 96 |
| 96 if options.video: | 97 if options.video: |
| 97 _CaptureVideo(device, host_file, options) | 98 _CaptureVideo(device, host_file, options) |
| 98 else: | 99 else: |
| 99 _CaptureScreenshot(device, host_file) | 100 _CaptureScreenshot(device, host_file) |
| 100 return 0 | 101 return 0 |
| 101 | 102 |
| 102 | 103 |
| 103 if __name__ == '__main__': | 104 if __name__ == '__main__': |
| 104 sys.exit(main()) | 105 sys.exit(main()) |
| OLD | NEW |