bug 624001 update devicemanager.py for reboot, getdirectory and isdir cleanup. r=mcote, a=NPOTB

This commit is contained in:
Joel Maher 2011-02-04 13:49:37 -05:00
parent ebf74d5e14
commit ae4f381afd

View File

@ -501,7 +501,7 @@ class DeviceManager:
timeslept = 0
while (timeslept <= 30):
process = self.processExist(appname)
if (self.process is not None):
if (process is not None):
break
time.sleep(3)
timeslept += 3
@ -743,14 +743,23 @@ class DeviceManager:
# copy directory structure from device (remoteDir) to host (localDir)
# external function
# checkDir exists so that we don't create local directories if the
# remote directory doesn't exist but also so that we don't call isDir
# twice when recursing.
# returns:
# success: list of files, string
# failure: None
def getDirectory(self, remoteDir, localDir):
def getDirectory(self, remoteDir, localDir, checkDir=True):
if (self.debug >= 2): print "getting files in '" + remoteDir + "'"
if checkDir:
try:
is_dir = self.isDir(remoteDir)
except FileError:
return None
if not is_dir:
return None
filelist = self.listFiles(remoteDir)
if (filelist == []):
return None
if (self.debug >= 3): print filelist
if not os.path.exists(localDir):
os.makedirs(localDir)
@ -766,7 +775,7 @@ class DeviceManager:
print 'isdir failed on file "%s"; continuing anyway...' % remotePath
continue
if is_dir:
if (self.getDirectory(remotePath, localPath) == None):
if (self.getDirectory(remotePath, localPath, False) == None):
print 'failed to get directory "%s"' % remotePath
return None
else:
@ -787,7 +796,10 @@ class DeviceManager:
try:
data = self.verifySendCMD(['isdir ' + remotePath])
except(DMError):
data = None
# normally there should be no error here; a nonexistent file/directory will
# return the string "<filename>: No such file or directory".
# However, I've seen AGENT-WARNING returned before.
return False
retVal = self.stripPrompt(data).strip()
if not retVal:
@ -971,17 +983,31 @@ class DeviceManager:
# returns:
# success: status from test agent
# failure: None
def reboot(self):
def reboot(self, wait = False):
cmd = 'rebt'
if (self.debug > 3): print "INFO: sending rebt command"
if (self.debug >= 3): print "INFO: sending rebt command"
try:
status = self.verifySendCMD([cmd])
status = self.sendCMD([cmd])
except DMError:
return None
if (self.debug > 3): print "INFO: rebt- got status back: " + str(status)
if (wait == True):
#this sleeps up to 5 minutes in 30 second intervals
count = 0
while (count < 10):
if (self.debug >= 4): print "DEBUG: sleeping 30 seconds while waiting for reboot"
time.sleep(30)
waitstatus = self.getDeviceRoot()
if (waitstatus is not None):
break
self.retries = 0
count += 1
if (count >= 10):
return None
if (self.debug >= 3): print "INFO: rebt- got status back: " + str(status)
return status
# validate localDir from host to remoteDir on the device