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