forked from dtmilano/AndroidViewClient
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdump.py
More file actions
executable file
·57 lines (46 loc) · 1.53 KB
/
dump.py
File metadata and controls
executable file
·57 lines (46 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#! /usr/bin/env monkeyrunner
'''
Copyright (C) 2012 Diego Torres Milano
Created on Feb 3, 2012
@author: diego
'''
import sys
import os
import getopt
# This must be imported before MonkeyRunner and MonkeyDevice,
# otherwise the import fails.
# PyDev sets PYTHONPATH, use it
try:
for p in os.environ['PYTHONPATH'].split(':'):
if not p in sys.path:
sys.path.append(p)
except:
pass
try:
sys.path.append(os.path.join(os.environ['ANDROID_VIEW_CLIENT_HOME'], 'src'))
except:
pass
from com.dtmilano.android.viewclient import ViewClient
UNIQUE_ID = 'uniqueId'
POSITION = 'position'
CONTENT_DESCRIPTION = 'content-description'
CENTER = 'center'
MAP = {'u':ViewClient.TRAVERSE_CITUI, UNIQUE_ID:ViewClient.TRAVERSE_CITUI,
'x':ViewClient.TRAVERSE_CITPS, POSITION:ViewClient.TRAVERSE_CITPS,
'd':ViewClient.TRAVERSE_CITCD, CONTENT_DESCRIPTION:ViewClient.TRAVERSE_CITCD,
'c':ViewClient.TRAVERSE_CITC, CENTER:ViewClient.TRAVERSE_CITC,
}
def usage():
print >> sys.stderr, 'usage: dump.py [-u|--%s] [-x|--%s] [-d|--%s] [-c|--%s] [serialno]' % \
(UNIQUE_ID, POSITION, CONTENT_DESCRIPTION, CENTER)
sys.exit(1)
try:
opts, args = getopt.getopt(sys.argv[1:], 'uxdc',
[UNIQUE_ID, POSITION, CONTENT_DESCRIPTION, CENTER])
except getopt.GetoptError, e:
print >>sys.stderr, 'ERROR:', str(e)
usage()
transform = ViewClient.TRAVERSE_CIT
for o, a in opts:
transform = MAP[o.strip('-')]
ViewClient(*ViewClient.connectToDeviceOrExit()).traverse(transform=transform)