Bug 1026710 - Fix errors in output handling in devicemanagerADB. r=armenzg
authorWilliam Lachance <wlachance@mozilla.com>
Fri, 18 Jul 2014 14:19:33 -0400
changeset 217126 c809edd9b1c37352484596c86aa950b60ce1fce1
parent 217125 a232fd36c82701cee208ce2a869d87e1400cb1ea
child 217127 1cda8d9d66ba29d142d3437aac4b28a4397c44e8
push id515
push userraliiev@mozilla.com
push dateMon, 06 Oct 2014 12:51:51 +0000
treeherdermozilla-release@267c7a481bef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersarmenzg
bugs1026710
milestone33.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1026710 - Fix errors in output handling in devicemanagerADB. r=armenzg
testing/mozbase/mozdevice/mozdevice/devicemanagerADB.py
--- a/testing/mozbase/mozdevice/mozdevice/devicemanagerADB.py
+++ b/testing/mozbase/mozdevice/mozdevice/devicemanagerADB.py
@@ -196,18 +196,18 @@ class DeviceManagerADB(DeviceManager):
                           (localname, destname))
         if not os.access(localname, os.F_OK):
             raise DMError("File not found: %s" % localname)
 
         self._checkCmd(["push", os.path.realpath(localname), destname],
                        retryLimit=retryLimit)
 
     def mkDir(self, name):
-        result = str(self._runCmd(["shell", "mkdir", name]).output)
-        if 'read-only file system' in result.lower():
+        result = self._runCmd(["shell", "mkdir", name]).output
+        if len(result) and 'read-only file system' in result[0].lower():
             raise DMError("Error creating directory: read only file system")
 
     def pushDir(self, localDir, remoteDir, retryLimit=None, timeout=None):
         # adb "push" accepts a directory as an argument, but if the directory
         # contains symbolic links, the links are pushed, rather than the linked
         # files; we either zip/unzip or re-copy the directory into a temporary
         # one to get around this limitation
         retryLimit = retryLimit or self.retryLimit
@@ -217,17 +217,17 @@ class DeviceManagerADB(DeviceManager):
             try:
                 localZip = tempfile.mktemp() + ".zip"
                 remoteZip = remoteDir + "/adbdmtmp.zip"
                 ProcessHandler(["zip", "-r", localZip, '.'], cwd=localDir,
                         processOutputLine=self._log).run().wait()
                 self.pushFile(localZip, remoteZip, retryLimit=retryLimit, createDir=False)
                 mozfile.remove(localZip)
                 data = self._runCmd(["shell", "unzip", "-o", remoteZip,
-                                     "-d", remoteDir]).output
+                                     "-d", remoteDir]).output[0]
                 self._checkCmd(["shell", "rm", remoteZip],
                                retryLimit=retryLimit, timeout=timeout)
                 if re.search("unzip: exiting", data) or re.search("Operation not permitted", data):
                     raise Exception("unzip failed, or permissions error")
             except:
                 self._logger.info("zip/unzip failure: falling back to normal push")
                 self._useZip = False
                 self.pushDir(localDir, remoteDir, retryLimit=retryLimit)
@@ -481,40 +481,39 @@ class DeviceManagerADB(DeviceManager):
         timestr = str(self._runCmd(["shell", "date", "+%s"]).output[0])
         if (not timestr or not timestr.isdigit()):
             raise DMError("Unable to get current time using date (got: '%s')" % timestr)
         return int(timestr)*1000
 
     def getInfo(self, directive=None):
         ret = {}
         if (directive == "id" or directive == "all"):
-            ret["id"] = self._runCmd(["get-serialno"]).output
+            ret["id"] = self._runCmd(["get-serialno"]).output[0]
         if (directive == "os" or directive == "all"):
-            ret["os"] = self._runCmd(["shell", "getprop", "ro.build.display.id"]).output
+            ret["os"] = self._runCmd(["shell", "getprop", "ro.build.display.id"]).output[0]
         if (directive == "uptime" or directive == "all"):
             utime = self._runCmd(["shell", "uptime"]).output[0]
             if (not utime):
                 raise DMError("error getting uptime")
             utime = utime[9:]
             hours = utime[0:utime.find(":")]
             utime = utime[utime[1:].find(":") + 2:]
             minutes = utime[0:utime.find(":")]
             utime = utime[utime[1:].find(":") +  2:]
             seconds = utime[0:utime.find(",")]
             ret["uptime"] = ["0 days " + hours + " hours " + minutes + " minutes " + seconds + " seconds"]
         if (directive == "process" or directive == "all"):
             ret["process"] = self._runCmd(["shell", "ps"]).output
         if (directive == "systime" or directive == "all"):
-            ret["systime"] = self._runCmd(["shell", "date"]).output
+            ret["systime"] = self._runCmd(["shell", "date"]).output[0]
         self._logger.info(ret)
         return ret
 
     def uninstallApp(self, appName, installPath=None):
-        data = self._runCmd(["uninstall", appName]).output.strip()
-        status = data.split('\n')[0].strip()
+        status = self._runCmd(["uninstall", appName]).output[0].strip()
         if status != 'Success':
             raise DMError("uninstall failed for %s. Got: %s" % (appName, status))
 
     def uninstallAppAndReboot(self, appName, installPath=None):
         self.uninstallApp(appName)
         self.reboot()
 
     def _runCmd(self, args):
@@ -633,17 +632,17 @@ class DeviceManagerADB(DeviceManager):
         # password or triggers the Android SuperUser prompt
         start_time = time.time()
         retcode = None
         while (time.time() - start_time) <= 15 and retcode is None:
             retcode = proc.poll()
         if retcode is None: # still not terminated, kill
             proc.kill()
 
-        data = proc.output
+        data = proc.output[0]
         if data.find('uid=0(root)') >= 0:
             self._haveSu = True
 
     def _isUnzipAvailable(self):
         data = self._runCmd(["shell", "unzip"]).output
         for line in data:
             if (re.search('Usage', line)):
                 return True