[ONOS-7039] [ONOS-7044] Fix PEP8 Warnings in TestON

Change-Id: Ied79ff9caff5487a6df50466307f757468d7ca3a
diff --git a/TestON/tests/SCPF/SCPFswitchLat/SCPFswitchLat.py b/TestON/tests/SCPF/SCPFswitchLat/SCPFswitchLat.py
index 66b3dc0..fa168f6 100644
--- a/TestON/tests/SCPF/SCPFswitchLat/SCPFswitchLat.py
+++ b/TestON/tests/SCPF/SCPFswitchLat/SCPFswitchLat.py
@@ -1,5 +1,5 @@
 """
-Copyright 2015 Open Networking Foundation (ONF)
+Copyright 2015 Open Networking Foundation ( ONF )
 
 Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
 the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
@@ -8,7 +8,7 @@
     TestON is free software: you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
     the Free Software Foundation, either version 2 of the License, or
-    (at your option) any later version.
+    ( at your option ) any later version.
 
     TestON is distributed in the hope that it will be useful,
     but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,8 +18,7 @@
     You should have received a copy of the GNU General Public License
     along with TestON.  If not, see <http://www.gnu.org/licenses/>.
 """
-
-'''
+"""
     SCPFswitchLat
     Test Switch add/remove latency
     calculate package latency between switch and ONOS
@@ -27,8 +26,7 @@
     TCP -- Feature Reply -- Role Request -- Role Reply -- Device -- Graph
     Siwtch Down:
     Openflow FIN/ACK -- ACK -- Device -- Graph
-'''
-
+"""
 class SCPFswitchLat:
 
     def __init__( self ):
@@ -37,7 +35,7 @@
     def CASE0( self, main ):
         import os
         import imp
-        '''
+        """
         - GIT
         - BUILDING ONOS
             Pull specific ONOS branch, then Build ONOS ono ONOS Bench.
@@ -45,7 +43,7 @@
             test env. We want Jenkins jobs to pull&build for flexibility to handle
             different versions of ONOS.
         - Construct tests variables
