Bug 713970 - Restore accidentally removed changes and fix error handling in devicemanager. r=jmaher

This commit is contained in:
William Lachance 2012-01-26 13:56:51 -05:00
Родитель f7bd61e7ac
Коммит d0c0d177c4
1 изменённых файлов: 15 добавлений и 31 удалений

Просмотреть файл

@ -66,10 +66,10 @@ def abstractmethod(method):
line = method.func_code.co_firstlineno
filename = method.func_code.co_filename
def not_implemented(*args, **kwargs):
raise NotImplementedError('Abstract method %s at File "%s", line %s \
should be implemented by a concrete class' %
raise NotImplementedError('Abstract method %s at File "%s", line %s '
'should be implemented by a concrete class' %
(repr(method), filename,line))
return not_implemented
return not_implemented
class DeviceManager:
@ -236,14 +236,14 @@ class DeviceManager:
pieces = appname.split(' ')
parts = pieces[0].split('/')
app = parts[-1]
procre = re.compile('.*' + app + '.*')
procList = self.getProcessList()
if (procList == []):
return None
for proc in procList:
if (procre.match(proc[1])):
procName = proc[1].split('/')[-1]
if (procName == app):
pid = proc[0]
break
return pid
@ -379,6 +379,7 @@ class DeviceManager:
failure: None
"""
@abstractmethod
def getAppRoot(self):
"""
Either we will have /tests/fennec or /tests/firefox but we will never have
@ -390,26 +391,6 @@ class DeviceManager:
failure: None
"""
devroot = self.getDeviceRoot()
if (devroot == None):
return None
if (self.dirExists(devroot + '/fennec')):
return devroot + '/fennec'
elif (self.dirExists(devroot + '/firefox')):
return devroot + '/firefox'
elif (self.dirExsts('/data/data/org.mozilla.fennec')):
return 'org.mozilla.fennec'
elif (self.dirExists('/data/data/org.mozilla.firefox')):
return 'org.mozilla.firefox'
elif (self.dirExists('/data/data/org.mozilla.fennec_aurora')):
return 'org.mozilla.fennec_aurora'
elif (self.dirExists('/data/data/org.mozilla.firefox_beta')):
return 'org.mozilla.firefox_beta'
# Failure (either not installed or not a recognized platform)
return None
def getTestRoot(self, type):
"""
Gets the directory location on the device for a specific test type
@ -562,7 +543,10 @@ class NetworkTools:
return None
def getLanIp(self):
ip = socket.gethostbyname(socket.gethostname())
try:
ip = socket.gethostbyname(socket.gethostname())
except socket.gaierror:
ip = socket.gethostbyname(socket.gethostname() + ".local") # for Mac OS X
if ip.startswith("127.") and os.name != "nt":
interfaces = ["eth0","eth1","eth2","wlan0","wlan1","wifi0","ath0","ath1","ppp0"]
for ifname in interfaces: