Skip to content

Commit f772da8

Browse files
committed
Fixed environment variable check
- Added FORCED_FAIL constant
1 parent a7114ca commit f772da8

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

src/com/dtmilano/android/common.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ def obtainAdbPath():
7373
Obtains the ADB path attempting know locations for different OSs
7474
'''
7575

76+
FORCE_FAIL = False
77+
''' Sometimes, you want it to fail to check the error messages '''
7678
osName = platform.system()
7779
isWindows = False
7880
adb = 'adb'
@@ -116,16 +118,16 @@ def obtainAdbPath():
116118

117119
for exeFile in possibleChoices:
118120
checkedFiles.append(exeFile)
119-
if os.access(exeFile, os.X_OK):
121+
if not FORCE_FAIL and os.access(exeFile, os.X_OK):
120122
return exeFile
121123

122124
for path in os.environ["PATH"].split(os.pathsep):
123125
exeFile = os.path.join(path, adb)
124126
checkedFiles.append(exeFile)
125-
if exeFile is not None and os.access(exeFile, os.X_OK if not isWindows else os.F_OK):
127+
if not FORCE_FAIL and exeFile is not None and os.access(exeFile, os.X_OK if not isWindows else os.F_OK):
126128
return exeFile
127129

128-
if not os.environ['ANDROID_HOME']:
130+
if not os.environ.has_key('ANDROID_HOME'):
129131
helpMsg = 'Did you forget to set ANDROID_HOME in the environment?'
130132
else:
131133
helpMsg = ''

0 commit comments

Comments
 (0)