Correct to pep8 style with yapf linter.

Bug=28751508

Change-Id: Ic7435726030b6d9a40ba5e4dc37302f34d86e67d
diff --git a/utils/python/controllers/adb.py b/utils/python/controllers/adb.py
index c6a0e96..9e8859a 100644
--- a/utils/python/controllers/adb.py
+++ b/utils/python/controllers/adb.py
@@ -21,12 +21,16 @@
 import subprocess
 import time
 
+
 class AdbError(Exception):
     """Raised when there is an error in adb operations."""
 
-SL4A_LAUNCH_CMD=("am start -a com.googlecode.android_scripting.action.LAUNCH_SERVER "
+
+SL4A_LAUNCH_CMD = (
+    "am start -a com.googlecode.android_scripting.action.LAUNCH_SERVER "
     "--ei com.googlecode.android_scripting.extra.USE_SERVICE_PORT {} "
-    "com.googlecode.android_scripting/.activity.ScriptingLayerServiceLauncher" )
+    "com.googlecode.android_scripting/.activity.ScriptingLayerServiceLauncher")
+
 
 def get_available_host_port():
     """Gets a host port number available for adb forward.
@@ -40,6 +44,7 @@
         if is_port_available(port):
             return port
 
+
 def is_port_available(port):
     """Checks if a given port number is available on the system.
 
@@ -65,6 +70,7 @@
         if s:
             s.close()
 
+
 def list_occupied_adb_ports():
     """Lists all the host ports occupied by adb forward.
 
@@ -86,6 +92,7 @@
         used_ports.append(int(tokens[1]))
     return used_ports
 
+
 class AdbProxy():
     """Proxy class for ADB.
 
@@ -95,6 +102,7 @@
     >> adb.start_server()
     >> adb.devices() # will return the console output of "adb devices".
     """
+
     def __init__(self, serial="", log=None):
         self.serial = serial
         if serial:
@@ -156,7 +164,7 @@
             if self.is_sl4a_running():
                 return
         raise AdbError(
-                "com.googlecode.android_scripting process never started.")
+            "com.googlecode.android_scripting process never started.")
 
     def is_sl4a_running(self):
         """Checks if the sl4a app is running on an android device.
