Revision b1ec912d mininet/util.py

View differences:

mininet/util.py
25 25
    return check_call( cmd.split( ' ' ) )
26 26

  
27 27
# pylint doesn't understand explicit type checking
28
# pylint: disable-msg=E1103
28
# pylint: disable=E1103
29 29

  
30 30
def oldQuietRun( *cmd ):
31 31
    """Run a command, routing stderr to stdout, and return the output.
......
119 119
    "Run a command and return merged stdout and stderr"
120 120
    return errRun( cmd, stderr=STDOUT, **kwargs )[ 0 ]
121 121

  
122
# pylint: enable-msg=E1103
123
# pylint: disable-msg=E1101
122
# pylint: enable=E1103
123
# pylint: disable=E1101
124 124

  
125 125
def isShellBuiltin( cmd ):
126 126
    "Return True if cmd is a bash builtin."
......
133 133

  
134 134
isShellBuiltin.builtIns = None
135 135

  
136
# pylint: enable-msg=E1101
136
# pylint: enable=E1101
137 137

  
138 138
# Interface management
139 139
#
......
148 148
# live in the root namespace and thus do not have to be
149 149
# explicitly moved.
150 150

  
151
def makeIntfPair( intf1, intf2, addr1=None, addr2=None, run=quietRun ):
151
def makeIntfPair( intf1, intf2, addr1=None, addr2=None, runCmd=quietRun ):
152 152
    """Make a veth pair connecting intf1 and intf2.
153 153
       intf1: string, interface
154 154
       intf2: string, interface
155
       node: node to run on or None (default)
155
       runCmd: function to run shell commands (quietRun)
156 156
       returns: ip link add result"""
157 157
    # Delete any old interfaces with the same names
158
    run( 'ip link del ' + intf1 )
159
    run( 'ip link del ' + intf2 )
158
    runCmd( 'ip link del ' + intf1 )
159
    runCmd( 'ip link del ' + intf2 )
160 160
    # Create new pair
161 161
    if addr1 is None and addr2 is None:
162 162
        cmd = 'ip link add name ' + intf1 + ' type veth peer name ' + intf2
163 163
    else:
164 164
        cmd = ( 'ip link add name ' + intf1 + ' address ' + addr1 +
165 165
                ' type veth peer name ' + intf2 + ' address ' + addr2 )
166
    cmdOutput = run( cmd )
166
    cmdOutput = runCmd( cmd )
167 167
    if cmdOutput == '':
168 168
        return True
169 169
    else:
......
202 202
        return False
203 203
    return True
204 204

  
205
def moveIntf( intf, dstNode, srcNode=None, printError=True,
205
def moveIntf( intf, dstNode, printError=True,
206 206
             retries=3, delaySecs=0.001 ):
207 207
    """Move interface to node, retrying on failure.
208 208
       intf: string, interface
......
296 296
def ipParse( ip ):
297 297
    "Parse an IP address and return an unsigned int."
298 298
    args = [ int( arg ) for arg in ip.split( '.' ) ]
299
    while ( len(args) < 4 ):
299
    while len(args) < 4:
300 300
        args.append( 0 )
301 301
    return ipNum( *args )
302 302

  
......
427 427
        sysctlTestAndSet( 'net.ipv4.route.max_size', 32768 )
428 428
        #Increase number of PTYs for nodes
429 429
        sysctlTestAndSet( 'kernel.pty.max', 20000 )
430
    except:
430
    except Exception:
431 431
        warn( "*** Error setting resource limits. "
432 432
              "Mininet's performance may be affected.\n" )
433 433

  
......
545 545
def waitListening( client=None, server='127.0.0.1', port=80, timeout=None ):
546 546
    """Wait until server is listening on port.
547 547
       returns True if server is listening"""
548
    run = ( client.cmd if client else
548
    runCmd = ( client.cmd if client else
549 549
                partial( quietRun, shell=True ) )
550
    if not run( 'which telnet' ):
550
    if not runCmd( 'which telnet' ):
551 551
        raise Exception('Could not find telnet' )
552 552
    serverIP = server if isinstance( server, basestring ) else server.IP()
553 553
    cmd = ( 'sh -c "echo A | telnet -e A %s %s"' %

Also available in: Unified diff