-        '''
+        """
         try:
             from tests.dependencies.ONOSSetup import ONOSSetup
             main.testSetUp = ONOSSetup()
@@ -56,10 +54,10 @@
         stepResult = main.FALSE
         try:
             # The dictionary to record different type of wrongs
-            main.wrong = { 'totalWrong': 0, 'skipDown' : 0, 'TsharkValueIncorrect': 0,
-                    'TypeError' : 0, 'decodeJasonError': 0,
-                    'checkResultIncorrect': 0 }
-            main.maxWrong = int( main.params[ 'TEST' ] [ 'MaxWrong' ] )
+            main.wrong = { 'totalWrong': 0, 'skipDown': 0, 'TsharkValueIncorrect': 0,
+                           'TypeError': 0, 'decodeJasonError': 0,
+                           'checkResultIncorrect': 0 }
+            main.maxWrong = int( main.params[ 'TEST' ][ 'MaxWrong' ] )
             main.resultRange = main.params[ 'TEST' ][ 'ResultRange' ]
             main.searchTerm = main.params[ 'TEST' ][ 'SearchTerm' ]
             main.MN1Ip = main.params[ 'MN' ][ 'ip1' ]
@@ -72,7 +70,7 @@
             main.scale = ( main.params[ 'SCALE' ] ).split( "," )
 
             main.ofPackage = main.params[ 'TSHARK' ]
-            main.defaultTopoCfg = main.params [ 'CFG' ][ 'defaultTopo' ]
+            main.defaultTopoCfg = main.params[ 'CFG' ][ 'defaultTopo' ]
             main.tsharkResultPath = main.params[ 'TEST' ][ 'tsharkResultPath' ]
             main.sampleSize = int( main.params[ 'TEST' ][ 'sampleSize' ] )
             main.warmUp = int( main.params[ 'TEST' ][ 'warmUp' ] )
@@ -90,9 +88,9 @@
             resultsDB.close()
 
             main.switchFunc = imp.load_source( main.dependencyFunc,
-                                           main.dependencyPath +
-                                           main.dependencyFunc +
-                                           ".py" )
+                                               main.dependencyPath +
+                                               main.dependencyFunc +
+                                               ".py" )
         except Exception as e:
             main.testSetUp.envSetupException( e )
         main.testSetUp.evnSetupConclusion( stepResult )
@@ -144,26 +142,26 @@
         import json
         import numpy
 
-        resultDict = { 'up' : {}, 'down' : {} }
+        resultDict = { 'up': {}, 'down': {} }
         for i in range( 1, main.Cluster.numCtrls + 1 ):
             resultDict[ 'up' ][ 'node' + str( i ) ] = {}
             resultDict[ 'up' ][ 'node' + str( i ) ][ 'Ave' ] = {}
             resultDict[ 'up' ][ 'node' + str( i ) ][ 'Std' ] = {}
-            resultDict[ 'up' ][ 'node' + str( i ) ][ 'T_F' ] = []#TCP to Feature
-            resultDict[ 'up' ][ 'node' + str( i ) ][ 'F_R' ] = []#Feature to Role
-            resultDict[ 'up' ][ 'node' + str( i ) ][ 'RQ_RR' ] = []#role request to role reply
-            resultDict[ 'up' ][ 'node' + str( i ) ][ 'RR_D' ] = []#role reply to Device
-            resultDict[ 'up' ][ 'node' + str( i ) ][ 'D_G' ] = []#Device to Graph
-            resultDict[ 'up' ][ 'node' + str( i ) ][ 'E_E' ] = []#TCP to Graph
+            resultDict[ 'up' ][ 'node' + str( i ) ][ 'T_F' ] = []  # TCP to Feature
+            resultDict[ 'up' ][ 'node' + str( i ) ][ 'F_R' ] = []  # Feature to Role
+            resultDict[ 'up' ][ 'node' + str( i ) ][ 'RQ_RR' ] = []  # role request to role reply
+            resultDict[ 'up' ][ 'node' + str( i ) ][ 'RR_D' ] = []  # role reply to Device
+            resultDict[ 'up' ][ 'node' + str( i ) ][ 'D_G' ] = []  # Device to Graph
+            resultDict[ 'up' ][ 'node' + str( i ) ][ 'E_E' ] = []  # TCP to Graph
 
         for i in range( 1, main.Cluster.numCtrls + 1 ):
             resultDict[ 'down' ][ 'node' + str( i ) ] = {}
             resultDict[ 'down' ][ 'node' + str( i ) ][ 'Ave' ] = {}
             resultDict[ 'down' ][ 'node' + str( i ) ][ 'Std' ] = {}
-            resultDict[ 'down' ][ 'node' + str( i ) ][ 'FA_A' ] = []#Fin_ack to ACK
-            resultDict[ 'down' ][ 'node' + str( i ) ][ 'A_D' ] = []#Ack to Device
-            resultDict[ 'down' ][ 'node' + str( i ) ][ 'D_G' ] = []#Device to Graph
-            resultDict[ 'down' ][ 'node' + str( i ) ][ 'E_E' ] = []#fin_ack to Graph
+            resultDict[ 'down' ][ 'node' + str( i ) ][ 'FA_A' ] = []  # Fin_ack to ACK
+            resultDict[ 'down' ][ 'node' + str( i ) ][ 'A_D' ] = []  # Ack to Device
+            resultDict[ 'down' ][ 'node' + str( i ) ][ 'D_G' ] = []  # Device to Graph
+            resultDict[ 'down' ][ 'node' + str( i ) ][ 'E_E' ] = []  # fin_ack to Graph
         for i in range( 0, main.sampleSize + main.warmUp ):
             main.log.info( "************************************************************" )
             main.log.info( "************************ Iteration: {} **********************" .format( str( i + 1 ) ) )
@@ -176,12 +174,12 @@
             else:
                 main.switchFunc.captureOfPack( main, main.device, main.ofPackage,
                                                "up", resultDict, False )
-                main.switchFunc.captureOfPack ( main, main.device, main.ofPackage,
-                                               "down", resultDict, False )
+                main.switchFunc.captureOfPack( main, main.device, main.ofPackage,
+                                                "down", resultDict, False )
                 main.Cluster.active( 0 ).CLI.removeDevice( "of:0000000000000001" )
 
         # Dictionary for result
-        maxDict  = {}
+        maxDict = {}
         maxDict[ 'down' ] = {}
         maxDict[ 'up' ] = {}
         maxDict[ 'down' ][ 'max' ] = 0
diff --git a/TestON/tests/SCPF/SCPFswitchLat/dependencies/switchFunc.py b/TestON/tests/SCPF/SCPFswitchLat/dependencies/switchFunc.py
index cde275e..7a159ba 100644
--- a/TestON/tests/SCPF/SCPFswitchLat/dependencies/switchFunc.py
+++ b/TestON/tests/SCPF/SCPFswitchLat/dependencies/switchFunc.py
@@ -1,5 +1,5 @@
 """
-Copyright 2016 Open Networking Foundation (ONF)
+Copyright 2016 Open Networking Foundation ( ONF )
 
 Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
 the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
@@ -8,7 +8,7 @@
     TestON is free software: you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
     the Free Software Foundation, either version 2 of the License, or
-    (at your option) any later version.
+    ( at your option ) any later version.
 
     TestON is distributed in the hope that it will be useful,
     but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,29 +18,29 @@
     You should have received a copy of the GNU General Public License
     along with TestON.  If not, see <http://www.gnu.org/licenses/>.
 """
-
-'''
+"""
     Wrapper function for SCPFswitchLat test
     Assign switch and capture openflow package
     remove switch and caputer openflow package
     calculate latency
-'''
+"""
 import time
 import json
 
