[ONOS-7104]: Style fixes to the drivers directory in TestON

Change-Id: Ie151a956c15f1b1cc6ebc09a2e7474f8e4066459
diff --git a/TestON/drivers/common/cli/emulator/mininetclidriver.py b/TestON/drivers/common/cli/emulator/mininetclidriver.py
index d69fbeb..25cafe0 100644
--- a/TestON/drivers/common/cli/emulator/mininetclidriver.py
+++ b/TestON/drivers/common/cli/emulator/mininetclidriver.py
@@ -45,6 +45,7 @@
 
 
 class MininetCliDriver( Emulator ):
+
     """
        MininetCliDriver is the basic driver which will handle
        the Mininet functions"""
@@ -184,7 +185,7 @@
                         main.log.info(
                             "Starting Mininet from topo file " +
                             topoFile )
-                        cmdString +=  "-E python " + topoFile + " "
+                        cmdString += "-E python " + topoFile + " "
                         if args is None:
                             args = ''
                             # TODO: allow use of args from .topo file?
@@ -434,7 +435,6 @@
             main.log.exception( self.name + ": Uncaught exception!" )
             main.cleanAndExit()
 
-
     def pingallHosts( self, hostList, wait=1 ):
         """
             Ping all specified IPv4 hosts
@@ -462,7 +462,7 @@
                 pingList = hostList[ :listIndex ] + \
                     hostList[ ( listIndex + 1 ): ]
 
-                pingResponse += str(str(host) + " -> ")
+                pingResponse += str( str( host ) + " -> " )
 
                 for temp in pingList:
                     # Current host pings all other hosts specified
@@ -471,14 +471,14 @@
                     self.handle.expect( "mininet>", timeout=wait + 1 )
                     response = self.handle.before
                     if re.search( ',\s0\%\spacket\sloss', response ):
-                        pingResponse += str(" h" + str( temp[1:] ))
+                        pingResponse += str( " h" + str( temp[ 1: ] ) )
                     else:
                         pingResponse += " X"
                         # One of the host to host pair is unreachable
                         isReachable = main.FALSE
                         failedPings += 1
                 pingResponse += "\n"
-            main.log.info( pingResponse + "Failed pings: " + str(failedPings) )
+            main.log.info( pingResponse + "Failed pings: " + str( failedPings ) )
             return isReachable
         except pexpect.TIMEOUT:
             main.log.exception( self.name + ": TIMEOUT exception" )
@@ -513,23 +513,23 @@
                 pingList = hostList[ :listIndex ] + \
                     hostList[ ( listIndex + 1 ): ]
 
-                pingResponse += str(str(host) + " -> ")
+                pingResponse += str( str( host ) + " -> " )
 
                 for temp in pingList:
                     # Current host pings all other hosts specified
-                    pingCmd = str( host ) + cmd + str( self.getIPAddress(temp,proto='IPv6') )
+                    pingCmd = str( host ) + cmd + str( self.getIPAddress( temp, proto='IPv6' ) )
                     self.handle.sendline( pingCmd )
                     self.handle.expect( "mininet>", timeout=wait + 1 )
                     response = self.handle.before
                     if re.search( ',\s0\%\spacket\sloss', response ):
-                        pingResponse += str(" h" + str( temp[1:] ))
+                        pingResponse += str( " h" + str( temp[ 1: ] ) )
                     else:
                         pingResponse += " X"
                         # One of the host to host pair is unreachable
                         isReachable = main.FALSE
                         failedPings += 1
                 pingResponse += "\n"
-            main.log.info( pingResponse + "Failed pings: " + str(failedPings) )
+            main.log.info( pingResponse + "Failed pings: " + str( failedPings ) )
             return isReachable
 
         except pexpect.TIMEOUT:
@@ -549,7 +549,7 @@
         Currently the only supported Params: SRC, TARGET, and WAIT
         """
         args = utilities.parse_args( [ "SRC", "TARGET", 'WAIT' ], **pingParams )
-        wait = args['WAIT']
+        wait = args[ 'WAIT' ]
         wait = int( wait if wait else 1 )
         command = args[ "SRC" ] + " ping " + \
             args[ "TARGET" ] + " -c 1 -i 1 -W " + str( wait ) + " "
@@ -594,7 +594,7 @@
            Example: main.Mininet1.ping6pair( src="h1", target="1000::2" )
         """
         args = utilities.parse_args( [ "SRC", "TARGET", 'WAIT' ], **pingParams )
-        wait = args['WAIT']
+        wait = args[ 'WAIT' ]
         wait = int( wait if wait else 1 )
         command = args[ "SRC" ] + " ping6 " + \
             args[ "TARGET" ] + " -c 1 -i 1 -W " + str( wait ) + " "
@@ -838,8 +838,8 @@
                 return main.TRUE
 
             except pexpect.TIMEOUT:
-                main.log.error(self.name + ": TIMEOUT exception found")
-                main.log.error(self.name + ":     " + self.handle.before)
+                main.log.error( self.name + ": TIMEOUT exception found" )
+                main.log.error( self.name + ":     " + self.handle.before )
                 main.cleanAndExit()
             except pexpect.EOF:
                 main.log.error( self.name + ": EOF exception found" )
@@ -877,7 +877,7 @@
                 self.handle.expect( "mininet>" )
 
                 # Determine ip and mac address of the host-oldSw interface
-                cmd = "px ipaddr = " + str(IP)
+                cmd = "px ipaddr = " + str( IP )
                 print "cmd3= ", cmd
                 self.handle.sendline( cmd )
                 self.handle.expect( "mininet>" )
@@ -888,7 +888,7 @@
                 self.handle.expect( "mininet>" )
 
                 # Detach interface between oldSw-host
-                cmd = "px " + oldSw + ".detach( sintf )"
+                cmd = "px " + oldSw + ".detach(sintf)"
                 print "cmd4= ", cmd
                 self.handle.sendline( cmd )
                 self.handle.expect( "mininet>" )
@@ -907,31 +907,31 @@
                 self.handle.expect( "mininet>" )
 
                 # Attach interface between newSw-host
-                cmd = "px " + newSw + ".attach( sintf )"
+                cmd = "px " + newSw + ".attach(sintf)"
                 print "cmd6= ", cmd
                 self.handle.sendline( cmd )
                 self.handle.expect( "mininet>" )
 
                 # Set macaddress of the host-newSw interface
-                cmd = "px " + host + ".setMAC( mac = macaddr, intf = hintf)"
+                cmd = "px " + host + ".setMAC(mac = macaddr, intf = hintf)"
                 print "cmd7 = ", cmd
                 self.handle.sendline( cmd )
                 self.handle.expect( "mininet>" )
 
                 # Set ipaddress of the host-newSw interface
-                cmd = "px " + host + ".setIP( ip = ipaddr, intf = hintf)"
+                cmd = "px " + host + ".setIP(ip = ipaddr, intf = hintf)"
                 print "cmd8 = ", cmd
                 self.handle.sendline( cmd )
                 self.handle.expect( "mininet>" )
 
                 cmd = host + " ifconfig"
-                print "cmd9 =",cmd
-                response = self.execute( cmd = cmd, prompt="mininet>" ,timeout=10 )
+                print "cmd9 =", cmd
+                response = self.execute( cmd = cmd, prompt="mininet>", timeout=10 )
                 print response
                 pattern = "h\d-eth([\w])"
                 ipAddressSearch = re.search( pattern, response )
-                print ipAddressSearch.group(1)
-                intf= host + "-eth" + str(ipAddressSearch.group(1))
+                print ipAddressSearch.group( 1 )
+                intf = host + "-eth" + str( ipAddressSearch.group( 1 ) )
                 cmd = host + " ip -6 addr add %s dev %s" % ( IP, intf )
                 print "cmd10 = ", cmd
                 self.handle.sendline( cmd )
@@ -952,8 +952,8 @@
 
                 return main.TRUE
             except pexpect.TIMEOUT:
-                main.log.error(self.name + ": TIMEOUT exception found")
-                main.log.error(self.name + ":     " + self.handle.before)
+                main.log.error( self.name + ": TIMEOUT exception found" )
+                main.log.error( self.name + ":     " + self.handle.before )
                 main.cleanAndExit()
             except pexpect.EOF:
                 main.log.error( self.name + ": EOF exception found" )
@@ -982,8 +982,8 @@
                     newIP )
                 return main.TRUE
             except pexpect.TIMEOUT:
-                main.log.error(self.name + ": TIMEOUT exception found")
-                main.log.error(self.name + ":     " + self.handle.before)
+                main.log.error( self.name + ": TIMEOUT exception found" )
+                main.log.error( self.name + ":     " + self.handle.before )
                 main.cleanAndExit()
             except pexpect.EOF:
                 main.log.error( self.name + ": EOF exception found" )
@@ -1011,8 +1011,8 @@
                     newGW )
                 return main.TRUE
             except pexpect.TIMEOUT:
-                main.log.error(self.name + ": TIMEOUT exception found")
-                main.log.error(self.name + ":     " + self.handle.before)
+                main.log.error( self.name + ": TIMEOUT exception found" )
+                main.log.error( self.name + ":     " + self.handle.before )
                 main.cleanAndExit()
             except pexpect.EOF:
                 main.log.error( self.name + ": EOF exception found" )
@@ -1040,8 +1040,8 @@
                     macaddr )
                 return main.TRUE
             except pexpect.TIMEOUT:
-                main.log.error(self.name + ": TIMEOUT exception found")
-                main.log.error(self.name + ":     " + self.handle.before)
+                main.log.error( self.name + ": TIMEOUT exception found" )
+                main.log.error( self.name + ":     " + self.handle.before )
                 main.cleanAndExit()
             except pexpect.EOF:
                 main.log.error( self.name + ": EOF exception found" )
@@ -1064,8 +1064,8 @@
                 main.log.info( host + " arp -an = " + response )
                 return main.TRUE
             except pexpect.TIMEOUT:
-                main.log.error(self.name + ": TIMEOUT exception found")
-                main.log.error(self.name + ":     " + self.handle.before)
+                main.log.error( self.name + ": TIMEOUT exception found" )
+                main.log.error( self.name + ":     " + self.handle.before )
                 main.cleanAndExit()
             except pexpect.EOF:
                 main.log.error( self.name + ": EOF exception found" )
@@ -1138,7 +1138,7 @@
         else:
             main.log.error( "Connection failed to the host" )
 
-    def getIPAddress( self, host , proto='IPV4'):
+    def getIPAddress( self, host , proto='IPV4' ):
         """
            Verifies the host's ip configured or not."""
         if self.handle:
@@ -1214,8 +1214,8 @@
                 response = self.handle.before
                 return response
             except pexpect.TIMEOUT:
-                main.log.error(self.name + ": TIMEOUT exception found")
-                main.log.error(self.name + ":     " + self.handle.before)
+                main.log.error( self.name + ": TIMEOUT exception found" )
+                main.log.error( self.name + ":     " + self.handle.before )
                 main.cleanAndExit()
             except pexpect.EOF:
                 main.log.error( self.name + ": EOF exception found" )
@@ -1307,7 +1307,7 @@
             main.cleanAndExit()
         return response
 
-    def iperftcpAll(self, hosts, timeout=6):
+    def iperftcpAll( self, hosts, timeout=6 ):
         '''
         Runs the iperftcp function with a given set of hosts and specified timeout.
 
@@ -1319,13 +1319,13 @@
             for host1 in hosts:
                 for host2 in hosts:
                     if host1 != host2:
-                        if self.iperftcp(host1, host2, timeout) == main.FALSE:
-                            main.log.error(self.name + ": iperftcp test failed for " + host1 + " and " + host2)
+                        if self.iperftcp( host1, host2, timeout ) == main.FALSE:
+                            main.log.error( self.name + ": iperftcp test failed for " + host1 + " and " + host2 )
         except Exception:
             main.log.exception( self.name + ": Uncaught exception!" )
             main.cleanAndExit()
 
-    def iperftcp(self, host1="h1", host2="h2", timeout=6):
+    def iperftcp( self, host1="h1", host2="h2", timeout=6 ):
         '''
         Creates an iperf TCP test between two hosts. Returns main.TRUE if test results
         are valid.
@@ -1344,26 +1344,26 @@
 
             # checks if there are results in the mininet response
             if "Results:" in response:
-                main.log.report(self.name + ": iperf test completed")
+                main.log.report( self.name + ": iperf test completed" )
                 # parse the mn results
-                response = response.split("\r\n")
-                response = response[len(response)-2]
-                response = response.split(": ")
-                response = response[len(response)-1]
-                response = response.replace("[", "")
-                response = response.replace("]", "")
-                response = response.replace("\'", "")
+                response = response.split( "\r\n" )
+                response = response[ len( response )-2 ]
+                response = response.split( ": " )
+                response = response[ len( response )-1 ]
+                response = response.replace( "[", "" )
+                response = response.replace( "]", "" )
+                response = response.replace( "\'", "" )
 
                 # this is the bandwith two and from the two hosts
-                bandwidth = response.split(", ")
+                bandwidth = response.split( ", " )
 
                 # there should be two elements in the bandwidth list
                 # ['host1 to host2', 'host2 to host1"]
-                if len(bandwidth) == 2:
-                    main.log.report(self.name + ": iperf test successful")
+                if len( bandwidth ) == 2:
+                    main.log.report( self.name + ": iperf test successful" )
                     return main.TRUE
                 else:
-                    main.log.error(self.name + ": invalid iperf results")
+                    main.log.error( self.name + ": invalid iperf results" )
                     return main.FALSE
             else:
                 main.log.error( self.name + ": iperf test failed" )
@@ -1385,22 +1385,22 @@
             main.log.exception( self.name + ": Uncaught exception!" )
             main.cleanAndExit()
 
-    def iperftcpipv6(self, host1="h1", host2="h2", timeout=50):
+    def iperftcpipv6( self, host1="h1", host2="h2", timeout=50 ):
         main.log.info( self.name + ": Simple iperf TCP test between two hosts" )
         try:
             IP1 = self.getIPAddress( host1, proto='IPV6' )
-            cmd1 = host1 +' iperf -V -sD -B '+ str(IP1)
+            cmd1 = host1 + ' iperf -V -sD -B ' + str( IP1 )
             self.handle.sendline( cmd1 )
