diff --git a/mininet/link.py b/mininet/link.py index 29ee07f7f14eaad463c614b85d6190a7fa8532ab..28fa757d388b78042935f473e3b8e0decbd2b48a 100644 --- a/mininet/link.py +++ b/mininet/link.py @@ -160,9 +160,9 @@ def setParam( self, results, method, **param ): f = getattr( self, method, None ) if not f or value is None: return - if type( value ) is list: + if isinstance( value, list ): result = f( *value ) - elif type( value ) is dict: + elif isinstance( value, dict ): result = f( **value ) else: result = f( value ) diff --git a/mininet/node.py b/mininet/node.py index b4ef54dd569d0dd16f760f0bacb93debce2796a9..1687b6eee02afdd4e15c9ff30054976b47556a46 100644 --- a/mininet/node.py +++ b/mininet/node.py @@ -258,7 +258,7 @@ def sendCmd( self, *args, **kwargs ): assert not self.waiting printPid = kwargs.get( 'printPid', True ) # Allow sendCmd( [ list ] ) - if len( args ) == 1 and type( args[ 0 ] ) is list: + if len( args ) == 1 and isinstance( args[ 0 ], list ): cmd = args[ 0 ] # Allow sendCmd( cmd, arg1, arg2... ) elif len( args ) > 0: @@ -352,7 +352,7 @@ def popen( self, *args, **kwargs ): [ 'mnexec', '-da', str( self.pid ) ] } defaults.update( kwargs ) if len( args ) == 1: - if type( args[ 0 ] ) is list: + if isinstance( args[ 0 ], list ): # popen([cmd, arg1, arg2...]) cmd = args[ 0 ] elif isinstance( args[ 0 ], basestring ): @@ -539,9 +539,9 @@ def setParam( self, results, method, **param ): f = getattr( self, method, None ) if not f: return - if type( value ) is list: + if isinstance( value, list ): result = f( *value ) - elif type( value ) is dict: + elif isinstance( valude, dict ): result = f( **value ) else: result = f( value ) @@ -774,7 +774,7 @@ def setCPUs( self, cores, mems=0 ): "Specify (real) cores that our cgroup can run on" if not cores: return - if type( cores ) is list: + if isinstance( cores, list ): cores = ','.join( [ str( c ) for c in cores ] ) self.cgroupSet( resource='cpuset', param='cpus', value=cores ) @@ -937,7 +937,7 @@ def TCReapply( intf ): over tc queuing disciplines. To resolve the conflict, we re-create the user switch's configuration, but as a leaf of the TCIntf-created configuration.""" - if type( intf ) is TCIntf: + if isinstance( intf, TCIntf ): ifspeed = 10000000000 # 10 Gbps minspeed = ifspeed * 0.001 @@ -1097,7 +1097,7 @@ def TCReapply( intf ): """Unfortunately OVS and Mininet are fighting over tc queuing disciplines. As a quick hack/ workaround, we clear OVS's and reapply our own.""" - if type( intf ) is TCIntf: + if isinstance( intf, TCIntf ): intf.config( **intf.params ) def attach( self, intf ): diff --git a/mininet/topo.py b/mininet/topo.py index 22d0c1f5a5f78cdb7b87c91cdcc9673158563b6f..cfa581e09213216e974c4741925b9907da63c1ab 100644 --- a/mininet/topo.py +++ b/mininet/topo.py @@ -45,7 +45,7 @@ def add_edge( self, src, dst, key=None, attr_dict=None, **attrs ): entry = self.edge[ dst ][ src ] = self.edge[ src ][ dst ] # If no key, pick next ordinal number if key is None: - keys = [ k for k in entry.keys() if type( k ) is int ] + keys = [ k for k in entry.keys() if isinstance( k, int ) ] key = max( [ 0 ] + keys ) + 1 entry[ key ] = attr_dict return key diff --git a/mininet/util.py b/mininet/util.py index 1fbc5826d274e0c0f7dfbdc041747dd1cffef49c..74a2424d2134ff538fac86797e51b1e8c8a9026e 100644 --- a/mininet/util.py +++ b/mininet/util.py @@ -388,7 +388,7 @@ def sysctlTestAndSet( name, limit ): #read limit with open( name, 'r' ) as readFile: oldLimit = readFile.readline() - if type( limit ) is int: + if isinstance( limit, int ): #compare integer limits before overriding if int( oldLimit ) < limit: with open( name, 'w' ) as writeFile: