Bug 720663 - devicemanagerADB pushDir fallback not always tried. r=gbrown

The devicemanagerADB.py pushDir method has two paths, one that uses zip/unzip
and the other that just pushes each file one at a time. The idea is that the
first path is chosen, and if it fails, the second is tried before bailing out,
but it's possible for the first failure not to be detected in such a way that
activates the fallback path.

Add a try/except block to catch exceptions in the first path and fall back to
the second.
This commit is contained in:
Chris Lord 2012-01-25 09:49:30 +00:00
parent 2dbd7b5621
commit 1649ace873

View File

@ -115,14 +115,17 @@ class DeviceManagerADB(DeviceManager):
if (not self.dirExists(remoteDir)):
self.mkDirs(remoteDir+"/x")
if (self.useZip):
localZip = tempfile.mktemp()+".zip"
remoteZip = remoteDir + "/adbdmtmp.zip"
subprocess.check_output(["zip", "-r", localZip, '.'], cwd=localDir)
self.pushFile(localZip, remoteZip)
os.remove(localZip)
data = self.runCmdAs(["shell", "unzip", "-o", remoteZip, "-d", remoteDir]).stdout.read()
self.checkCmdAs(["shell", "rm", remoteZip])
if (re.search("unzip: exiting", data) or re.search("Operation not permitted", data)):
try:
localZip = tempfile.mktemp()+".zip"
remoteZip = remoteDir + "/adbdmtmp.zip"
subprocess.check_output(["zip", "-r", localZip, '.'], cwd=localDir)
self.pushFile(localZip, remoteZip)
os.remove(localZip)
data = self.runCmdAs(["shell", "unzip", "-o", remoteZip, "-d", remoteDir]).stdout.read()
self.checkCmdAs(["shell", "rm", remoteZip])
if (re.search("unzip: exiting", data) or re.search("Operation not permitted", data)):
raise Exception("unzip failed, or permissions error")
except:
print "zip/unzip failure: falling back to normal push"
self.useZip = False
self.pushDir(localDir, remoteDir)