-            outcome1 = self.handle.expect( "mininet>")
-            cmd2 = host2 +' iperf -V -c '+ str(IP1) +' -t 5'
+            outcome1 = self.handle.expect( "mininet>" )
+            cmd2 = host2 + ' iperf -V -c ' + str( IP1 ) + ' -t 5'
             self.handle.sendline( cmd2 )
-            outcome2 = self.handle.expect( "mininet>")
+            outcome2 = self.handle.expect( "mininet>" )
             response1 = self.handle.before
             response2 = self.handle.after
-            print response1,response2
-            pattern = "connected with "+ str(IP1)
+            print response1, response2
+            pattern = "connected with " + str( IP1 )
             if pattern in response1:
-                main.log.report(self.name + ": iperf test completed")
+                main.log.report( self.name + ": iperf test completed" )
                 return main.TRUE
             else:
                 main.log.error( self.name + ": iperf test failed" )
@@ -1420,7 +1420,7 @@
             main.log.exception( self.name + ": Uncaught exception!" )
             main.cleanAndExit()
 
-    def iperfudpAll(self, hosts, bandwidth="10M"):
+    def iperfudpAll( self, hosts, bandwidth="10M" ):
         '''
         Runs the iperfudp function with a given set of hosts and specified
         bandwidth
@@ -1432,17 +1432,16 @@
             for host1 in hosts:
                 for host2 in hosts:
                     if host1 != host2:
-                        if self.iperfudp(host1, host2, bandwidth) == main.FALSE:
-                            main.log.error(self.name + ": iperfudp test failed for " + host1 + " and " + host2)
+                        if self.iperfudp( host1, host2, bandwidth ) == main.FALSE:
+                            main.log.error( self.name + ": iperfudp test failed for " + host1 + " and " + host2 )
         except TypeError:
-            main.log.exception(self.name + ": Object not as expected")
+            main.log.exception( self.name + ": Object not as expected" )
             return main.FALSE
         except Exception:
             main.log.exception( self.name + ": Uncaught exception!" )
             main.cleanAndExit()
 
-    def iperfudp( self, bandwidth="10M", host1="h1", host2="h2"):
-
+    def iperfudp( self, bandwidth="10M", host1="h1", host2="h2" ):
         '''
         Creates an iperf UDP test with a specific bandwidth.
         Returns true if results are valid.
