| 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 |
| 11 import os | 11 import os |
| 12 import sys | 12 import sys |
| 13 | 13 |
| 14 from pylib import android_commands | 14 from pylib import android_commands |
| 15 from pylib import screenshot | 15 from pylib import screenshot |
| 16 from pylib.device import device_utils | 16 from pylib.device import device_utils |
| 17 | 17 |
| 18 def _PrintMessage(heading, eol='\n'): | 18 def _PrintMessage(heading, eol='\n'): |
| 19 sys.stdout.write('%s%s' % (heading, eol)) | 19 sys.stdout.write('%s%s' % (heading, eol)) |
| 20 sys.stdout.flush() | 20 sys.stdout.flush() |
| 21 | 21 |
| 22 | 22 |
| 23 def _CaptureScreenshot(device, host_file): | 23 def _CaptureScreenshot(device, host_file): |
| 24 host_file = device.old_interface.TakeScreenshot(host_file) | 24 host_file = device.TakeScreenshot(host_file) |
| 25 _PrintMessage('Screenshot written to %s' % os.path.abspath(host_file)) | 25 _PrintMessage('Screenshot written to %s' % os.path.abspath(host_file)) |
| 26 | 26 |
| 27 | 27 |
| 28 def _CaptureVideo(device, host_file, options): | 28 def _CaptureVideo(device, host_file, options): |
| 29 size = tuple(map(int, options.size.split('x'))) if options.size else None | 29 size = tuple(map(int, options.size.split('x'))) if options.size else None |
| 30 recorder = screenshot.VideoRecorder(device, | 30 recorder = screenshot.VideoRecorder(device, |
| 31 megabits_per_second=options.bitrate, | 31 megabits_per_second=options.bitrate, |
| 32 size=size, | 32 size=size, |
| 33 rotate=options.rotate) | 33 rotate=options.rotate) |
| 34 try: | 34 try: |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 | 80 |
| 81 if options.video: | 81 if options.video: |
| 82 _CaptureVideo(device, host_file, options) | 82 _CaptureVideo(device, host_file, options) |
| 83 else: | 83 else: |
| 84 _CaptureScreenshot(device, host_file) | 84 _CaptureScreenshot(device, host_file) |
| 85 return 0 | 85 return 0 |
| 86 | 86 |
| 87 | 87 |
| 88 if __name__ == '__main__': | 88 if __name__ == '__main__': |
| 89 sys.exit(main()) | 89 sys.exit(main()) |
| OLD | NEW |