Bug 1310937 - Autophone - mozdevice - sync Bug 1300890 - Autophone - pylint fixes and logging clean up, r=jmaher.
authorBob Clary <bclary@bclary.com>
Wed, 19 Oct 2016 06:06:55 -0700
changeset 318542 7362a3b3d23989a2ced1ffd112a66ec300c77e40
parent 318541 f332f66d3c6b24d1b7d55725b854d9b4cf06099f
child 318543 5238fbaf49fa56ffa84a83dfa9cc92e9818671a4
push id82957
push userbclary@mozilla.com
push dateWed, 19 Oct 2016 13:07:48 +0000
treeherdermozilla-inbound@7362a3b3d239 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmaher
bugs1310937, 1300890
milestone52.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 1310937 - Autophone - mozdevice - sync Bug 1300890 - Autophone - pylint fixes and logging clean up, r=jmaher.
testing/mozbase/mozdevice/mozdevice/adb.py
testing/mozbase/mozdevice/mozdevice/adb_android.py
testing/mozbase/mozdevice/mozdevice/adb_b2g.py
--- a/testing/mozbase/mozdevice/mozdevice/adb.py
+++ b/testing/mozbase/mozdevice/mozdevice/adb.py
@@ -678,34 +678,33 @@ class ADBDevice(ADBCommand):
             if self.shell_output("id", timeout=timeout).find(uid) != -1:
                 self._have_root_shell = True
                 self._logger.info("adbd running as root")
         except ADBError:
             self._logger.debug("Check for root shell failed")
 
         # Do we need to run adb root to get a root shell?
         try:
-            if (not self._have_root_shell and
-                self.command_output(
+            if (not self._have_root_shell and self.command_output(
                     ["root"],
                     timeout=timeout).find("cannot run as root") == -1):
                 self._have_root_shell = True
                 self._logger.info("adbd restarted as root")
         except ADBError:
             self._logger.debug("Check for root adbd failed")
 
     @staticmethod
     def _escape_command_line(cmd):
         """Utility function to return escaped and quoted version of command
         line.
         """
         quoted_cmd = []
 
         for arg in cmd:
-            arg.replace('&', '\&')
+            arg.replace('&', r'\&')
 
             needs_quoting = False
             for char in [' ', '(', ')', '"', '&']:
                 if arg.find(char) >= 0:
                     needs_quoting = True
                     break
             if needs_quoting:
                 arg = "'%s'" % arg
@@ -1574,17 +1573,16 @@ class ADBDevice(ADBCommand):
             try:
                 data = self.shell_output("%s %s" % (self._ls, path),
                                          timeout=timeout,
                                          root=root).split('\r\n')
                 self._logger.debug('list_files: data: %s' % data)
             except ADBError:
                 self._logger.error('Ignoring exception in ADBDevice.list_files\n%s' %
                                    traceback.format_exc())
-                pass
         data[:] = [item for item in data if item]
         self._logger.debug('list_files: %s' % data)
         return data
 
     def ls(self, path, recursive=False, timeout=None, root=False):
         """Return a list of matching files/directories on the device.
 
         The ls method emulates the behavior of the ls shell command.
@@ -1868,17 +1866,17 @@ class ADBDevice(ADBCommand):
                 line = adb_process.stdout_file.readline()
             self._logger.debug('get_process_list: %s' % ret)
             return ret
         finally:
             if adb_process and isinstance(adb_process.stdout_file, file):
                 adb_process.stdout_file.close()
                 adb_process.stderr_file.close()
 
-    def kill(self, pids, sig=None,  attempts=3, wait=5,
+    def kill(self, pids, sig=None, attempts=3, wait=5,
              timeout=None, root=False):
         """Kills processes on the device given a list of process ids.
 
         :param list pids: process ids to be killed.
         :param sig: signal to be sent to the process.
         :type sig: integer or None
         :param integer attempts: number of attempts to try to
             kill the processes.
@@ -2181,17 +2179,17 @@ class ADBDevice(ADBCommand):
             may exceed this value. If it is not specified, the value
             set in the ADB constructor is used.
         :raises: * ADBTimeoutError
                  * ADBError
         """
         directives = ['battery', 'disk', 'id', 'os', 'process', 'systime',
                       'uptime']
 
-        if (directive in directives):
+        if directive in directives:
             directives = [directive]
 
         info = {}
         if 'battery' in directives:
             info['battery'] = self.get_battery_percentage(timeout=timeout)
         if 'disk' in directives:
             info['disk'] = self.shell_output('df /data /system /sdcard',
                                              timeout=timeout).splitlines()
@@ -2203,15 +2201,15 @@ class ADBDevice(ADBCommand):
         if 'process' in directives:
             ps = self.shell_output('ps', timeout=timeout)
             info['process'] = ps.splitlines()
         if 'systime' in directives:
             info['systime'] = self.shell_output('date', timeout=timeout)
         if 'uptime' in directives:
             uptime = self.shell_output('uptime', timeout=timeout)
             if uptime:
-                m = re.match('up time: ((\d+) days, )*(\d{2}):(\d{2}):(\d{2})',
+                m = re.match(r'up time: ((\d+) days, )*(\d{2}):(\d{2}):(\d{2})',
                              uptime)
                 if m:
                     uptime = '%d days %d hours %d minutes %d seconds' % tuple(
                         [int(g or 0) for g in m.groups()[1:]])
                 info['uptime'] = uptime
         return info
--- a/testing/mozbase/mozdevice/mozdevice/adb_android.py
+++ b/testing/mozbase/mozdevice/mozdevice/adb_android.py
@@ -193,19 +193,18 @@ class ADBAndroid(ADBDevice):
             failure = 'Unknown failure'
             success = True
             try:
                 state = self.get_state(timeout=timeout)
                 if state != 'device':
                     failure = "Device state: %s" % state
                     success = False
                 else:
-                    if (self.selinux and
-                        self.shell_output('getenforce',
-                                          timeout=timeout) != 'Permissive'):
+                    if (self.selinux and self.shell_output('getenforce',
+                                                           timeout=timeout) != 'Permissive'):
                         self._logger.info('Setting SELinux Permissive Mode')
                         self.shell_output("setenforce Permissive", timeout=timeout, root=True)
                     if self.is_dir(ready_path, timeout=timeout, root=True):
                         self.rmdir(ready_path, timeout=timeout, root=True)
                     self.mkdir(ready_path, timeout=timeout, root=True)
                     self.rmdir(ready_path, timeout=timeout, root=True)
                     # Invoke the pm list commands to see if it is up and
                     # running.
@@ -336,19 +335,19 @@ class ADBAndroid(ADBDevice):
         acmd = ["am", "start"] + \
             ["-W" if wait else '', "-n", "%s/%s" % (app_name, activity_name)]
 
         if intent:
             acmd.extend(["-a", intent])
 
         if extras:
             for (key, val) in extras.iteritems():
-                if type(val) is int:
+                if isinstance(val, int):
                     extra_type_param = "--ei"
-                elif type(val) is bool:
+                elif isinstance(val, bool):
                     extra_type_param = "--ez"
                 else:
                     extra_type_param = "--es"
                 acmd.extend([extra_type_param, str(key), str(val)])
 
         if url:
             acmd.extend(["-d", url])
 
@@ -393,18 +392,18 @@ class ADBAndroid(ADBDevice):
             for (env_count, (env_key, env_val)) in enumerate(moz_env.iteritems()):
                 extras["env" + str(env_count)] = env_key + "=" + env_val
 
         # Additional command line arguments that fennec will read and use (e.g.
         # with a custom profile)
         if extra_args:
             extras['args'] = " ".join(extra_args)
 
-        self.launch_application(app_name, "org.mozilla.gecko.BrowserApp", intent, url=url,
-                                extras=extras,
+        self.launch_application(app_name, "org.mozilla.gecko.BrowserApp",
+                                intent, url=url, extras=extras,
                                 wait=wait, fail_if_running=fail_if_running,
                                 timeout=timeout)
 
     def stop_application(self, app_name, timeout=None, root=False):
         """Stops the specified application
 
         For Android 3.0+, we use the "am force-stop" to do this, which
         is reliable and does not require root. For earlier versions of
--- a/testing/mozbase/mozdevice/mozdevice/adb_b2g.py
+++ b/testing/mozbase/mozdevice/mozdevice/adb_b2g.py
@@ -95,17 +95,17 @@ class ADBB2G(ADBDevice):
             set in the ADB constructor is used.
         :raises: * ADBTimeoutError
                  * ADBError
         """
         info = super(ADBB2G, self).get_info(directive=directive,
                                             timeout=timeout)
 
         directives = ['memtotal']
-        if (directive in directives):
+        if directive in directives:
             directives = [directive]
 
         if 'memtotal' in directives:
             info['memtotal'] = self.get_memory_total(timeout=timeout)
         return info
 
     def is_device_ready(self, timeout=None):
         """Returns True if the device is ready.