Pass code check (14.04)

This commit is contained in:
Bob Lantz
2018-07-25 21:30:05 -07:00
parent f4490069ca
commit 8102704726
4 changed files with 13 additions and 10 deletions
+2 -1
View File
@@ -186,7 +186,8 @@ class MininetRunner( object ):
for fileName in files: for fileName in files:
customs = {} customs = {}
if os.path.isfile( fileName ): 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 ) customs, customs )
for name, val in customs.items(): for name, val in customs.items():
self.setCustom( name, val ) self.setCustom( name, val )
+2 -3
View File
@@ -89,7 +89,7 @@ class Node( object ):
self.inNamespace = params.get( 'inNamespace', inNamespace ) self.inNamespace = params.get( 'inNamespace', inNamespace )
# Python 3 complains if we don't wait for shell exit # 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 # Stash configuration parameters for future reference
self.params = params self.params = params
@@ -207,7 +207,7 @@ class Node( object ):
# Leave this is as an instance method for now # Leave this is as an instance method for now
assert self assert self
popen = Popen( cmd, **params ) popen = Popen( cmd, **params )
debug( '_popen', cmd, popen.pid ) debug( '_popen', cmd, popen.pid )
return popen return popen
def cleanup( self ): def cleanup( self ):
@@ -732,7 +732,6 @@ class CPULimitedHost( Host ):
super( CPULimitedHost, self ).cleanup() super( CPULimitedHost, self ).cleanup()
retry( retries=3, delaySecs=.1, fn=self.cgroupDel ) retry( retries=3, delaySecs=.1, fn=self.cgroupDel )
_rtGroupSched = False # internal class var: Is CONFIG_RT_GROUP_SCHED set? _rtGroupSched = False # internal class var: Is CONFIG_RT_GROUP_SCHED set?
@classmethod @classmethod
@@ -35,7 +35,6 @@ class TestSwitchDpidAssignmentOVS( unittest.TestCase ):
self.assertEqual( switch.defaultDpid(), switch.dpid ) self.assertEqual( switch.defaultDpid(), switch.dpid )
net.stop() net.stop()
def dpidFrom( self, num ): def dpidFrom( self, num ):
"Compute default dpid from number" "Compute default dpid from number"
fmt = ( '%0' + str( self.switchClass.dpidLen ) + 'x' ) fmt = ( '%0' + str( self.switchClass.dpidLen ) + 'x' )
@@ -50,7 +49,6 @@ class TestSwitchDpidAssignmentOVS( unittest.TestCase ):
self.assertEqual( switch.dpid, dpid ) self.assertEqual( switch.dpid, dpid )
net.stop() net.stop()
def testDefaultDpidAssignmentFailure( self ): def testDefaultDpidAssignmentFailure( self ):
"""Verify that Default dpid assignment raises an Exception if the """Verify that Default dpid assignment raises an Exception if the
name of the switch does not contin a digit. Also verify the name of the switch does not contin a digit. Also verify the
+9 -4
View File
@@ -16,7 +16,7 @@ import sys
# Python 2/3 compatibility # Python 2/3 compatibility
Python3 = sys.version_info[0] == 3 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 Encoding = 'utf-8' if Python3 else None
def decode( s ): def decode( s ):
"Decode a byte string if needed for Python 3" "Decode a byte string if needed for Python 3"
@@ -26,17 +26,20 @@ def encode( s ):
return s.encode( Encoding ) if Python3 else s return s.encode( Encoding ) if Python3 else s
try: try:
import pexpect as oldpexpect import pexpect as oldpexpect
class Pexpect( object ): class Pexpect( object ):
"Custom pexpect that is compatible with str" "Custom pexpect that is compatible with str"
def spawn( self, *args, **kwargs): @staticmethod
def spawn( *args, **kwargs):
"pexpect.spawn that is compatible with str" "pexpect.spawn that is compatible with str"
if Python3 and 'encoding' not in kwargs: if Python3 and 'encoding' not in kwargs:
kwargs.update( encoding='utf-8' ) kwargs.update( encoding='utf-8' )
return oldpexpect.spawn( *args, **kwargs ) return oldpexpect.spawn( *args, **kwargs )
def __getattr__( self, name ): def __getattr__( self, name ):
return getattr( oldpexpect, name ) return getattr( oldpexpect, name )
pexpect = Pexpect() pexpect = Pexpect()
except: except ImportError:
pass pass
@@ -84,7 +87,7 @@ def oldQuietRun( *cmd ):
# This is a bit complicated, but it enables us to # This is a bit complicated, but it enables us to
# monitor command output as it is happening # monitor command output as it is happening
# pylint: disable=too-many-branches # pylint: disable=too-many-branches,too-many-statements
def errRun( *cmd, **kwargs ): def errRun( *cmd, **kwargs ):
"""Run a command and return stdout, stderr and return code """Run a command and return stdout, stderr and return code
cmd: string or list of command and args cmd: string or list of command and args
@@ -415,11 +418,13 @@ def pmonitor(popens, timeoutms=500, readline=True,
# Use non-blocking reads # Use non-blocking reads
flags = fcntl( fd, F_GETFL ) flags = fcntl( fd, F_GETFL )
fcntl( fd, F_SETFL, flags | O_NONBLOCK ) fcntl( fd, F_SETFL, flags | O_NONBLOCK )
def readit( f ): def readit( f ):
"Helper function - read line or data" "Helper function - read line or data"
# Note this will block if readline is True # Note this will block if readline is True
line = f.readline() if readline else f.read( readmax ) line = f.readline() if readline else f.read( readmax )
return decode( line ) return decode( line )
while popens: while popens:
fds = poller.poll( timeoutms ) fds = poller.poll( timeoutms )
if fds: if fds: