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

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

Issue 1089273002: Revert of [Android] Remove android_commands uses from build/android/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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
14 from pylib import screenshot 15 from pylib import screenshot
15 from pylib.device import adb_wrapper
16 from pylib.device import device_filter
17 from pylib.device import device_utils 16 from pylib.device import device_utils
18 17
19 def _PrintMessage(heading, eol='\n'): 18 def _PrintMessage(heading, eol='\n'):
20 sys.stdout.write('%s%s' % (heading, eol)) 19 sys.stdout.write('%s%s' % (heading, eol))
21 sys.stdout.flush() 20 sys.stdout.flush()
22 21
23 22
24 def _CaptureScreenshot(device, host_file): 23 def _CaptureScreenshot(device, host_file):
25 host_file = device.TakeScreenshot(host_file) 24 host_file = device.TakeScreenshot(host_file)
26 _PrintMessage('Screenshot written to %s' % os.path.abspath(host_file)) 25 _PrintMessage('Screenshot written to %s' % os.path.abspath(host_file))
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 video_options.add_option('-s', '--size', metavar='WIDTHxHEIGHT', 62 video_options.add_option('-s', '--size', metavar='WIDTHxHEIGHT',
64 help='Frame size to use instead of the device ' 63 help='Frame size to use instead of the device '
65 'screen size.', default=None) 64 'screen size.', default=None)
66 parser.add_option_group(video_options) 65 parser.add_option_group(video_options)
67 66
68 (options, args) = parser.parse_args() 67 (options, args) = parser.parse_args()
69 68
70 if options.verbose: 69 if options.verbose:
71 logging.getLogger().setLevel(logging.DEBUG) 70 logging.getLogger().setLevel(logging.DEBUG)
72 71
73 devices = adb_wrapper.AdbWrapper.Devices( 72 devices = android_commands.GetAttachedDevices()
74 filters=device_filter.DefaultFilters())
75 73
76 if not options.device and len(devices) > 1: 74 if not options.device and len(devices) > 1:
77 parser.error('Multiple devices are attached. ' 75 parser.error('Multiple devices are attached. '
78 'Please specify device serial number with --device.') 76 'Please specify device serial number with --device.')
79 elif not options.device and len(devices) == 1: 77 elif not options.device and len(devices) == 1:
80 options.device = devices[0] 78 options.device = devices[0]
81 79
82 if len(args) > 1: 80 if len(args) > 1:
83 parser.error('Too many positional arguments.') 81 parser.error('Too many positional arguments.')
84 host_file = args[0] if args else options.file 82 host_file = args[0] if args else options.file
85 device = device_utils.DeviceUtils(options.device) 83 device = device_utils.DeviceUtils(options.device)
86 84
87 if options.video: 85 if options.video:
88 _CaptureVideo(device, host_file, options) 86 _CaptureVideo(device, host_file, options)
89 else: 87 else:
90 _CaptureScreenshot(device, host_file) 88 _CaptureScreenshot(device, host_file)
91 return 0 89 return 0
92 90
93 91
94 if __name__ == '__main__': 92 if __name__ == '__main__':
95 sys.exit(main()) 93 sys.exit(main())
OLDNEW
« no previous file with comments | « build/android/pylib/local/device/local_device_environment.py ('k') | build/android/tombstones.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698