@@ -166,8 +174,8 @@
         """
         #Grep for process with a preceding S which means it is truly started.
         out = self.shell('ps | grep "S com.googlecode.android_scripting"')
-        if len(out)==0:
-          return False
+        if len(out) == 0:
+            return False
         return True
 
     def __getattr__(self, name):
@@ -175,4 +183,5 @@
             clean_name = name.replace('_', '-')
             arg_str = ' '.join(str(elem) for elem in args)
             return self._exec_adb_cmd(clean_name, arg_str)
+
         return adb_call
diff --git a/utils/python/controllers/android.py b/utils/python/controllers/android.py
index cdd1412..531ae06 100644
--- a/utils/python/controllers/android.py
+++ b/utils/python/controllers/android.py
@@ -13,7 +13,6 @@
 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 # License for the specific language governing permissions and limitations under
 # the License.
-
 """
 JSON RPC interface to android scripting engine.
 """
@@ -29,30 +28,40 @@
 HOST = os.environ.get('AP_HOST', None)
 PORT = os.environ.get('AP_PORT', 9999)
 
+
 class SL4AException(Exception):
     pass
 
+
 class SL4AAPIError(SL4AException):
     """Raised when remote API reports an error."""
 
+
 class SL4AProtocolError(SL4AException):
     """Raised when there is some error in exchanging data with server on device."""
     NO_RESPONSE_FROM_HANDSHAKE = "No response from handshake."
     NO_RESPONSE_FROM_SERVER = "No response from server."
     MISMATCHED_API_ID = "Mismatched API id."
 
+
 def IDCounter():
     i = 0
     while True:
         yield i
         i += 1
 
+
 class Android(object):
     COUNTER = IDCounter()
 
     _SOCKET_CONNECT_TIMEOUT = 60
 
-    def __init__(self, cmd='initiate', uid=-1, port=PORT, addr=HOST, timeout=None):
+    def __init__(self,
+                 cmd='initiate',
+                 uid=-1,
+                 port=PORT,
+                 addr=HOST,
+                 timeout=None):
         self.lock = threading.RLock()
         self.client = None  # prevent close errors on connect failure
         self.uid = None
@@ -60,7 +69,7 @@
         while True:
             try:
                 self.conn = socket.create_connection(
-                        (addr, port), max(1,timeout_time - time.time()))
+                    (addr, port), max(1, timeout_time - time.time()))
                 self.conn.settimeout(timeout)
                 break
             except (TimeoutError, socket.timeout):
@@ -79,7 +88,8 @@
 
         resp = self._cmd(cmd, uid)
         if not resp:
-            raise SL4AProtocolError(SL4AProtocolError.NO_RESPONSE_FROM_HANDSHAKE)
+            raise SL4AProtocolError(
+                SL4AProtocolError.NO_RESPONSE_FROM_HANDSHAKE)
         result = json.loads(str(resp, encoding="utf8"))
         if result['status']:
             self.uid = result['uid']
@@ -94,9 +104,8 @@
     def _cmd(self, command, uid=None):
         if not uid:
             uid = self.uid
-        self.client.write(
-            json.dumps({'cmd': command, 'uid': uid})
-                .encode("utf8")+b'\n')
+        self.client.write(json.dumps({'cmd': command,
+                                      'uid': uid}).encode("utf8") + b'\n')
         self.client.flush()
         return self.client.readline()
 
@@ -104,11 +113,9 @@
         self.lock.acquire()
         apiid = next(Android.COUNTER)
         self.lock.release()
-        data = {'id': apiid,
-                'method': method,
-                'params': args}
+        data = {'id': apiid, 'method': method, 'params': args}
         request = json.dumps(data)
-        self.client.write(request.encode("utf8")+b'\n')
+        self.client.write(request.encode("utf8") + b'\n')
         self.client.flush()
         response = self.client.readline()
         if not response:
@@ -123,4 +130,5 @@
     def __getattr__(self, name):
         def rpc_call(*args):
             return self._rpc(name, *args)
+
         return rpc_call
diff --git a/utils/python/controllers/android_device.py b/utils/python/controllers/android_device.py
index 17ff80b..01a2368 100644
--- a/utils/python/controllers/android_device.py
+++ b/utils/python/controllers/android_device.py
@@ -38,9 +38,11 @@
 ANDROID_DEVICE_EMPTY_CONFIG_MSG = "Configuration is empty, abort!"
 ANDROID_DEVICE_NOT_LIST_CONFIG_MSG = "Configuration should be a list, abort!"
 
+
 class AndroidDeviceError(signals.ControllerError):
     pass
 
+
 def create(configs, logger):
     if not configs:
         raise AndroidDeviceError(ANDROID_DEVICE_EMPTY_CONFIG_MSG)
@@ -57,8 +59,9 @@
     connected_ads = list_adb_devices()
     for ad in ads:
         if ad.serial not in connected_ads:
-            raise AndroidDeviceError(("Android device %s is specified in config"
-                                     " but is not attached.") % ad.serial)
+            raise AndroidDeviceError(
+                ("Android device %s is specified in config"
+                 " but is not attached.") % ad.serial)
         ad.startAdbLogcat()
         try:
             ad.getSl4aClient()
@@ -72,6 +75,7 @@
             raise AndroidDeviceError(msg)
     return ads
 
+
 def destroy(ads):
     for ad in ads:
         try:
@@ -81,6 +85,7 @@
         if ad.adb_logcat_process:
             ad.stopAdbLogcat()
 
+
 def _parse_device_list(device_list_str, key):
     """Parses a byte string representing a list of devices. The string is
     generated by calling either adb or fastboot.
@@ -100,6 +105,7 @@
             results.append(tokens[0])
     return results
 