+
 def getTimestampFromLog( index, searchTerm ):
-    '''
+    """
     Get timestamp value of the search term from log.
     Args:
         index: the index of cli
         searchTerm: the key term of timestamp
 
-    '''
+    """
     lines = main.Cluster.active( index ).CLI.logSearch( mode='last', searchTerm=searchTerm )
     try:
-        assert lines != None
-        logString = lines[ len ( lines ) - 1 ]
-        #get the target value
+        assert lines is not None
+        logString = lines[ len( lines ) - 1 ]
+        # get the target value
         line = logString.split( "time = " )
         key = line[ 1 ].split( " " )
         return int( key[ 0 ] )
@@ -51,13 +51,14 @@
         main.log.warn( "Search Term Not Found" )
         return 0
 
+
 def processPackage( package ):
-    '''
+    """
     split package information to dictionary
     Args:
         package: Package String
 
-    '''
+    """
     pacakge = package.split( " " )
     dic = {}
     for s in pacakge:
@@ -68,28 +69,30 @@
             continue
     return dic
 
+
 def findSeqBySeqAck( seq, packageList ):
-    '''
+    """
     Find specific Seq of package in packageList
     Args:
         seq: seq from last TCP package
         packageList: find package in packageList
 
-    '''
+    """
     for l in packageList:
         temp = processPackage( l )
         tA = temp[ 'Ack' ]
         if int( seq ) + 1 == int( tA ):
             return temp[ 'Seq' ]
 
+
 def arrangeTsharkFile( switchStatus, keyTerm ):
-    '''
+    """
     Arrange different tshark messeage from overall file to different specific files
     Args:
         switchStatus: switch up or down
         keyTerm: A dictionary that store the path name as value and the searchTerm as key
 
-    '''
+    """
     with open( main.tsharkResultPath[ switchStatus ][ 'ALL' ], 'r' ) as resultFile:
         resultText = resultFile.readlines()
         resultFile.close()
@@ -102,13 +105,14 @@
                     outputfile.write( line )
                     outputfile.close()
 
+
 def checkResult( result1, result2, result3 ):
-    '''
+    """
     Check if the inputs meet the requirement
     Returns:
             1 means the results are right, 0 means the results are wrong
 
-    '''
+    """
     result = check( result1 ) + check( result2 ) + check( result3 )
     if result < 3:
         # if any result is wrong, increase the main wrong number
@@ -118,32 +122,34 @@
         return 0
     return 1
 
+
 def check( result ):
-    '''
+    """
     Check the single input.
     Returns:
             1 means the input is good, 0 means the input is wrong
 
-    '''
+    """
     if result < int( main.resultRange[ 'Min' ] ) or result > int( main.resultRange[ 'Max' ] ):
         main.log.debug( str( result ) + " is not meet the requirement" )
         return 0
     return 1
 
