Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/usr/bin/env python | |
| 2 | |
| 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 | |
| 5 # found in the LICENSE file. | |
| 6 | |
| 7 """Takes and saves a screenshot from an Android device. | |
| 8 | |
| 9 Usage: screenshot.py [-s SERIAL] [-f FILE] | |
| 10 | |
| 11 Options: | |
| 12 -s SERIAL connect to device with specified SERIAL | |
| 13 -f FILE write screenshot to FILE (default: Screenshot.png) | |
| 14 """ | |
| 15 | |
| 16 from optparse import OptionParser | |
| 17 import os | |
| 18 import sys | |
| 19 | |
| 20 from pylib import android_commands | |
| 21 | |
| 22 | |
| 23 def main(argv): | |
| 24 # Parse options. | |
| 25 parser = OptionParser() | |
| 26 parser.add_option('-s', '--serial', dest='serial', | |
| 27 help='connect to device with specified SERIAL', | |
| 28 metavar='SERIAL', default=None) | |
| 29 parser.add_option('-f', '--file', dest='filename', | |
| 30 help='write screenshot to FILE (default: %default)', | |
| 31 metavar='FILE', default='Screenshot.png') | |
| 32 (options, args) = parser.parse_args(argv) | |
| 33 | |
| 34 if options.serial is None and len(android_commands.GetAttachedDevices()) > 1: | |
|
frankf
2012/12/06 22:37:47
if not options.serial and len(android_commands.Get
newt (away)
2012/12/06 22:41:21
Done.
| |
| 35 print 'Multiple devices are attached. Please specify SERIAL with -s.' | |
| 36 return 1 | |
| 37 | |
| 38 # Grab screenshot and write to disk. | |
| 39 filename = os.path.abspath(options.filename) | |
| 40 ac = android_commands.AndroidCommands(options.serial) | |
| 41 ac.TakeScreenshot(filename) | |
| 42 return 0 | |
| 43 | |
| 44 | |
| 45 if __name__ == '__main__': | |
| 46 sys.exit(main(sys.argv)) | |
| OLD | NEW |