Skip to content

Commit a7114ca

Browse files
committed
More explicit error message when 'adb' is not found
- Version 11.0.10 - Fixed uiAutomatorHelper member creation to happen before 'adb' is checked
1 parent f2c2c31 commit a7114ca

11 files changed

Lines changed: 55 additions & 31 deletions

File tree

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from setuptools import setup, find_packages
44

55
setup(name='androidviewclient',
6-
version='11.0.9',
6+
version='11.0.10',
77
description='''AndroidViewClient is a 100% pure python library and tools
88
that simplifies test script creation providing higher level
99
operations and the ability of obtaining the tree of Views present at

src/com/dtmilano/android/adb/adbclient.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
'''
1919
import threading
2020

21-
__version__ = '11.0.9'
21+
__version__ = '11.0.10'
2222

2323
import sys
2424
import warnings

src/com/dtmilano/android/common.py

Lines changed: 43 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,21 @@
2020
import platform
2121
import os
2222

23+
2324
def _nd(name):
2425
'''
2526
@return: Returns a named decimal regex
2627
'''
2728
return '(?P<%s>\d+)' % name
2829

30+
2931
def _nh(name):
3032
'''
3133
@return: Returns a named hex regex
3234
'''
3335
return '(?P<%s>[0-9a-f]+)' % name
3436

37+
3538
def _ns(name, greedy=False):
3639
'''
3740
NOTICE: this is using a non-greedy (or minimal) regex
@@ -45,21 +48,25 @@ def _ns(name, greedy=False):
4548
'''
4649
return '(?P<%s>\S+%s)' % (name, '' if greedy else '?')
4750

51+
4852
def obtainPxPy(m):
4953
px = int(m.group('px'))
5054
py = int(m.group('py'))
5155
return (px, py)
5256

57+
5358
def obtainVxVy(m):
5459
wvx = int(m.group('vx'))
5560
wvy = int(m.group('vy'))
5661
return wvx, wvy
5762

63+
5864
def obtainVwVh(m):
5965
(wvx, wvy) = obtainVxVy(m)
6066
wvx1 = int(m.group('vx1'))
6167
wvy1 = int(m.group('vy1'))
62-
return (wvx1-wvx, wvy1-wvy)
68+
return (wvx1 - wvx, wvy1 - wvy)
69+
6370

6471
def obtainAdbPath():
6572
'''
@@ -69,58 +76,74 @@ def obtainAdbPath():
6976
osName = platform.system()
7077
isWindows = False
7178
adb = 'adb'
72-
79+
7380
if (osName.startswith('Windows')) or (osName.startswith('Java')):
74-
envOSName = os.getenv('os') #this should work as it has been set since xp.
81+
envOSName = os.getenv('os') # this should work as it has been set since xp.
7582
if envOSName.startswith('Windows'):
76-
adb = 'adb.exe'
77-
isWindows = True
83+
adb = 'adb.exe'
84+
isWindows = True
7885

7986
ANDROID_HOME = os.environ['ANDROID_HOME'] if os.environ.has_key('ANDROID_HOME') else '/opt/android-sdk'
8087
HOME = os.environ['HOME'] if os.environ.has_key('HOME') else ''
8188

82-
possibleChoices = [ os.path.join(ANDROID_HOME, 'platform-tools', adb),
83-
os.path.join(HOME, "android", 'platform-tools', adb),
84-
os.path.join(HOME, "android-sdk", 'platform-tools', adb),
89+
possibleChoices = [os.path.join(ANDROID_HOME, 'platform-tools', adb),
90+
os.path.join(HOME, "android", 'platform-tools', adb),
91+
os.path.join(HOME, "android-sdk", 'platform-tools', adb),
8592
]
8693

8794
if osName.startswith('Windows'):
8895
possibleChoices.append(os.path.join("""C:\Program Files\Android\android-sdk\platform-tools""", adb))
8996
possibleChoices.append(os.path.join("""C:\Program Files (x86)\Android\android-sdk\platform-tools""", adb))
9097
elif osName.startswith('Linux'):
91-
possibleChoices.append(os.path.join("opt", "android-sdk-linux", 'platform-tools', adb))
92-
possibleChoices.append(os.path.join(HOME, "opt", "android-sdk-linux", 'platform-tools', adb))
93-
possibleChoices.append(os.path.join(HOME, "android-sdk-linux", 'platform-tools', adb))
94-
possibleChoices.append(os.path.join(HOME, 'Android', 'Sdk', 'platform-tools', adb))
98+
possibleChoices.append(os.path.join("opt", "android-sdk-linux", 'platform-tools', adb))
99+
possibleChoices.append(os.path.join(HOME, "opt", "android-sdk-linux", 'platform-tools', adb))
100+
possibleChoices.append(os.path.join(HOME, "android-sdk-linux", 'platform-tools', adb))
101+
possibleChoices.append(os.path.join(HOME, 'Android', 'Sdk', 'platform-tools', adb))
95102
elif osName.startswith('Mac'):
96-
possibleChoices.append(os.path.join("opt", "android-sdk-mac_x86", 'platform-tools', adb))
97-
possibleChoices.append(os.path.join(HOME, "opt", "android-sdk-mac", 'platform-tools', adb))
98-
possibleChoices.append(os.path.join(HOME, "android-sdk-mac", 'platform-tools', adb))
99-
possibleChoices.append(os.path.join(HOME, "opt", "android-sdk-mac_x86", 'platform-tools', adb))
100-
possibleChoices.append(os.path.join(HOME, "android-sdk-mac_x86", 'platform-tools', adb))
103+
possibleChoices.append(os.path.join(HOME, "Library", "Android", "sdk", 'platform-tools', adb))
104+
possibleChoices.append(os.path.join("opt", "android-sdk-mac_x86", 'platform-tools', adb))
105+
possibleChoices.append(os.path.join(HOME, "opt", "android-sdk-mac", 'platform-tools', adb))
106+
possibleChoices.append(os.path.join(HOME, "android-sdk-mac", 'platform-tools', adb))
107+
possibleChoices.append(os.path.join(HOME, "opt", "android-sdk-mac_x86", 'platform-tools', adb))
108+
possibleChoices.append(os.path.join(HOME, "android-sdk-mac_x86", 'platform-tools', adb))
101109
else:
102110
# Unsupported OS
103111
pass
104112

105113
possibleChoices.append(adb)
106-
114+
115+
checkedFiles = []
116+
107117
for exeFile in possibleChoices:
118+
checkedFiles.append(exeFile)
108119
if os.access(exeFile, os.X_OK):
109120
return exeFile
110121

111122
for path in os.environ["PATH"].split(os.pathsep):
112123
exeFile = os.path.join(path, adb)
113-
if exeFile != None and os.access(exeFile, os.X_OK if not isWindows else os.F_OK):
124+
checkedFiles.append(exeFile)
125+
if exeFile is not None and os.access(exeFile, os.X_OK if not isWindows else os.F_OK):
114126
return exeFile
115127

116-
raise Exception('adb="%s" is not executable. Did you forget to set ANDROID_HOME in the environment?' % adb)
128+
if not os.environ['ANDROID_HOME']:
129+
helpMsg = 'Did you forget to set ANDROID_HOME in the environment?'
130+
else:
131+
helpMsg = ''
132+
133+
raise Exception('''adb="%s" is not executable. %s
134+
135+
These files we unsuccessfully checked to find a suitable '%s' executable:
136+
%s
137+
''' % (adb, helpMsg, adb, "\n ".join(checkedFiles)))
138+
117139

118140
def profileStart():
119141
import cProfile
120142
global profile
121143
profile = cProfile.Profile()
122144
profile.enable()
123145

146+
124147
def profileEnd():
125148
profile.disable()
126149
import StringIO, pstats

src/com/dtmilano/android/concertina.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import time
2626

2727
__author__ = 'diego'
28-
__version__ = '11.0.9'
28+
__version__ = '11.0.10'
2929

3030
DEBUG = True
3131

src/com/dtmilano/android/controlpanel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
@author: Ahmed Kasem
2020
'''
2121

22-
__version__ = '11.0.9'
22+
__version__ = '11.0.10'
2323

2424
import sys, os
2525
import Tkinter, tkFileDialog, ttk

src/com/dtmilano/android/culebron.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
from com.dtmilano.android.common import profileEnd
2727
from com.dtmilano.android.concertina import Concertina
2828

29-
__version__ = '11.0.9'
29+
__version__ = '11.0.10'
3030

3131
import sys
3232
import threading

src/com/dtmilano/android/robotframework/viewclientwrapper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
@author: Diego Torres Milano
1919
'''
2020

21-
__version__ = '11.0.9'
21+
__version__ = '11.0.10'
2222
__author__ = 'diego'
2323

2424
import sys

src/com/dtmilano/android/uiautomator/uiautomatorhelper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
@author: Diego Torres Milano
1919
'''
2020

21-
__version__ = '11.0.9'
21+
__version__ = '11.0.10'
2222

2323
import os
2424
import subprocess

src/com/dtmilano/android/viewclient.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2342,6 +2342,9 @@ def __init__(self, device, serialno, adb=None, autodump=True, forceviewserveruse
23422342
self.serialno = self.__mapSerialNo(serialno)
23432343
''' The serial number of the device '''
23442344

2345+
self.uiAutomatorHelper = None
2346+
''' The UiAutomatorHelper '''
2347+
23452348
if DEBUG_DEVICE: print >> sys.stderr, "ViewClient: using device with serialno", self.serialno
23462349

23472350
if adb:
@@ -2449,8 +2452,6 @@ def __init__(self, device, serialno, adb=None, autodump=True, forceviewserveruse
24492452
''' The list of windows as obtained by L{ViewClient.list()} '''
24502453

24512454

2452-
self.uiAutomatorHelper = None
2453-
''' The UiAutomatorHelper '''
24542455
# FIXME: may not be true, one may want UiAutomator but without UiAutomatorHelper
24552456
if self.useUiAutomator:
24562457
if useuiautomatorhelper:

tools/culebra

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ ___________________/ /__/ /__/ /__/ /________________________________
2020
2121
'''
2222

23-
__version__ = '11.0.9'
23+
__version__ = '11.0.10'
2424

2525
import re
2626
import sys

0 commit comments

Comments
 (0)