Bug 728927 - A few more minor exception conditions in DeviceManagerSUT. r=jmaher

This commit is contained in:
William Lachance 2012-02-21 09:10:42 -05:00
parent 4742e3f7df
commit 7d8303966f

View File

@ -209,17 +209,18 @@ class DeviceManagerSUT(DeviceManager):
self._sock = None self._sock = None
return None return None
# If something goes wrong in the agent it will send back a string that
# starts with '##AGENT-ERROR##'
if (self.agentErrorRE.match(temp)):
data = temp
break
data += temp data += temp
# If something goes wrong in the agent it will send back a string that
# starts with '##AGENT-ERROR##'
if self.agentErrorRE.match(data):
break
for line in data.splitlines(): for line in data.splitlines():
if (promptre.match(line)): if promptre.match(line):
found = True found = True
data = self._stripPrompt(data)
break
# If we violently lose the connection to the device, this loop tends to spin, # If we violently lose the connection to the device, this loop tends to spin,
# this guard prevents that # this guard prevents that
@ -238,7 +239,7 @@ class DeviceManagerSUT(DeviceManager):
# internal function # internal function
# take a data blob and strip instances of the prompt '$>\x00' # take a data blob and strip instances of the prompt '$>\x00'
def stripPrompt(self, data): def _stripPrompt(self, data):
promptre = re.compile(self.prompt_regex + '.*') promptre = re.compile(self.prompt_regex + '.*')
retVal = [] retVal = []
lines = data.split('\n') lines = data.split('\n')
@ -293,7 +294,7 @@ class DeviceManagerSUT(DeviceManager):
validated = False validated = False
if (retVal): if (retVal):
retline = self.stripPrompt(retVal).strip() retline = retVal.strip()
if (retline == None): if (retline == None):
# Then we failed to get back a hash from agent, try manual validation # Then we failed to get back a hash from agent, try manual validation
validated = self.validateFile(destname, localname) validated = self.validateFile(destname, localname)
@ -379,10 +380,8 @@ class DeviceManagerSUT(DeviceManager):
except(DMError): except(DMError):
return False return False
retVal = self.stripPrompt(data)
data = retVal.split('\n')
found = False found = False
for d in data: for d in data.splitlines():
if (dirre.match(d)): if (dirre.match(d)):
found = True found = True
@ -417,8 +416,7 @@ class DeviceManagerSUT(DeviceManager):
except(DMError): except(DMError):
return [] return []
retVal = self.stripPrompt(data) files = filter(lambda x: x, data.splitlines())
files = filter(lambda x: x, retVal.split('\n'))
if len(files) == 1 and files[0] == '<empty>': if len(files) == 1 and files[0] == '<empty>':
# special case on the agent: empty directories return just the string "<empty>" # special case on the agent: empty directories return just the string "<empty>"
return [] return []
@ -460,11 +458,9 @@ class DeviceManagerSUT(DeviceManager):
except DMError: except DMError:
return [] return []
retVal = self.stripPrompt(data)
lines = retVal.split('\n')
files = [] files = []
for line in lines: for line in data.splitlines():
if (line.strip() != ''): if line:
pidproc = line.strip().split() pidproc = line.strip().split()
if (len(pidproc) == 2): if (len(pidproc) == 2):
files += [[pidproc[0], pidproc[1]]] files += [[pidproc[0], pidproc[1]]]
@ -552,7 +548,7 @@ class DeviceManagerSUT(DeviceManager):
except(DMError): except(DMError):
return None return None
return self.stripPrompt(data).strip('\n') return data.strip()
# external function # external function
# returns: # returns:
@ -564,7 +560,7 @@ class DeviceManagerSUT(DeviceManager):
except(DMError): except(DMError):
return None return None
return self.stripPrompt(data) return data
# external function # external function
# returns: # returns:
@ -754,7 +750,8 @@ class DeviceManagerSUT(DeviceManager):
# return the string "<filename>: No such file or directory". # return the string "<filename>: No such file or directory".
# However, I've seen AGENT-WARNING returned before. # However, I've seen AGENT-WARNING returned before.
return False return False
retVal = self.stripPrompt(data).strip()
retVal = data.strip()
if not retVal: if not retVal:
raise FileError('isdir returned null') raise FileError('isdir returned null')
return retVal == 'TRUE' return retVal == 'TRUE'
@ -787,9 +784,9 @@ class DeviceManagerSUT(DeviceManager):
except(DMError): except(DMError):
return None return None
retVal = self.stripPrompt(data) retVal = None
if (retVal != None): if data:
retVal = retVal.strip('\n') retVal = data.strip()
if (self.debug >= 3): print "remote hash returned: '" + retVal + "'" if (self.debug >= 3): print "remote hash returned: '" + retVal + "'"
return retVal return retVal
@ -816,7 +813,7 @@ class DeviceManagerSUT(DeviceManager):
except: except:
return None return None
deviceRoot = self.stripPrompt(data).strip('\n') + '/tests' deviceRoot = data.strip() + '/tests'
if (not self.dirExists(deviceRoot)): if (not self.dirExists(deviceRoot)):
if (self.mkDir(deviceRoot) == None): if (self.mkDir(deviceRoot) == None):
@ -830,8 +827,7 @@ class DeviceManagerSUT(DeviceManager):
except: except:
return None return None
appRoot = self.stripPrompt(data).strip('\n') return data.strip()
return appRoot
# external function # external function
# returns: # returns:
@ -925,7 +921,6 @@ class DeviceManagerSUT(DeviceManager):
data = self.verifySendCMD(['info ' + d]) data = self.verifySendCMD(['info ' + d])
if (data is None): if (data is None):
continue continue
data = self.stripPrompt(data)
data = collapseSpaces.sub(' ', data) data = collapseSpaces.sub(' ', data)
result[d] = data.split('\n') result[d] = data.split('\n')
@ -1055,7 +1050,7 @@ class DeviceManagerSUT(DeviceManager):
except(DMError): except(DMError):
return None return None
return self.stripPrompt(data).strip('\n') return data.strip()
""" """
Connect the ipaddress and port for a callback ping. Defaults to current IP address Connect the ipaddress and port for a callback ping. Defaults to current IP address