+
 def list_adb_devices():
     """List all android devices connected to the computer that are detected by
     adb.
@@ -110,6 +116,7 @@
     out = adb.AdbProxy().devices()
     return _parse_device_list(out, "device")
 
+
 def list_fastboot_devices():
     """List all android devices connected to the computer that are in in
     fastboot mode. These are detected by fastboot.
@@ -120,6 +127,7 @@
     out = fastboot.FastbootProxy().devices()
     return _parse_device_list(out, "fastboot")
 
+
 def get_instances(serials, logger=None):
     """Create AndroidDevice instances from a list of serials.
 
@@ -135,6 +143,7 @@
         results.append(AndroidDevice(s, logger=logger))
     return results
 
+
 def get_instances_with_configs(configs, logger=None):
     """Create AndroidDevice instances from a list of json configs.
 
@@ -154,12 +163,13 @@
             serial = c.pop("serial")
         except KeyError:
             raise AndroidDeviceError(('Required value "serial" is missing in '
-                'AndroidDevice config %s.') % c)
+                                      'AndroidDevice config %s.') % c)
         ad = AndroidDevice(serial, logger=logger)
         ad.loadConfig(c)
         results.append(ad)
     return results
 
+
 def get_all_instances(include_fastboot=False, logger=None):
     """Create AndroidDevice instances for all attached android devices.
 
@@ -176,6 +186,7 @@
         return get_instances(serial_list, logger=logger)
     return get_instances(list_adb_devices(), logger=logger)
 
+
 def filter_devices(ads, func):
     """Finds the AndroidDevice instances from a list that match certain
     conditions.
@@ -194,6 +205,7 @@
             results.append(ad)
     return results
 
+
 def get_device(ads, **kwargs):
     """Finds a unique AndroidDevice instance from a list that has specific
     attributes of certain values.
@@ -213,6 +225,7 @@
         AndroidDeviceError is raised if none or more than one device is
         matched.
     """
+
     def _get_device_filter(ad):
         for k, v in kwargs.items():
             if not hasattr(ad, k):
@@ -220,6 +233,7 @@
             elif getattr(ad, k) != v:
                 return False
         return True
+
     filtered = filter_devices(ads, _get_device_filter)
     if not filtered:
         raise AndroidDeviceError(("Could not find a target device that matches"
@@ -230,6 +244,7 @@
         serials = [ad.serial for ad in filtered]
         raise AndroidDeviceError("More than one device matched: %s" % serials)
 
+
 def takeBugReports(ads, test_name, begin_time):
     """Takes bug reports on a list of android devices.
 
@@ -244,11 +259,14 @@
         begin_time: Logline format timestamp taken when the test started.
     """
     begin_time = vts_logger.normalizeLogLineTimestamp(begin_time)
+
     def take_br(test_name, begin_time, ad):
         ad.takeBugReport(test_name, begin_time)
+
     args = [(test_name, begin_time, ad) for ad in ads]
     utils.concurrent_exec(take_br, args)
 
+
 class AndroidDevice:
     """Class representing an android device.
 
@@ -274,7 +292,10 @@
                   via fastboot.
     """
 
-    def __init__(self, serial="", host_port=None, device_port=8080,
+    def __init__(self,
+                 serial="",
+                 host_port=None,
+                 device_port=8080,
                  logger=None):
         self.serial = serial
         self.h_port = host_port
@@ -401,7 +422,8 @@
         for k, v in config.items():
             if hasattr(self, k):
                 raise AndroidDeviceError(("Attempting to set existing "
-                    "attribute %s on %s") % (k, self.serial))
+                                          "attribute %s on %s") %
+                                         (k, self.serial))
             setattr(self, k, v)
 
     def rootAdb(self):
@@ -488,9 +510,9 @@
                 period.
         """
         if not self.adb_logcat_file_path:
-            raise AndroidDeviceError(("Attempting to cat adb log when none has"
-                                      " been collected on Android device %s."
-                                      ) % self.serial)
+            raise AndroidDeviceError(
+                ("Attempting to cat adb log when none has"
+                 " been collected on Android device %s.") % self.serial)
         end_time = vts_logger.getLogLineTimestamp()
         self.log.debug("Extracting adb log from logcat.")
         adb_excerpt_path = os.path.join(self.log_path, "AdbLogExcerpts")
@@ -518,7 +540,7 @@
                     if not vts_logger.isValidLogLineTimestamp(line_time):
                         continue
                     if self._is_timestamp_in_range(line_time, begin_time,
-                        end_time):
+                                                   end_time):
                         in_range = True
                         if not line.endswith('\n'):
                             line += '\n'
@@ -533,8 +555,8 @@
         """
         if self.isAdbLogcatOn:
             raise AndroidDeviceError(("Android device {} already has an adb "
-                                     "logcat thread going on. Cannot start "
-                                     "another one.").format(self.serial))
+                                      "logcat thread going on. Cannot start "
+                                      "another one.").format(self.serial))
         # Disable adb log spam filter.
         self.adb.shell("logpersist.start")
         f_name = "adblog,{},{}.txt".format(self.model, self.serial)
@@ -554,8 +576,8 @@
         """
         if not self.isAdbLogcatOn:
             raise AndroidDeviceError(("Android device {} does not have an "
-                                      "ongoing adb logcat collection."
-                                      ).format(self.serial))
+                                      "ongoing adb logcat collection.").format(
+                                          self.serial))
         utils.stop_standing_subprocess(self.adb_logcat_process)
         self.adb_logcat_process = None
 
@@ -592,7 +614,7 @@
         droid = android.Android(port=self.h_port)
         if droid.uid in self._droid_sessions:
             raise android.SL4AException(("SL4A returned an existing uid for a "
-                "new session. Abort."))
+                                         "new session. Abort."))
         self._droid_sessions[droid.uid] = [droid]
         return droid
 
@@ -612,8 +634,9 @@
         """
         if session_id not in self._droid_sessions:
             raise AndroidDeviceError("Session %d doesn't exist." % session_id)
-        droid = android.Android(cmd='continue', uid=session_id,
-            port=self.h_port)
+        droid = android.Android(cmd='continue',
+                                uid=session_id,
+                                port=self.h_port)
         return droid
 
     def closeOneSl4aSession(self, session_id):
@@ -669,7 +692,7 @@
             results: results have data flow information
         """
         out = self.adb.shell("iperf3 -c {} {}".format(server_host, extra_args))
-        clean_out = str(out,'utf-8').strip().split('\n')
+        clean_out = str(out, 'utf-8').strip().split('\n')
         if "error" in clean_out[0].lower():
             return False, clean_out
         return True, clean_out
diff --git a/utils/python/controllers/attenuator.py b/utils/python/controllers/attenuator.py
index 7dd14f2..98e42c1 100644
--- a/utils/python/controllers/attenuator.py
+++ b/utils/python/controllers/attenuator.py
@@ -21,6 +21,7 @@
 VTS_CONTROLLER_CONFIG_NAME = "Attenuator"
 VTS_CONTROLLER_REFERENCE_NAME = "attenuators"
 
+
 def create(configs, logger):
     objs = []
     for c in configs:
@@ -29,14 +30,14 @@
         protocol = "telnet"
         if "Protocol" in c:
             protocol = c["Protocol"]
-        module_name = "vts.utils.python.controllers.attenuator_lib.%s.%s" % (attn_model,
-            protocol)
+        module_name = "vts.utils.python.controllers.attenuator_lib.%s.%s" % (
+            attn_model, protocol)
         module = importlib.import_module(module_name)
         inst_cnt = c["InstrumentCount"]
         attn_inst = module.AttenuatorInstrument(inst_cnt)
         attn_inst.model = attn_model
         insts = attn_inst.open(c[Config.key_address.value],
-            c[Config.key_port.value])
+                               c[Config.key_port.value])
         for i in range(inst_cnt):
             attn = Attenuator(attn_inst, idx=i)
             if "Paths" in c:
@@ -48,9 +49,11 @@
             objs.append(attn)
     return objs
 
+
 def destroy(objs):
     return
 
+
 r"""
 Base classes which define how attenuators should be accessed, managed, and manipulated.
 
