Skip to content

Commit e5d9814

Browse files
committed
check-import: improvements and more detailed messages
1 parent b9ad78c commit e5d9814

1 file changed

Lines changed: 21 additions & 3 deletions

File tree

AndroidViewClient/examples/check-import.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#! /usr/bin/env monkeyrunner
12
'''
23
Created on Aug 29, 2012
34
@@ -8,6 +9,10 @@
89
import sys
910
import os
1011

12+
debug = False
13+
if '--debug' in sys.argv or '-X' in sys.argv:
14+
debug = True
15+
1116
# PyDev sets PYTHONPATH, use it
1217
try:
1318
for p in os.environ['PYTHONPATH'].split(':'):
@@ -16,16 +21,29 @@
1621
except:
1722
pass
1823
try:
19-
sys.path.append(os.path.join(os.environ['ANDROID_VIEW_CLIENT_HOME'], 'src'))
24+
if os.environ.has_key('ANDROID_VIEW_CLIENT_HOME'):
25+
avcd = os.path.join(os.environ['ANDROID_VIEW_CLIENT_HOME'], 'src')
26+
if os.path.isdir(avcd):
27+
sys.path.append(avcd)
28+
else:
29+
print >>sys.stderr, "WARNING: '%s' is not a directory and is pointed by ANDROID_VIEW_CLIENT_HOME environment variable" % avcd
2030
except:
2131
pass
2232

23-
print >>sys.stderr, "sys.path=", sys.path
33+
if debug:
34+
print >>sys.stderr, "sys.path=", sys.path
35+
for d in sys.path:
36+
if d in [ '__classpath__', '__pyclasspath__/']:
37+
continue
38+
if not os.path.exists(d):
39+
if re.search('/Lib$', d):
40+
if not os.path.exists(re.sub('/Lib$', '', d)):
41+
print >>sys.stderr, "WARNING: '%s' is in sys.path but doesn't exist" % d
2442
import com
2543
import com.dtmilano
2644
import com.dtmilano.android
2745
import com.dtmilano.android.viewclient
2846
from com.dtmilano.android.viewclient import ViewClient, View
2947
print "OK"
3048

31-
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
49+
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice

0 commit comments

Comments
 (0)