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 | |
|
frankf
2012/12/06 21:44:42
Two blank lines here.
| |
| 21 | |
| 22 def main(argv): | |
| 23 # Parse options. | |
| 24 parser = OptionParser() | |
| 25 parser.add_option("-s", "--serial", dest="serial", | |
|
frankf
2012/12/06 21:44:42
Use single quotes for consistency.
frankf
2012/12/06 21:50:14
Also, how does this behave if no serial is given a
| |
| 26 help="connect to device with specified SERIAL", | |
| 27 metavar="SERIAL", default=None) | |
| 28 parser.add_option("-f", "--file", dest="filename", | |
| 29 help="write screenshot to FILE (default: %default)", | |
| 30 metavar="FILE", default="Screenshot.png") | |
| 31 (options, args) = parser.parse_args(argv) | |
| 32 | |
| 33 # Grab screenshot and write to disk. | |
| 34 filename = os.path.abspath(options.filename) | |
| 35 ac = android_commands.AndroidCommands(options.serial) | |
| 36 ac.TakeScreenshot(filename) | |
| 37 return 0 | |
| 38 | |
| 39 if __name__ == '__main__': | |
| 40 sys.exit(main(sys.argv)) | |
| OLD | NEW |