@@ -117,7 +120,8 @@
         """
 
         if type(self) is AttenuatorInstrument:
-            raise NotImplementedError("Base class should not be instantiated directly!")
+            raise NotImplementedError(
+                "Base class should not be instantiated directly!")
 
         self.num_atten = num_atten
         self.max_atten = AttenuatorInstrument.INVALID_MAX_ATTEN
@@ -198,8 +202,9 @@
         self.idx = idx
         self.offset = offset
 
-        if(self.idx >= instrument.num_atten):
-            raise IndexError("Attenuator index out of range for attenuator instrument")
+        if (self.idx >= instrument.num_atten):
+            raise IndexError(
+                "Attenuator index out of range for attenuator instrument")
 
     def set_atten(self, value):
         r"""This function sets the attenuation of Attenuator.
@@ -214,10 +219,11 @@
             The requested set value+offset must be less than the maximum value.
         """
 
-        if value+self.offset > self.instrument.max_atten:
-            raise ValueError("Attenuator Value+Offset greater than Max Attenuation!")
+        if value + self.offset > self.instrument.max_atten:
+            raise ValueError(
+                "Attenuator Value+Offset greater than Max Attenuation!")
 
-        self.instrument.set_atten(self.idx, value+self.offset)
+        self.instrument.set_atten(self.idx, value + self.offset)
 
     def get_atten(self):
         r"""This function returns the current attenuation setting of Attenuator, normalized by
@@ -240,7 +246,8 @@
         float
             Returns a the max attenuation value
         """
-        if (self.instrument.max_atten == AttenuatorInstrument.INVALID_MAX_ATTEN):
+        if (self.instrument.max_atten ==
+                AttenuatorInstrument.INVALID_MAX_ATTEN):
             raise ValueError("Invalid Max Attenuator Value")
 
         return self.instrument.max_atten - self.offset
diff --git a/utils/python/controllers/attenuator_lib/_tnhelper.py b/utils/python/controllers/attenuator_lib/_tnhelper.py
index f1a35c9..639d379 100644
--- a/utils/python/controllers/attenuator_lib/_tnhelper.py
+++ b/utils/python/controllers/attenuator_lib/_tnhelper.py
@@ -13,14 +13,12 @@
 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 #   See the License for the specific language governing permissions and
 #   limitations under the License.
-
 """
 Helper module for common telnet capability to communicate with AttenuatorInstrument(s).
 
 User code shouldn't need to directly access this class.
 """
 
-
 import telnetlib
 from vts.utils.python.controllers import attenuator
 
@@ -34,7 +32,10 @@
     #It should only be used by those implemention control libraries and not by any user code
     # directly
 
-    def __init__(self, tx_cmd_separator="\n", rx_cmd_separator="\n", prompt=""):
+    def __init__(self,
+                 tx_cmd_separator="\n",
+                 rx_cmd_separator="\n",
+                 prompt=""):
         self._tn = None
 
         self.tx_cmd_separator = tx_cmd_separator
@@ -61,11 +62,12 @@
             raise TypeError("Invalid command string", cmd_str)
 
         if not self.is_open():
-            raise attenuator.InvalidOperationError("Telnet connection not open for commands")
+            raise attenuator.InvalidOperationError(
+                "Telnet connection not open for commands")
 
         cmd_str.strip(self.tx_cmd_separator)
         self._tn.read_until(_ascii_string(self.prompt), 2)
-        self._tn.write(_ascii_string(cmd_str+self.tx_cmd_separator))
+        self._tn.write(_ascii_string(cmd_str + self.tx_cmd_separator))
 
         if wait_ret is False:
             return None
@@ -74,9 +76,11 @@
             self._tn.expect([_ascii_string("\S+"+self.rx_cmd_separator)], 1)
 
         if match_idx == -1:
-            raise attenuator.InvalidDataError("Telnet command failed to return valid data")
+            raise attenuator.InvalidDataError(
+                "Telnet command failed to return valid data")
 
         ret_text = ret_text.decode()
-        ret_text = ret_text.strip(self.tx_cmd_separator + self.rx_cmd_separator + self.prompt)
+        ret_text = ret_text.strip(self.tx_cmd_separator + self.rx_cmd_separator
+                                  + self.prompt)
 
         return ret_text
diff --git a/utils/python/controllers/attenuator_lib/aeroflex/telnet.py b/utils/python/controllers/attenuator_lib/aeroflex/telnet.py
index 4ce5612..9b8a0c1 100644
--- a/utils/python/controllers/attenuator_lib/aeroflex/telnet.py
+++ b/utils/python/controllers/attenuator_lib/aeroflex/telnet.py
@@ -13,7 +13,6 @@
 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 #   See the License for the specific language governing permissions and
 #   limitations under the License.
-
 """
 Class for Telnet control of Aeroflex 832X and 833X Series Attenuator Modules
 
