Skip to content

Commit 48135c7

Browse files
committed
culebra: fixed START_ACTIVITY default value issue
- Version 0.9.10 - Refactoring
1 parent df9d55a commit 48135c7

1 file changed

Lines changed: 16 additions & 9 deletions

File tree

AndroidViewClient/tools/culebra

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ ___________________/ /__/ /__/ /__/ /________________________________
1919
\_____/--<
2020
@author: Diego Torres Milano
2121
@author: Jennifer E. Swofford (ascii art snake)
22+
2223
'''
2324

24-
__version__ = '0.9.8'
25+
__version__ = '0.9.10'
2526

2627
import re
2728
import sys
@@ -101,10 +102,13 @@ OPTS_HELP = {
101102

102103
ID_RE = re.compile('id/([^/]*)(/(\d+))?')
103104
AUTO_REGEXPS_RES = {'clock': re.compile('[012]\d:[0-5]\d')}
105+
SB_NO_JAR = 'no-jar'
106+
SB_JAR = 'jar'
107+
SB_JAR_LINUX = 'jar-linux'
104108
SHEBANG = {
105-
'no-jar': '#! /usr/bin/env monkeyrunner',
106-
'jar': '#! /usr/bin/env shebang monkeyrunner -plugin $ANDROID_VIEW_CLIENT_HOME/bin/androidviewclient-$ANDROID_VIEW_CLIENT_VERSION.jar @!',
107-
'jar-linux': '#! /usr/local/bin/shebang monkeyrunner -plugin $AVC_HOME/bin/androidviewclient-$AVC_VERSION.jar @!'
109+
SB_NO_JAR: '#! /usr/bin/env monkeyrunner',
110+
SB_JAR: '#! /usr/bin/env shebang monkeyrunner -plugin $ANDROID_VIEW_CLIENT_HOME/bin/androidviewclient-$ANDROID_VIEW_CLIENT_VERSION.jar @!',
111+
SB_JAR_LINUX: '#! /usr/local/bin/shebang monkeyrunner -plugin $AVC_HOME/bin/androidviewclient-$AVC_VERSION.jar @!'
108112
}
109113

110114
def shortAndLongOptions():
@@ -301,11 +305,14 @@ def getShebangJar():
301305
import java
302306
osName = java.lang.System.getProperty('os.name')
303307
if osName == 'Linux':
304-
return SHEBANG['jar-linux']
308+
return SHEBANG[SB_JAR_LINUX]
305309
else:
306-
return SHEBANG['jar']
310+
return SHEBANG[SB_JAR]
307311
else:
308-
return SHEBANG['no-jar']
312+
return SHEBANG[SB_NO_JAR]
313+
314+
def getWindowOption():
315+
return options[WINDOW] if isinstance(options[WINDOW], str) and options[WINDOW][0] in '-0123456789' else "'%s'" % options[WINDOW]
309316

310317
# __main__
311318
progname = os.path.basename(sys.argv[0])
@@ -321,7 +328,7 @@ kwargs2 = {'forceviewserveruse': False, 'startviewserver': True, 'autodump': Fal
321328
options = {FIND_VIEWS_BY_ID: True, FIND_VIEWS_WITH_TEXT: False, FIND_VIEWS_WITH_CONTENT_DESCRIPTION: False,
322329
USE_REGEXPS: False, VERBOSE_COMMENTS: False,
323330
UNIT_TEST: False, USE_JAR: True, USE_DICTIONARY: False, DICTIONARY_KEYS_FROM: 'id',
324-
AUTO_REGEXPS: None, OUTPUT: None,
331+
AUTO_REGEXPS: None, START_ACTIVITY: None, OUTPUT: None,
325332
WINDOW: -1}
326333
transform = traverseAndPrint
327334
for o, a in optlist:
@@ -441,7 +448,7 @@ device.startActivity(component='%s')
441448
print '''\
442449
vc = ViewClient(device, serialno, autodump=False)
443450
vc.dump(window=%s)
444-
''' % (options[WINDOW] if type(options[WINDOW]).__name__ == 'str' and options[WINDOW][0] in '-0123456789' else "'%s'" % options[WINDOW])
451+
''' % getWindowOption()
445452

446453
if options[USE_DICTIONARY]:
447454
print '''views = dict()'''

0 commit comments

Comments
 (0)