Chromium Code Reviews| Index: build/android/screenshot.py |
| diff --git a/build/android/screenshot.py b/build/android/screenshot.py |
| new file mode 100755 |
| index 0000000000000000000000000000000000000000..340f390476317ded0eba2c477963ffacba07d6eb |
| --- /dev/null |
| +++ b/build/android/screenshot.py |
| @@ -0,0 +1,47 @@ |
| +#!/usr/bin/env python |
| + |
| +# Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| + |
| +"""Takes and saves a screenshot from an Android device. |
| + |
| +Usage: screenshot.py [-s SERIAL] [-f FILE] |
| + |
| +Options: |
| + -s SERIAL connect to device with specified SERIAL |
| + -f FILE write screenshot to FILE (default: Screenshot.png) |
| +""" |
| + |
| +from optparse import OptionParser |
| +import os |
| +import sys |
| + |
| +from pylib import android_commands |
| + |
| + |
| +def main(argv): |
| + # Parse options. |
| + parser = OptionParser() |
| + parser.add_option('-s', '--serial', dest='serial', |
| + help='connect to device with specified SERIAL', |
| + metavar='SERIAL', default=None) |
| + parser.add_option('-f', '--file', dest='filename', |
| + help='write screenshot to FILE (default: %default)', |
| + metavar='FILE', default='Screenshot.png') |
| + (options, args) = parser.parse_args(argv) |
| + |
| + # Grab screenshot and write to disk. |
| + filename = os.path.abspath(options.filename) |
| + ac = android_commands.AndroidCommands(options.serial) |
| + try: |
| + ac.TakeScreenshot(filename) |
| + except: |
| + print ('Screenshot failed. If multiple devices are attached, be sure to ' |
|
frankf
2012/12/06 22:27:09
Actually, it'd be cleaner do explicitly check usin
newt (away)
2012/12/06 22:32:30
Exactly. Tommy had the same idea. Done.
|
| + 'specify SERIAL with -s.') |
| + raise |
| + return 0 |
| + |
| + |
| +if __name__ == '__main__': |
| + sys.exit(main(sys.argv)) |