Skip to content
Permalink
Browse files

Pass code check (14.04)

  • Loading branch information...
lantz committed Jul 26, 2018
1 parent f449006 commit 81027047262822eccf5644270493a187c88b02ce
Showing with 13 additions and 10 deletions.
  1. +2 −1 bin/mn
  2. +2 −3 mininet/node.py
  3. +0 −2 mininet/test/test_switchdpidassignment.py
  4. +9 −4 mininet/util.py
3 bin/mn
@@ -186,7 +186,8 @@ class MininetRunner( object ):
for fileName in files:
customs = {}
if os.path.isfile( fileName ):
exec( compile ( open( fileName ).read(), fileName, 'exec' ),
# pylint: disable=exec-used
exec( compile( open( fileName ).read(), fileName, 'exec' ),
customs, customs )
for name, val in customs.items():
self.setCustom( name, val )
@@ -89,7 +89,7 @@ def __init__( self, name, inNamespace=True, **params ):
self.inNamespace = params.get( 'inNamespace', inNamespace )

# Python 3 complains if we don't wait for shell exit
self.waitExited = params.get( 'waitExited', Python3==True )
self.waitExited = params.get( 'waitExited', Python3 == True )

# Stash configuration parameters for future reference
self.params = params
@@ -207,7 +207,7 @@ def _popen( self, cmd, **params ):
# Leave this is as an instance method for now
assert self
popen = Popen( cmd, **params )
debug( '_popen', cmd, popen.pid )
debug( '_popen', cmd, popen.pid )
return popen

def cleanup( self ):
@@ -732,7 +732,6 @@ def cleanup( self ):
super( CPULimitedHost, self ).cleanup()
retry( retries=3, delaySecs=.1, fn=self.cgroupDel )


_rtGroupSched = False # internal class var: Is CONFIG_RT_GROUP_SCHED set?

@classmethod
@@ -35,7 +35,6 @@ def testDefaultDpid( self ):
self.assertEqual( switch.defaultDpid(), switch.dpid )
net.stop()


def dpidFrom( self, num ):
"Compute default dpid from number"
fmt = ( '%0' + str( self.switchClass.dpidLen ) + 'x' )
@@ -50,7 +49,6 @@ def testActualDpidAssignment( self ):
self.assertEqual( switch.dpid, dpid )
net.stop()


def testDefaultDpidAssignmentFailure( self ):
"""Verify that Default dpid assignment raises an Exception if the
name of the switch does not contin a digit. Also verify the
@@ -16,7 +16,7 @@

# Python 2/3 compatibility
Python3 = sys.version_info[0] == 3
BaseString = str if Python3 else str.__base__
BaseString = str if Python3 else getattr( str, '__base__' )
Encoding = 'utf-8' if Python3 else None
def decode( s ):
"Decode a byte string if needed for Python 3"
@@ -26,17 +26,20 @@ def encode( s ):
return s.encode( Encoding ) if Python3 else s
try:
import pexpect as oldpexpect

class Pexpect( object ):
"Custom pexpect that is compatible with str"
def spawn( self, *args, **kwargs):
@staticmethod
def spawn( *args, **kwargs):
"pexpect.spawn that is compatible with str"
if Python3 and 'encoding' not in kwargs:
kwargs.update( encoding='utf-8' )
return oldpexpect.spawn( *args, **kwargs )

def __getattr__( self, name ):
return getattr( oldpexpect, name )
pexpect = Pexpect()
except:
except ImportError:
pass


@@ -84,7 +87,7 @@ def oldQuietRun( *cmd ):
# This is a bit complicated, but it enables us to
# monitor command output as it is happening

# pylint: disable=too-many-branches
# pylint: disable=too-many-branches,too-many-statements
def errRun( *cmd, **kwargs ):
"""Run a command and return stdout, stderr and return code
cmd: string or list of command and args
@@ -415,11 +418,13 @@ def pmonitor(popens, timeoutms=500, readline=True,
# Use non-blocking reads
flags = fcntl( fd, F_GETFL )
fcntl( fd, F_SETFL, flags | O_NONBLOCK )

def readit( f ):
"Helper function - read line or data"
# Note this will block if readline is True
line = f.readline() if readline else f.read( readmax )
return decode( line )

while popens:
fds = poller.poll( timeoutms )
if fds:

0 comments on commit 8102704

Please sign in to comment.
You can’t perform that action at this time.