+
 def checkTotalWrongNum():
-    '''
+    """
     Check if the total wrong number is bigger than the max wrong number. If it is, then exit the
     test.
 
-    '''
+    """
     # if there are too many wrongs in this test, then exit
-    if main.wrong['totalWrong'] > main.maxWrong:
+    if main.wrong[ 'totalWrong' ] > main.maxWrong:
         main.log.error( "The total wrong number exceeds %d, test terminated" % main.maxWrong )
         main.cleanAndExit()
 
-def captureOfPack( main, deviceName, ofPack, switchStatus, resultDict, warmup ):
-    '''
 
+def captureOfPack( main, deviceName, ofPack, switchStatus, resultDict, warmup ):
+    """
     Args:
         main: TestON class
         deviceName: device name
@@ -152,7 +158,7 @@
         resultDict: dictionary to contain result
         warmup: warm up boolean
 
-    '''
+    """
     main.log.debug( "TOTAL WRONG: " + str( main.wrong ) )
     for d in ofPack[ switchStatus ]:
         main.log.info( "Clean up Tshark" )
@@ -168,14 +174,14 @@
         cleanTerm = ofPack[ switchStatus ][ d ].replace( '\\', '' )
         keyTerm[ cleanTerm ] = d
     # Delete the last '|'
-    grepString = grepString[:-1]
+    grepString = grepString[ :-1 ]
     # open tshark
     main.log.info( "starting tshark capture" )
     main.ONOSbench.tsharkGrep( grepString, main.tsharkResultPath[ switchStatus ][ 'ALL' ], grepOptions='-E' )
     if switchStatus == 'up':
         # if up, assign switch to controller
         time.sleep( main.measurementSleep )
-        main.log.info( 'Assigning {} to controller'.format( deviceName ))
+        main.log.info( 'Assigning {} to controller'.format( deviceName ) )
         main.Mininet1.assignSwController( sw=deviceName, ip=main.Cluster.active( 0 ).ipAddress )
         time.sleep( main.measurementSleep )
     if switchStatus == 'down':
@@ -208,8 +214,8 @@
                 main.log.info( "Capture result:" + resultText )
                 resultText = resultText.strip()
                 resultText = resultText.split( " " )
-                if len(resultText) > 1:
-                    tempResultDict[d]= int( ( float( resultText[ 1 ] ) * 1000 ) )
+                if len( resultText ) > 1:
+                    tempResultDict[ d ] = int( ( float( resultText[ 1 ] ) * 1000 ) )
                 resultFile.close()
     elif switchStatus == 'down':
         # if state is down, we should capture Fin/Ack and ACK package
@@ -220,7 +226,7 @@
             resultFile.close()
         FinAckSeq = processPackage( FinAckText )[ 'Seq' ]
         FinAckOFseq = findSeqBySeqAck( FinAckSeq, resultText )
-        if FinAckOFseq == None:
+        if FinAckOFseq is None:
             main.log.warn( "Tshark Result was incorrect!" )
             main.log.warn( resultText )
             main.wrong[ 'TsharkValueIncorrect' ] += 1
@@ -269,7 +275,7 @@
                 return
             if not warmup:
                 resultDict[ switchStatus ][ d ][ 'T_F' ].append( T_Ftemp )
-                resultDict[ switchStatus ][ d ][ 'F_R' ].append( F_Rtemp  )
+                resultDict[ switchStatus ][ d ][ 'F_R' ].append( F_Rtemp )
                 resultDict[ switchStatus ][ d ][ 'RQ_RR' ].append( RQ_RRtemp )
 
             main.log.info( "{} TCP to Feature: {}".format( d, str( T_Ftemp ) ) )
@@ -284,7 +290,7 @@
             # get onos metrics timestamps
             try:
                 response = json.loads( main.Cluster.active( i - 1 ).CLI.topologyEventsMetrics() )
-                DeviceTime = getTimestampFromLog( i - 1, searchTerm=main.searchTerm[switchStatus] )
+                DeviceTime = getTimestampFromLog( i - 1, searchTerm=main.searchTerm[ switchStatus ] )
                 main.log.info( "ONOS{} device Event timestamp: {}".format( i, "%.2f" % DeviceTime ) )
                 GraphTime = int( response.get( "topologyGraphEventTimestamp" ).get( "value" ) )
                 main.log.info( "ONOS{} Graph Event timestamp: {}".format( i, GraphTime ) )
@@ -331,14 +337,14 @@
                     checkTotalWrongNum()
                     break
                 if not warmup and check == 1:
-                    resultDict[ switchStatus ][ 'node' + str( i )][ 'RR_D' ].append( RR_Dtemp )
-                    resultDict[ switchStatus ][ 'node' + str( i )][ 'D_G' ].append( D_Gtemp )
-                    resultDict[ switchStatus ][ 'node' + str( i )][ 'E_E' ].append( E_Etemp )
+                    resultDict[ switchStatus ][ 'node' + str( i ) ][ 'RR_D' ].append( RR_Dtemp )
+                    resultDict[ switchStatus ][ 'node' + str( i ) ][ 'D_G' ].append( D_Gtemp )
+                    resultDict[ switchStatus ][ 'node' + str( i ) ][ 'E_E' ].append( E_Etemp )
             else:
-                main.wrong['checkResultIncorrect'] += 1
+                main.wrong[ 'checkResultIncorrect' ] += 1
                 main.wrong[ 'totalWrong' ] += 1
                 checkTotalWrongNum()
-                main.log.debug("Skip this iteration due to the None Devicetime")
+                main.log.debug( "Skip this iteration due to the None Devicetime" )
 
     if switchStatus == "down":
         # down Latency
@@ -389,7 +395,7 @@
                     check = checkResult( A_Dtemp, D_Gtemp, E_Etemp )
                     if check == 1:
                         main.log.info( "ACK to device: {}".format( A_Dtemp ) )
-                        main.log.info( "Device to Graph: {}".format( D_Gtemp )  )
+                        main.log.info( "Device to Graph: {}".format( D_Gtemp ) )
                         main.log.info( "End to End: {}".format( E_Etemp ) )
                         main.log.info( "================================================" )
                 except KeyError:
@@ -417,8 +423,7 @@
                     resultDict[ switchStatus ][ 'node' + str( i ) ][ 'E_E' ].append( E_Etemp )
 
             else:
-                main.wrong['checkResultIncorrect'] += 1
-                main.wrong['totalWrong'] += 1
+                main.wrong[ 'checkResultIncorrect' ] += 1
+                main.wrong[ 'totalWrong' ] += 1
                 checkTotalWrongNum()
-                main.log.debug("Skip this iteration due to the None Devicetime")
-
+                main.log.debug( "Skip this iteration due to the None Devicetime" )
diff --git a/TestON/tests/SCPF/SCPFswitchLat/dependencies/topo-perf-1sw.py b/TestON/tests/SCPF/SCPFswitchLat/dependencies/topo-perf-1sw.py
index 1793e2b..3652c82 100644
--- a/TestON/tests/SCPF/SCPFswitchLat/dependencies/topo-perf-1sw.py
+++ b/TestON/tests/SCPF/SCPFswitchLat/dependencies/topo-perf-1sw.py
@@ -1,5 +1,5 @@
 """
-Copyright 2015 Open Networking Foundation (ONF)
+Copyright 2015 Open Networking Foundation ( ONF )
 
 Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
 the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
@@ -8,7 +8,7 @@
     TestON is free software: you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
     the Free Software Foundation, either version 2 of the License, or
-    (at your option) any later version.
+    ( at your option ) any later version.
 
     TestON is distributed in the hope that it will be useful,
     but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,17 +18,17 @@
     You should have received a copy of the GNU General Public License
     along with TestON.  If not, see <http://www.gnu.org/licenses/>.
 """
-
-'''
+"""
 Simple 1 switch topology for topologoy performance test
-'''
-
+"""
 from mininet.topo import Topo
 
-class MyTopo( Topo ):
-    def __init__(self):
-        Topo.__init__(self)
 
-        s3 = self.addSwitch( "s3", dpid="0000000000000001")
+class MyTopo( Topo ):
+
+    def __init__( self ):
+        Topo.__init__( self )
+
+        s3 = self.addSwitch( "s3", dpid="0000000000000001" )
 
 topos = { 'mytopo': ( lambda: MyTopo() ) }