@@ -25,13 +24,11 @@
 See http://www.aeroflex.com/ams/weinschel/PDFILES/IM-608-Models-8320-&-8321-preliminary.pdf
 """
 
-
 from vts.utils.python.controllers import attenuator
 from vts.utils.python.controllers.attenuator_lib import _tnhelper
 
 
 class AttenuatorInstrument(attenuator.AttenuatorInstrument):
-
     def __init__(self, num_atten=0):
         super().__init__(num_atten)
 
@@ -60,9 +57,9 @@
 
         configstr = self._tnhelper.cmd("RFCONFIG? ATTN 1")
 
-        self.properties = dict(zip(['model', 'max_atten', 'min_step',
-                                    'unknown', 'unknown2', 'cfg_str'],
-                                   configstr.split(", ", 5)))
+        self.properties = dict(zip(
+            ['model', 'max_atten', 'min_step', 'unknown', 'unknown2', 'cfg_str'
+             ], configstr.split(", ", 5)))
 
         self.max_atten = float(self.properties['max_atten'])
 
@@ -108,17 +105,18 @@
             will be thrown. Do not count on this check programmatically.
         """
 
-
         if not self.is_open():
             raise attenuator.InvalidOperationError("Connection not open!")
 
         if idx >= self.num_atten:
-            raise IndexError("Attenuator index out of range!", self.num_atten, idx)
+            raise IndexError("Attenuator index out of range!", self.num_atten,
+                             idx)
 
         if value > self.max_atten:
-            raise ValueError("Attenuator value out of range!", self.max_atten, value)
+            raise ValueError("Attenuator value out of range!", self.max_atten,
+                             value)
 
-        self._tnhelper.cmd("ATTN " + str(idx+1) + " " + str(value), False)
+        self._tnhelper.cmd("ATTN " + str(idx + 1) + " " + str(value), False)
 
     def get_atten(self, idx):
         r"""This function returns the current attenuation from an attenuator at a given index in
@@ -145,6 +143,6 @@
 #       if idx >= self.num_atten:
 #           raise IndexError("Attenuator index out of range!", self.num_atten, idx)
 
-        atten_val = self._tnhelper.cmd("ATTN? " + str(idx+1))
+        atten_val = self._tnhelper.cmd("ATTN? " + str(idx + 1))
 
         return float(atten_val)
diff --git a/utils/python/controllers/attenuator_lib/minicircuits/telnet.py b/utils/python/controllers/attenuator_lib/minicircuits/telnet.py
index 1bcb98b..f4f9a1d 100644
--- a/utils/python/controllers/attenuator_lib/minicircuits/telnet.py
+++ b/utils/python/controllers/attenuator_lib/minicircuits/telnet.py
@@ -13,7 +13,6 @@
 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 #   See the License for the specific language governing permissions and
 #   limitations under the License.
-
 """
 Class for Telnet control of Mini-Circuits RCDAT series attenuators
 