@@ -1450,47 +1449,47 @@
         @param:
             bandwidth: the targeted bandwidth, in megabits ('M'), to run the test
         '''
-        main.log.info(self.name + ": Simple iperf UDP test between two hosts")
+        main.log.info( self.name + ": Simple iperf UDP test between two hosts" )
         try:
             # setup the mininet command
             cmd = 'iperfudp ' + bandwidth + " " + host1 + " " + host2
-            self.handle.sendline(cmd)
-            self.handle.expect("mininet>")
+            self.handle.sendline( cmd )
+            self.handle.expect( "mininet>" )
             response = self.handle.before
 
             # check if there are in results in the mininet response
             if "Results:" in response:
-                main.log.report(self.name + ": iperfudp test completed")
+                main.log.report( self.name + ": iperfudp test completed" )
                 # parse the results
-                response = response.split("\r\n")
-                response = response[len(response)-2]
-                response = response.split(": ")
-                response = response[len(response)-1]
-                response = response.replace("[", "")
-                response = response.replace("]", "")
-                response = response.replace("\'", "")
+                response = response.split( "\r\n" )
+                response = response[ len( response )-2 ]
+                response = response.split( ": " )
+                response = response[ len( response )-1 ]
+                response = response.replace( "[", "" )
+                response = response.replace( "]", "" )
+                response = response.replace( "\'", "" )
 
-                mnBandwidth = response.split(", ")
+                mnBandwidth = response.split( ", " )
 
                 # check to see if there are at least three entries
                 # ['bandwidth', 'host1 to host2', 'host2 to host1']
-                if len(mnBandwidth) == 3:
+                if len( mnBandwidth ) == 3:
                     # if one entry is blank then something is wrong
                     for item in mnBandwidth:
                         if item == "":
-                            main.log.error(self.name + ": Could not parse iperf output")
-                            main.log.error(self.name + ": invalid iperfudp results")
+                            main.log.error( self.name + ": Could not parse iperf output" )
+                            main.log.error( self.name + ": invalid iperfudp results" )
                             return main.FALSE
                     # otherwise results are vaild
-                    main.log.report(self.name + ": iperfudp test successful")
+                    main.log.report( self.name + ": iperfudp test successful" )
                     return main.TRUE
                 else:
-                    main.log.error(self.name + ": invalid iperfudp results")
+                    main.log.error( self.name + ": invalid iperfudp results" )
                     return main.FALSE
 
         except pexpect.TIMEOUT:
-            main.log.error(self.name + ": TIMEOUT exception found")
-            main.log.error(self.name + ":     " + self.handle.before)
+            main.log.error( self.name + ": TIMEOUT exception found" )
+            main.log.error( self.name + ":     " + self.handle.before )
             main.cleanAndExit()
         except pexpect.EOF:
             main.log.error( self.name + ": EOF exception found" )
@@ -1579,8 +1578,8 @@
             self.handle.sendline( command )
             self.handle.expect( "mininet>" )
         except pexpect.TIMEOUT:
-            main.log.error(self.name + ": TIMEOUT exception found")
-            main.log.error(self.name + ":     " + self.handle.before)
+            main.log.error( self.name + ": TIMEOUT exception found" )
+            main.log.error( self.name + ":     " + self.handle.before )
             main.cleanAndExit()
         except pexpect.EOF:
             main.log.error( self.name + ": EOF exception found" )
@@ -1622,7 +1621,7 @@
         args = utilities.parse_args( [ "SW", "INTF" ], **yankargs )
         sw = args[ "SW" ] if args[ "SW" ] is not None else ""
         intf = args[ "INTF" ] if args[ "INTF" ] is not None else ""
-        command = "py " + str( sw ) + '.detach("' + str(intf) + '")'
+        command = "py " + str( sw ) + '.detach("' + str( intf ) + '")'
         try:
             response = self.execute(
                 cmd=command,
@@ -1644,7 +1643,7 @@
         args = utilities.parse_args( [ "SW", "INTF" ], **plugargs )
         sw = args[ "SW" ] if args[ "SW" ] is not None else ""
         intf = args[ "INTF" ] if args[ "INTF" ] is not None else ""
-        command = "py " + str( sw ) + '.attach("' + str(intf) + '")'
+        command = "py " + str( sw ) + '.attach("' + str( intf ) + '")'
         try:
             response = self.execute(
                 cmd=command,
@@ -1966,11 +1965,11 @@
                     candidateSwitches.append( switchName )
             else:
                 graphDict = self.getGraphDict( timeout=timeout, useId=False )
-                if graphDict == None:
+                if graphDict is None:
                     return None
                 self.graph.update( graphDict )
                 candidateSwitches = self.graph.getNonCutVertices()
-            if candidateSwitches == None:
+            if candidateSwitches is None:
                 return None
             elif len( candidateSwitches ) == 0:
                 main.log.info( self.name + ": No candidate switch for deletion" )
@@ -2000,7 +1999,7 @@
         """
         try:
             switch = self.getSwitchRandom( timeout, nonCut )
-            if switch == None:
+            if switch is None:
                 return None
             else:
                 deletionResult = self.delSwitch( switch )
@@ -2105,11 +2104,11 @@
                     candidateLinks.append( [ link[ 'node1' ], link[ 'node2' ] ] )
             else:
                 graphDict = self.getGraphDict( timeout=timeout, useId=False )
-                if graphDict == None:
+                if graphDict is None:
                     return None
                 self.graph.update( graphDict )
                 candidateLinks = self.graph.getNonCutEdges()
-            if candidateLinks == None:
+            if candidateLinks is None:
                 return None
             elif len( candidateLinks ) == 0:
                 main.log.info( self.name + ": No candidate link for deletion" )
@@ -2139,7 +2138,7 @@
         """
         try:
             link = self.getLinkRandom( timeout, nonCut )
-            if link == None:
+            if link is None:
                 return None
             else:
                 deletionResult = self.delLink( link[ 0 ], link[ 1 ] )
@@ -2302,8 +2301,8 @@
                         fileName +
                         "\" | grep -v grep | awk '{print $2}'\`" )
             except pexpect.TIMEOUT:
-                main.log.error(self.name + ": TIMEOUT exception found")
-                main.log.error(self.name + ":     " + self.handle.before)
+                main.log.error( self.name + ": TIMEOUT exception found" )
+                main.log.error( self.name + ":     " + self.handle.before )
                 main.cleanAndExit()
             except pexpect.EOF:
                 main.log.error( self.name + ": EOF exception found" )
@@ -2331,7 +2330,7 @@
             ethDevice = '-I ' + ethDevice + ' '
         cmd = srcHost + " arping -c1 "
         if noResult:
-            cmd += "-w10 " # If we don't want the actural arping result, set -w10, arping will exit after 10 ms.
+            cmd += "-w10 "  # If we don't want the actural arping result, set -w10, arping will exit after 10 ms.
         cmd += ethDevice + dstHost
         try:
             if output:
@@ -2416,11 +2415,11 @@
             assert flowTable1, "flowTable1 is empty or None"
             assert flowTable2, "flowTable2 is empty or None"
             returnValue = main.TRUE
-            if len(flowTable1) != len(flowTable2):
+            if len( flowTable1 ) != len( flowTable2 ):
                 main.log.warn( "Flow table lengths do not match" )
                 returnValue = main.FALSE
-            dFields = ["n_bytes", "cookie", "n_packets", "duration"]
-            for flow1, flow2 in zip(flowTable1, flowTable2):
+            dFields = [ "n_bytes", "cookie", "n_packets", "duration" ]
+            for flow1, flow2 in zip( flowTable1, flowTable2 ):
                 for field in dFields:
                     try:
                         flow1.pop( field )
@@ -2430,10 +2429,10 @@
                         flow2.pop( field )
                     except KeyError:
                         pass
-            for i in range( len(flowTable1) ):
-                if flowTable1[i] not in flowTable2:
+            for i in range( len( flowTable1 ) ):
+                if flowTable1[ i ] not in flowTable2:
                     main.log.warn( "Flow tables do not match:" )
-                    main.log.warn( "Old flow:\n{}\n not in new flow table".format( flowTable1[i] ) )
+                    main.log.warn( "Old flow:\n{}\n not in new flow table".format( flowTable1[ i ] ) )
                     returnValue = main.FALSE
                     break
             return returnValue
@@ -2461,63 +2460,64 @@
             for flow in flowTable:
                 jsonFlow = {}
                 # split up the fields of the flow
-                parsedFlow = flow.split(", ")
+                parsedFlow = flow.split( ", " )
                 # get rid of any spaces in front of the field
-                for i in range( len(parsedFlow) ):
-                    item = parsedFlow[i]
-                    if item[0] == " ":
-                        parsedFlow[i] = item[1:]
+                for i in range( len( parsedFlow ) ):
+                    item = parsedFlow[ i ]
+                    if item[ 0 ] == " ":
+                        parsedFlow[ i ] = item[ 1: ]
                 # grab the selector and treatment from the parsed flow
                 # the last element is the selector and the treatment
-                temp = parsedFlow.pop(-1)
+                temp = parsedFlow.pop( -1 )
                 # split up the selector and the treatment
-                temp = temp.split(" ")
+                temp = temp.split( " " )
                 index = 0
                 # parse the flags
                 # NOTE: This only parses one flag
                 flag = {}
                 if version == "1.3":
-                    flag = {"flag":[temp[index]]}
+                    flag = { "flag": [ temp[ index ] ] }
                     index += 1
                 # the first element is the selector and split it up
-                sel = temp[index]
+                sel = temp[ index ]
                 index += 1
-                sel = sel.split(",")
+                sel = sel.split( "," )
                 # the priority is stuck in the selecter so put it back
                 # in the flow
-                parsedFlow.append(sel.pop(0))
+                parsedFlow.append( sel.pop( 0 ) )
                 # parse selector
                 criteria = []
                 for item in sel:
                     # this is the type of the packet e.g. "arp"
                     if "=" not in item:
-                        criteria.append( {"type":item} )
+                        criteria.append( { "type": item } )
                     else:
-                        field = item.split("=")
-                        criteria.append( {field[0]:field[1]} )
-                selector = {"selector": {"criteria":sorted(criteria)} }
-                treat = temp[index]
+                        field = item.split( "=" )
+                        criteria.append( { field[ 0 ]: field[ 1 ] } )
+                selector = { "selector": { "criteria": sorted( criteria ) } }
+                treat = temp[ index ]
                 # get rid of the action part e.g. "action=output:2"
                 # we will add it back later
-                treat = treat.split("=")
-                treat.pop(0)
+                treat = treat.split( "=" )
+                treat.pop( 0 )
                 # parse treatment
                 action = []
                 for item in treat:
-                    field = item.split(":")
-                    action.append( {field[0]:field[1]} )
+                    field = item.split( ":" )
+                    action.append( { field[ 0 ]: field[ 1 ] } )
                 # create the treatment field and add the actions
-                treatment = {"treatment": {"action":sorted(action)} }
+                treatment = { "treatment": { "action": sorted( action ) } }
                 # parse the rest of the flow
                 for item in parsedFlow:
-                    field = item.split("=")
-                    jsonFlow.update( {field[0]:field[1]} )
+                    field = item.split( "=" )
+                    jsonFlow.update( { field[ 0 ]: field[ 1 ] } )
                 # add the treatment and the selector to the json flow
                 jsonFlow.update( selector )
                 jsonFlow.update( treatment )
                 jsonFlow.update( flag )
 
-                if debug: main.log.debug( "\033[94mJson flow:\033[0m\n{}\n".format(jsonFlow) )
+                if debug:
+                    main.log.debug( "\033[94mJson flow:\033[0m\n{}\n".format( jsonFlow ) )
 
                 # add the json flow to the json flow table
                 jsonFlowTable.append( jsonFlow )
@@ -2535,7 +2535,7 @@
             main.log.exception( self.name + ": Uncaught exception!" )
             main.cleanAndExit()
 
-    def getFlowTable( self, sw, version="", debug=False):
+    def getFlowTable( self, sw, version="", debug=False ):
         '''
         Discription: Returns the flow table(s) on a switch or switches in a list.
             Each element is a flow.
