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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 | 69 |
70 (options, args) = parser.parse_args() | 70 (options, args) = parser.parse_args() |
71 | 71 |
72 if len(args) > 1: | 72 if len(args) > 1: |
73 parser.error('Too many positional arguments.') | 73 parser.error('Too many positional arguments.') |
74 host_file = args[0] if args else options.file | 74 host_file = args[0] if args else options.file |
75 | 75 |
76 if options.verbose: | 76 if options.verbose: |
77 logging.getLogger().setLevel(logging.DEBUG) | 77 logging.getLogger().setLevel(logging.DEBUG) |
78 | 78 |
79 blacklist = (device_blacklist.Blacklist(options.blacklist_file) | 79 if options.blacklist_file: |
80 if options.blacklist_file | 80 blacklist = device_blacklist.Blacklist(options.blacklist_file) |
81 else None) | 81 else: |
| 82 blacklist = None |
82 | 83 |
83 devices = device_utils.DeviceUtils.HealthyDevices(blacklist) | 84 devices = device_utils.DeviceUtils.HealthyDevices(blacklist) |
84 if options.device: | 85 if options.device: |
85 device = next((d for d in devices if d == options.device), None) | 86 device = next((d for d in devices if d == options.device), None) |
86 if not device: | 87 if not device: |
87 raise device_errors.DeviceUnreachableError(options.device) | 88 raise device_errors.DeviceUnreachableError(options.device) |
88 else: | 89 else: |
89 if len(devices) > 1: | 90 if len(devices) > 1: |
90 parser.error('Multiple devices are attached. ' | 91 parser.error('Multiple devices are attached. ' |
91 'Please specify device serial number with --device.') | 92 'Please specify device serial number with --device.') |
92 elif len(devices) == 1: | 93 elif len(devices) == 1: |
93 device = devices[0] | 94 device = devices[0] |
94 else: | 95 else: |
95 raise device_errors.NoDevicesError() | 96 raise device_errors.NoDevicesError() |
96 | 97 |
97 if options.video: | 98 if options.video: |
98 _CaptureVideo(device, host_file, options) | 99 _CaptureVideo(device, host_file, options) |
99 else: | 100 else: |
100 _CaptureScreenshot(device, host_file) | 101 _CaptureScreenshot(device, host_file) |
101 return 0 | 102 return 0 |
102 | 103 |
103 | 104 |
104 if __name__ == '__main__': | 105 if __name__ == '__main__': |
105 sys.exit(main()) | 106 sys.exit(main()) |
OLD | NEW |