@@ -25,7 +24,6 @@
 See http://www.minicircuits.com/softwaredownload/Prog_Manual-6-Programmable_Attenuator.pdf
 """
 
-
 from vts.utils.python.controllers import attenuator
 from vts.utils.python.controllers.attenuator_lib import _tnhelper
 
@@ -70,7 +68,8 @@
         if config_str.startswith("MN="):
             config_str = config_str[len("MN="):]
 
-        self.properties = dict(zip(['model', 'max_freq', 'max_atten'], config_str.split("-", 2)))
+        self.properties = dict(zip(
+            ['model', 'max_freq', 'max_atten'], config_str.split("-", 2)))
         self.max_atten = float(self.properties['max_atten'])
 
     def is_open(self):
@@ -119,10 +118,12 @@
             raise attenuator.InvalidOperationError("Connection not open!")
 
         if idx >= self.num_atten:
-            raise IndexError("Attenuator index out of range!", self.num_atten, idx)
+            raise IndexError("Attenuator index out of range!", self.num_atten,
+                             idx)
 
         if value > self.max_atten:
-            raise ValueError("Attenuator value out of range!", self.max_atten, value)
+            raise ValueError("Attenuator value out of range!", self.max_atten,
+                             value)
 
         self._tnhelper.cmd("SETATT=" + str(value))
 
diff --git a/utils/python/controllers/event_dispatcher.py b/utils/python/controllers/event_dispatcher.py
index 92b9c65..8bfd56c 100644
--- a/utils/python/controllers/event_dispatcher.py
+++ b/utils/python/controllers/event_dispatcher.py
@@ -22,17 +22,21 @@
 import time
 import traceback
 
+
 class EventDispatcherError(Exception):
     pass
 
+
 class IllegalStateError(EventDispatcherError):
     """Raise when user tries to put event_dispatcher into an illegal state.
     """
 
+
 class DuplicateError(EventDispatcherError):
     """Raise when a duplicate is being created and it shouldn't.
     """
 
+
 class EventDispatcher:
     """Class managing events for an sl4a connection.
     """
@@ -107,12 +111,12 @@
         """
         if self.started:
             raise IllegalStateError(("Can't register service after polling is"
-                " started"))
+                                     " started"))
         self.lock.acquire()
         try:
             if event_name in self.handlers:
-                raise DuplicateError(
-                    'A handler for {} already exists'.format(event_name))
+                raise DuplicateError('A handler for {} already exists'.format(
+                    event_name))
             self.handlers[event_name] = (handler, args)
         finally:
             self.lock.release()
@@ -179,8 +183,8 @@
         e_queue = self.get_event_q(event_name)
 
         if not e_queue:
-            raise TypeError(
-                "Failed to get an event queue for {}".format(event_name))
+            raise TypeError("Failed to get an event queue for {}".format(
+                event_name))
 
         try:
             # Block for timeout
@@ -190,15 +194,18 @@
             elif timeout == 0:
                 return e_queue.get(False)
             else:
-            # Block forever on event wait
+                # Block forever on event wait
                 return e_queue.get(True)
         except queue.Empty:
-            raise queue.Empty(
-                'Timeout after {}s waiting for event: {}'.format(
-                    timeout, event_name))
+            raise queue.Empty('Timeout after {}s waiting for event: {}'.format(
+                timeout, event_name))
 
