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 if options.blacklist_file: | 79 blacklist = (device_blacklist.Blacklist(options.blacklist_file) |
80 blacklist = device_blacklist.Blacklist(options.blacklist_file) | 80 if options.blacklist_file |
81 else: | 81 else None) |
82 blacklist = None | |
83 | 82 |
84 devices = device_utils.DeviceUtils.HealthyDevices(blacklist) | 83 devices = device_utils.DeviceUtils.HealthyDevices(blacklist) |
85 if options.device: | 84 if options.device: |
86 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) |
87 if not device: | 86 if not device: |
88 raise device_errors.DeviceUnreachableError(options.device) | 87 raise device_errors.DeviceUnreachableError(options.device) |
89 else: | 88 else: |
90 if len(devices) > 1: | 89 if len(devices) > 1: |
91 parser.error('Multiple devices are attached. ' | 90 parser.error('Multiple devices are attached. ' |
92 'Please specify device serial number with --device.') | 91 'Please specify device serial number with --device.') |
93 elif len(devices) == 1: | 92 elif len(devices) == 1: |
94 device = devices[0] | 93 device = devices[0] |
95 else: | 94 else: |
96 raise device_errors.NoDevicesError() | 95 raise device_errors.NoDevicesError() |
97 | 96 |
98 if options.video: | 97 if options.video: |
99 _CaptureVideo(device, host_file, options) | 98 _CaptureVideo(device, host_file, options) |
100 else: | 99 else: |
101 _CaptureScreenshot(device, host_file) | 100 _CaptureScreenshot(device, host_file) |
102 return 0 | 101 return 0 |
103 | 102 |
104 | 103 |
105 if __name__ == '__main__': | 104 if __name__ == '__main__': |
106 sys.exit(main()) | 105 sys.exit(main()) |
OLD | NEW |