Skip to content

Commit 5343b8e

Browse files
committed
dump.py: Added -F|--force-view-server-use options
- Sometimes, even if UiAutomator is available you want to stick to ViewServer (perhaps to get the View id's), this option enables it
1 parent 5450c6e commit 5343b8e

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

AndroidViewClient/examples/dump.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
from com.dtmilano.android.viewclient import ViewClient
3030

3131
VERBOSE = 'verbose'
32+
FORCE_VIEW_SERVER_USE = 'force-view-server-use'
3233
UNIQUE_ID = 'uniqueId'
3334
POSITION = 'position'
3435
CONTENT_DESCRIPTION = 'content-description'
@@ -40,24 +41,27 @@
4041
}
4142

4243
def usage():
43-
print >> sys.stderr, 'usage: dump.py [-V|--%s] [-u|--%s] [-x|--%s] [-d|--%s] [-c|--%s] [serialno]' % \
44-
(VERBOSE, UNIQUE_ID, POSITION, CONTENT_DESCRIPTION, CENTER)
44+
print >> sys.stderr, 'usage: dump.py [-V|--%s] [-F|--%s] [-u|--%s] [-x|--%s] [-d|--%s] [-c|--%s] [serialno]' % \
45+
(VERBOSE, FORCE_VIEW_SERVER_USE, UNIQUE_ID, POSITION, CONTENT_DESCRIPTION, CENTER)
4546
sys.exit(1)
4647

4748
try:
48-
opts, args = getopt.getopt(sys.argv[1:], 'Vuxdc',
49-
[VERBOSE, UNIQUE_ID, POSITION, CONTENT_DESCRIPTION, CENTER])
49+
opts, args = getopt.getopt(sys.argv[1:], 'VFuxdc',
50+
[VERBOSE, FORCE_VIEW_SERVER_USE, UNIQUE_ID, POSITION, CONTENT_DESCRIPTION, CENTER])
5051
except getopt.GetoptError, e:
5152
print >>sys.stderr, 'ERROR:', str(e)
5253
usage()
5354

5455
verbose = False
56+
kwargs = {'forceviewserveruse': False}
5557
transform = ViewClient.TRAVERSE_CIT
5658
for o, a in opts:
5759
o = o.strip('-')
5860
if o in ['V', VERBOSE]:
5961
verbose = True
60-
continue
61-
transform = MAP[o]
62+
elif o in ['F', FORCE_VIEW_SERVER_USE]:
63+
kwargs['forceviewserveruse'] = True
64+
else:
65+
transform = MAP[o]
6266

63-
ViewClient(*ViewClient.connectToDeviceOrExit(verbose=verbose)).traverse(transform=transform)
67+
ViewClient(*ViewClient.connectToDeviceOrExit(verbose=verbose), **kwargs).traverse(transform=transform)

0 commit comments

Comments
 (0)