Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: build/android/screenshot.py

Issue 1124763003: Update from https://crrev.com/327068 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: update nacl, buildtools, fix display_change_notifier_unittest Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
15 from pylib import screenshot 14 from pylib import screenshot
15 from pylib.device import device_errors
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.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))
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 default=4, type='float') 59 default=4, type='float')
60 video_options.add_option('-r', '--rotate', help='Rotate video by 90 degrees.', 60 video_options.add_option('-r', '--rotate', help='Rotate video by 90 degrees.',
61 default=False, action='store_true') 61 default=False, action='store_true')
62 video_options.add_option('-s', '--size', metavar='WIDTHxHEIGHT', 62 video_options.add_option('-s', '--size', metavar='WIDTHxHEIGHT',
63 help='Frame size to use instead of the device ' 63 help='Frame size to use instead of the device '
64 'screen size.', default=None) 64 'screen size.', default=None)
65 parser.add_option_group(video_options) 65 parser.add_option_group(video_options)
66 66
67 (options, args) = parser.parse_args() 67 (options, args) = parser.parse_args()
68 68
69 if len(args) > 1:
70 parser.error('Too many positional arguments.')
71 host_file = args[0] if args else options.file
72
69 if options.verbose: 73 if options.verbose:
70 logging.getLogger().setLevel(logging.DEBUG) 74 logging.getLogger().setLevel(logging.DEBUG)
71 75
72 devices = android_commands.GetAttachedDevices() 76 devices = device_utils.DeviceUtils.HealthyDevices()
73 77
74 if not options.device and len(devices) > 1: 78 if not options.device:
75 parser.error('Multiple devices are attached. ' 79 if len(devices) > 1:
76 'Please specify device serial number with --device.') 80 parser.error('Multiple devices are attached. '
77 elif not options.device and len(devices) == 1: 81 'Please specify device serial number with --device.')
78 options.device = devices[0] 82 elif len(devices) == 1:
79 83 device = devices[0]
80 if len(args) > 1: 84 else:
81 parser.error('Too many positional arguments.') 85 raise device_errors.NoDevicesError()
82 host_file = args[0] if args else options.file 86 else:
83 device = device_utils.DeviceUtils(options.device) 87 device = device_utils.DeviceUtils(options.device)
84 88
85 if options.video: 89 if options.video:
86 _CaptureVideo(device, host_file, options) 90 _CaptureVideo(device, host_file, options)
87 else: 91 else:
88 _CaptureScreenshot(device, host_file) 92 _CaptureScreenshot(device, host_file)
89 return 0 93 return 0
90 94
91 95
92 if __name__ == '__main__': 96 if __name__ == '__main__':
93 sys.exit(main()) 97 sys.exit(main())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698