@@ -2549,9 +2549,10 @@
         '''
         try:
             switches = []
-            if type(sw) is list:
-                switches.extend(sw)
-            else: switches.append(sw)
+            if isinstance( sw, list ):
+                switches.extend( sw )
+            else:
+                switches.append( sw )
 
             flows = []
             for s in switches:
@@ -2571,10 +2572,11 @@
                 # the first element is the command that was sent
                 # the second is the table header
                 # the last element is empty
-                response = response[2:-1]
+                response = response[ 2:-1 ]
                 flows.extend( response )
 
-            if debug: print "Flows:\n{}\n\n".format(flows)
+            if debug:
+                print "Flows:\n{}\n\n".format( flows )
 
             return self.parseFlowTable( flows, version, debug )
 
@@ -2602,13 +2604,14 @@
         try:
             main.log.info( "Getting flows from Mininet" )
             flows = self.getFlowTable( sw, version, debug )
-            if flows == None:
+            if flows is None:
                 return main.ERROR
 
-            if debug: print "flow ids:\n{}\n\n".format(flowId)
+            if debug:
+                print "flow ids:\n{}\n\n".format( flowId )
 
             # Check flowId is a list or a string
-            if type( flowId ) is str:
+            if isinstance( flowId, str ):
                 result = False
                 for f in flows:
                     if flowId in f.get( 'cookie' ):
@@ -2622,7 +2625,8 @@
                 # Save the IDs that are not in Mininet
                 absentIds = [ x for x in flowId if x not in mnFlowIds ]
 
-                if debug: print "mn flow ids:\n{}\n\n".format(mnFlowIds)
+                if debug:
+                    print "mn flow ids:\n{}\n\n".format( mnFlowIds )
 
                 # Print out the IDs that are not in Mininet
                 if absentIds:
@@ -2639,7 +2643,6 @@
             main.log.exception( self.name + ": Uncaught exception!" )
             main.cleanAndExit()
 
-
     def startTcpdump( self, filename, intf="eth0", port="port 6653" ):
         """
            Runs tpdump on an interface and saves the file
@@ -2704,8 +2707,8 @@
             self.handle.sendline( "" )
             self.handle.expect( "mininet>" )
         except pexpect.TIMEOUT:
-            main.log.error(self.name + ": TIMEOUT exception found")
-            main.log.error(self.name + ":     " + self.handle.before)
+            main.log.error( self.name + ": TIMEOUT exception found" )
+            main.log.error( self.name + ":     " + self.handle.before )
             main.cleanAndExit()
         except pexpect.EOF:
             main.log.error( self.name + ": EOF exception found" )
@@ -2948,7 +2951,7 @@
         """
         try:
             self.update()
-            response = self.links(timeout=timeout).split( '\n' )
+            response = self.links( timeout=timeout ).split( '\n' )
 
             # Examples:
             # s1-eth3<->s2-eth1 (OK OK)
@@ -3271,11 +3274,11 @@
                     main.log.info( output )
             return hostResults
         except pexpect.EOF:
-            main.log.error(self.name + ": EOF exception found")
-            main.log.error(self.name + ":     " + self.handle.before)
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":     " + self.handle.before )
             main.cleanAndExit()
         except Exception:
-            main.log.exception(self.name + ": Uncaught exception!")
+            main.log.exception( self.name + ": Uncaught exception!" )
             main.cleanAndExit()
 
     def getHostsOld( self ):
@@ -3304,8 +3307,8 @@
 
             return hostList
         except pexpect.TIMEOUT:
-            main.log.error(self.name + ": TIMEOUT exception found")
-            main.log.error(self.name + ":     " + self.handle.before)
+            main.log.error( self.name + ": TIMEOUT exception found" )
+            main.log.error( self.name + ":     " + self.handle.before )
             main.cleanAndExit()
         except pexpect.EOF:
             main.log.error( self.name + ": EOF exception found" )
@@ -3357,8 +3360,8 @@
 
             return switchList
         except pexpect.TIMEOUT:
-            main.log.error(self.name + ": TIMEOUT exception found")
-            main.log.error(self.name + ":     " + self.handle.before)
+            main.log.error( self.name + ": TIMEOUT exception found" )
+            main.log.error( self.name + ":     " + self.handle.before )
             main.cleanAndExit()
         except pexpect.EOF:
             main.log.error( self.name + ": EOF exception found" )
@@ -3414,7 +3417,7 @@
                     # Get port index from OVS
                     # The index extracted from port name may be inconsistent with ONOS
                     portIndex = -1
-                    if not nodeName1 in portDict.keys():
+                    if nodeName1 not in portDict.keys():
                         portList = self.getOVSPorts( nodeName1 )
                         if len( portList ) == 0:
                             main.log.warn( self.name + ": No port found on switch " + nodeName1 )
@@ -3433,21 +3436,21 @@
                     else:
                         node1 = nodeName1
                         node2 = nodeName2
-                    if not node1 in graphDict.keys():
+                    if node1 not in graphDict.keys():
                         if useId:
-                            graphDict[ node1 ] = { 'edges':{},
-                                                   'dpid':switches[ nodeName1 ][ 'dpid' ],
-                                                   'name':nodeName1,
-                                                   'ports':switches[ nodeName1 ][ 'ports' ],
-                                                   'swClass':switches[ nodeName1 ][ 'swClass' ],
-                                                   'pid':switches[ nodeName1 ][ 'pid' ],
-                                                   'options':switches[ nodeName1 ][ 'options' ] }
+                            graphDict[ node1 ] = { 'edges': {},
+                                                   'dpid': switches[ nodeName1 ][ 'dpid' ],
+                                                   'name': nodeName1,
+                                                   'ports': switches[ nodeName1 ][ 'ports' ],
+                                                   'swClass': switches[ nodeName1 ][ 'swClass' ],
+                                                   'pid': switches[ nodeName1 ][ 'pid' ],
+                                                   'options': switches[ nodeName1 ][ 'options' ] }
                         else:
-                            graphDict[ node1 ] = { 'edges':{} }
+                            graphDict[ node1 ] = { 'edges': {} }
                     else:
                         # Assert node2 is not connected to any current links of node1
                         assert node2 not in graphDict[ node1 ][ 'edges' ].keys()
-                    graphDict[ node1 ][ 'edges' ][ node2 ] = { 'port':portIndex }
+                    graphDict[ node1 ][ 'edges' ][ node2 ] = { 'port': portIndex }
                     # Swap two nodes/ports
                     nodeName1, nodeName2 = nodeName2, nodeName1
                     port1, port2 = port2, port1
@@ -3484,8 +3487,8 @@
 
             return main.TRUE
         except pexpect.TIMEOUT:
-            main.log.error(self.name + ": TIMEOUT exception found")
-            main.log.error(self.name + ":     " + self.handle.before)
+            main.log.error( self.name + ": TIMEOUT exception found" )
+            main.log.error( self.name + ":     " + self.handle.before )
             main.cleanAndExit()
         except pexpect.EOF:
             main.log.error( self.name + ": EOF exception found" )
@@ -3545,8 +3548,8 @@
 
                 return main.TRUE
             except pexpect.TIMEOUT:
-                main.log.error(self.name + ": TIMEOUT exception found")
-                main.log.error(self.name + ":     " + self.handle.before)
+                main.log.error( self.name + ": TIMEOUT exception found" )
+                main.log.error( self.name + ":     " + self.handle.before )
                 main.cleanAndExit()
             except pexpect.EOF:
                 main.log.error( self.name + ": EOF exception found" )
@@ -3572,8 +3575,8 @@
             getattr( main, name )
         except AttributeError:
             # namespace is clear, creating component
-            main.componentDictionary[name] = main.componentDictionary[self.name].copy()
-            main.componentDictionary[name]['connect_order'] = str( int( main.componentDictionary[name]['connect_order'] ) + 1 )
+            main.componentDictionary[ name ] = main.componentDictionary[ self.name ].copy()
+            main.componentDictionary[ name ][ 'connect_order' ] = str( int( main.componentDictionary[ name ][ 'connect_order' ] ) + 1 )
             main.componentInit( name )
         except pexpect.EOF:
             main.log.error( self.name + ": EOF exception found" )
@@ -3606,7 +3609,7 @@
             # Delete component
             delattr( main, name )
             # Delete component from ComponentDictionary
-            del( main.componentDictionary[name] )
+            del( main.componentDictionary[ name ] )
         except pexpect.EOF:
             main.log.error( self.name + ": EOF exception found" )
             main.log.error( self.name + ":     " + self.handle.before )
@@ -3656,25 +3659,24 @@
             try:
                 cmd = devicename + " ifconfig " + intf + " " + status
                 self.handle.sendline( cmd )
-                self.handle.expect("mininet>")
+                self.handle.expect( "mininet>" )
                 return main.TRUE
             except pexpect.TIMEOUT:
-                main.log.exception(self.name + ": Command timed out")
+                main.log.exception( self.name + ": Command timed out" )
                 return main.FALSE
             except pexpect.EOF:
-                main.log.exception(self.name + ": connection closed.")
+                main.log.exception( self.name + ": connection closed." )
                 main.cleanAndExit()
             except TypeError:
-                main.log.exception(self.name + ": TypeError")
+                main.log.exception( self.name + ": TypeError" )
                 main.cleanAndExit()
             except Exception:
-                main.log.exception(self.name + ": Uncaught exception!")
+                main.log.exception( self.name + ": Uncaught exception!" )
                 main.cleanAndExit()
         else:
-            main.log.warn("Interface status should be up or down!")
+            main.log.warn( "Interface status should be up or down!" )
             return main.FALSE
 
 
-
 if __name__ != "__main__":
     sys.modules[ __name__ ] = MininetCliDriver()