-    def wait_for_event(self, event_name, predicate,
-                       timeout=DEFAULT_TIMEOUT, *args, **kwargs):
+    def wait_for_event(self,
+                       event_name,
+                       predicate,
+                       timeout=DEFAULT_TIMEOUT,
+                       *args,
+                       **kwargs):
         """Wait for an event that satisfies a predicate to appear.
 
         Continuously pop events of a particular name and check against the
@@ -273,11 +280,10 @@
                 break
             time.sleep(1)
         if len(results) == 0:
-            raise queue.Empty(
-                'Timeout after {}s waiting for event: {}'.format(
-                    timeout, regex_pattern))
+            raise queue.Empty('Timeout after {}s waiting for event: {}'.format(
+                timeout, regex_pattern))
 
-        return sorted(results, key=lambda event : event['time'])
+        return sorted(results, key=lambda event: event['time'])
 
     def _match_and_pop(self, regex_pattern):
         """Pop one event from each of the event queues whose names
@@ -311,7 +317,8 @@
                 passed.
         """
         self.lock.acquire()
-        if not event_name in self.event_dict or self.event_dict[event_name] is None:
+        if not event_name in self.event_dict or self.event_dict[
+                event_name] is None:
             self.event_dict[event_name] = queue.Queue()
         self.lock.release()
 
@@ -331,9 +338,8 @@
         handler, args = self.handlers[event_name]
         self.executor.submit(handler, event_obj, *args)
 
-
     def _handle(self, event_handler, event_name, user_args, event_timeout,
-        cond, cond_timeout):
+                cond, cond_timeout):
         """Pop an event of specified type and calls its handler on it. If
         condition is not None, block until condition is met or timeout.
         """
@@ -342,8 +348,13 @@
         event = self.pop_event(event_name, event_timeout)
         return event_handler(event, *user_args)
 
-    def handle_event(self, event_handler, event_name, user_args,
-        event_timeout=None, cond=None, cond_timeout=None):
+    def handle_event(self,
+                     event_handler,
+                     event_name,
+                     user_args,
+                     event_timeout=None,
+                     cond=None,
+                     cond_timeout=None):
         """Handle events that don't have registered handlers
 
         In a new thread, poll one event of specified type from its queue and
@@ -368,7 +379,8 @@
                 needs to return something to unblock.
         """
         worker = self.executor.submit(self._handle, event_handler, event_name,
-            user_args, event_timeout, cond, cond_timeout)
+                                      user_args, event_timeout, cond,
+                                      cond_timeout)
         return worker
 
     def pop_all(self, event_name):
@@ -389,7 +401,7 @@
         """
         if not self.started:
             raise IllegalStateError(("Dispatcher needs to be started before "
-                "popping."))
+                                     "popping."))
         results = []
         try:
             self.lock.acquire()
diff --git a/utils/python/controllers/fastboot.py b/utils/python/controllers/fastboot.py
index 096dfae..b06e3f3 100644
--- a/utils/python/controllers/fastboot.py
+++ b/utils/python/controllers/fastboot.py
@@ -16,6 +16,7 @@
 
 from subprocess import Popen, PIPE
 
+
 def exe_cmd(*cmds):
     """Executes commands in a new shell. Directing stderr to PIPE.
 
@@ -38,9 +39,11 @@
         return out
     return err
 
+
 class FastbootError(Exception):
     """Raised when there is an error in fastboot operations."""
 
+
 class FastbootProxy():
     """Proxy class for fastboot.
 
@@ -49,6 +52,7 @@
     >> fb = FastbootProxy(<serial>)
     >> fb.devices() # will return the console output of "fastboot devices".
     """
+
     def __init__(self, serial=""):
         self.serial = serial
         if serial:
@@ -60,11 +64,12 @@
         return exe_cmd(' '.join((self.fastboot_str, name, arg_str)))
 
     def args(self, *args):
-        return exe_cmd(' '.join((self.fastboot_str,) + args))
+        return exe_cmd(' '.join((self.fastboot_str, ) + args))
 
     def __getattr__(self, name):
         def fastboot_call(*args):
             clean_name = name.replace('_', '-')
             arg_str = ' '.join(str(elem) for elem in args)
             return self._exec_fastboot_cmd(clean_name, arg_str)
+
         return fastboot_call