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

Unified Diff: build/android/screenshot.py

Issue 11510009: [Android] screenshot.py: handle positional arguments. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/screenshot.py
diff --git a/build/android/screenshot.py b/build/android/screenshot.py
index e1dfdb3e159223ff11a73a2555979499c607f932..86607cc0649349b5991cac456cdeb3e7e5e3e8b8 100755
--- a/build/android/screenshot.py
+++ b/build/android/screenshot.py
@@ -6,7 +6,7 @@
"""Takes and saves a screenshot from an Android device.
-Usage: screenshot.py [-s SERIAL] [-f FILE]
+Usage: screenshot.py [-s SERIAL] [[-f] FILE]
Options:
-s SERIAL connect to device with specified SERIAL
@@ -20,27 +20,30 @@ import sys
from pylib import android_commands
-def main(argv):
+def main():
# Parse options.
- parser = OptionParser()
+ parser = OptionParser(usage='screenshot.py [-s SERIAL] [[-f] FILE]')
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)
+ (options, args) = parser.parse_args()
if not options.serial and len(android_commands.GetAttachedDevices()) > 1:
parser.error('Multiple devices are attached. '
'Please specify SERIAL with -s.')
+ if len(args) > 1:
+ parser.error('Too many positional arguments.')
+ filename = os.path.abspath(args[0] if args else options.filename)
+
# Grab screenshot and write to disk.
- filename = os.path.abspath(options.filename)
ac = android_commands.AndroidCommands(options.serial)
ac.TakeScreenshot(filename)
return 0
if __name__ == '__main__':
- sys.exit(main(sys.argv))
+ sys.exit(main())
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698