Permalink
Browse files

Merge pull request #20 from dtmilano/dump-verbose

dump.py: Added verbose option (-V|--verbose)
  • Loading branch information...
2 parents 775b03b + b778e42 commit 2a5fae286cc0306a2e0285fabe01fbd0995f03d7 @dtmilano committed Jan 29, 2013
Showing with 12 additions and 6 deletions.
  1. +12 −6 AndroidViewClient/examples/dump.py
@@ -28,6 +28,7 @@
from com.dtmilano.android.viewclient import ViewClient
+VERBOSE = 'verbose'
UNIQUE_ID = 'uniqueId'
POSITION = 'position'
CONTENT_DESCRIPTION = 'content-description'
@@ -39,19 +40,24 @@
}
def usage():
- print >> sys.stderr, 'usage: dump.py [-u|--%s] [-x|--%s] [-d|--%s] [-c|--%s] [serialno]' % \
- (UNIQUE_ID, POSITION, CONTENT_DESCRIPTION, CENTER)
+ print >> sys.stderr, 'usage: dump.py [-V|--%s] [-u|--%s] [-x|--%s] [-d|--%s] [-c|--%s] [serialno]' % \
+ (VERBOSE, UNIQUE_ID, POSITION, CONTENT_DESCRIPTION, CENTER)
sys.exit(1)
try:
- opts, args = getopt.getopt(sys.argv[1:], 'uxdc',
- [UNIQUE_ID, POSITION, CONTENT_DESCRIPTION, CENTER])
+ opts, args = getopt.getopt(sys.argv[1:], 'Vuxdc',
+ [VERBOSE, UNIQUE_ID, POSITION, CONTENT_DESCRIPTION, CENTER])
except getopt.GetoptError, e:
print >>sys.stderr, 'ERROR:', str(e)
usage()
+verbose = True
transform = ViewClient.TRAVERSE_CIT
for o, a in opts:
- transform = MAP[o.strip('-')]
+ o = o.strip('-')
+ if o in ['V', VERBOSE]:
+ verbose = True
+ continue
+ transform = MAP[o]
-ViewClient(*ViewClient.connectToDeviceOrExit()).traverse(transform=transform)
+ViewClient(*ViewClient.connectToDeviceOrExit(verbose=verbose)).traverse(transform=transform)

0 comments on commit 2a5fae2

Please sign in to comment.