From 33e39a2471d013e5c198884fa61d99bce372507b Mon Sep 17 00:00:00 2001 From: Bob Lantz Date: Tue, 25 Jun 2013 20:26:06 -0700 Subject: [PATCH] Fix some pylint messages. --- examples/nat.py | 4 +--- mininet/clean.py | 2 +- mininet/log.py | 18 ++++++++---------- mininet/node.py | 4 ++-- mininet/term.py | 2 +- 5 files changed, 13 insertions(+), 17 deletions(-) diff --git a/examples/nat.py b/examples/nat.py index 292d2a3..fcad85c 100755 --- a/examples/nat.py +++ b/examples/nat.py @@ -10,10 +10,9 @@ Glen Gibb, February 2011 """ from mininet.cli import CLI -from mininet.log import lg, info +from mininet.log import lg from mininet.node import Node from mininet.topolib import TreeNet -from mininet.util import quietRun ################################# def startNAT( root, inetIntf='eth0', subnet='10.0/8' ): @@ -75,7 +74,6 @@ def connectToInternet( network, switch='s1', rootip='10.254', subnet='10.0/8'): subnet: Mininet subnet""" switch = network.get( switch ) prefixLen = subnet.split( '/' )[ 1 ] - routes = [ subnet ] # host networks to route to # Create a node in root namespace root = Node( 'root', inNamespace=False ) diff --git a/mininet/clean.py b/mininet/clean.py index 66103bd..c5ef1ab 100755 --- a/mininet/clean.py +++ b/mininet/clean.py @@ -55,7 +55,7 @@ def cleanup(): sh( 'ovs-vsctl del-br ' + dp ) info( "*** Removing all links of the pattern foo-ethX\n" ) - links = sh( "ip link show | egrep -o '(\w+-eth\w+)'" ).split( '\n' ) + links = sh( r"ip link show | egrep -o '(\w+-eth\w+)'" ).split( '\n' ) for link in links: if link != '': sh( "ip link del " + link ) diff --git a/mininet/log.py b/mininet/log.py index cd00821..a046f50 100644 --- a/mininet/log.py +++ b/mininet/log.py @@ -60,18 +60,16 @@ class Singleton( type ): See http://en.wikipedia.org/wiki/SingletonPattern#Python Intended to be used as a __metaclass_ param, as shown for the class - below. + below.""" - Changed cls first args to mcs to satisfy pylint.""" + def __init__( cls, name, bases, dict_ ): + super( Singleton, cls ).__init__( name, bases, dict_ ) + cls.instance = None - def __init__( mcs, name, bases, dict_ ): - super( Singleton, mcs ).__init__( name, bases, dict_ ) - mcs.instance = None - - def __call__( mcs, *args, **kw ): - if mcs.instance is None: - mcs.instance = super( Singleton, mcs ).__call__( *args, **kw ) - return mcs.instance + def __call__( cls, *args, **kw ): + if cls.instance is None: + cls.instance = super( Singleton, cls ).__call__( *args, **kw ) + return cls.instance class MininetLogger( Logger, object ): diff --git a/mininet/node.py b/mininet/node.py index b323db6..d6a66ba 100644 --- a/mininet/node.py +++ b/mininet/node.py @@ -759,7 +759,7 @@ class Switch( Node ): def defaultDpid( self ): "Derive dpid from switch name, s1 -> 1" try: - dpid = int( re.findall( '\d+', self.name )[ 0 ] ) + dpid = int( re.findall( r'\d+', self.name )[ 0 ] ) dpid = hex( dpid )[ 2: ] dpid = '0' * ( self.dpidLen - len( dpid ) ) + dpid return dpid @@ -787,7 +787,7 @@ class Switch( Node ): def connected( self ): "Is the switch connected to a controller? (override this method)" - return False + return False and self # satisfy pylint def __repr__( self ): "More informative string representation" diff --git a/mininet/term.py b/mininet/term.py index 4c6370c..5857fa8 100644 --- a/mininet/term.py +++ b/mininet/term.py @@ -54,7 +54,7 @@ def makeTerm( node, title='Node', term='xterm', display=None ): def runX11( node, cmd ): "Run an X11 client on a node" - display, tunnel = tunnelX11( node ) + _display, tunnel = tunnelX11( node ) popen = node.popen( cmd ) return [ tunnel, popen ]