print -> info; end the horror of print vs. print()
Although we could use print() from __future__, this messes up scripts which use examples as modules. The simple, if not nicest for 2.7, solution is to use info(), output() and other mininet.log functions. The disadvantage is that we may have to adjust things if we change info() to add automatic newlines, but we can burn that bridge in Mininet 3.x.
This commit is contained in:
@@ -8,7 +8,7 @@ monitoring them
|
||||
|
||||
from mininet.topo import SingleSwitchTopo
|
||||
from mininet.net import Mininet
|
||||
from mininet.log import setLogLevel
|
||||
from mininet.log import info, setLogLevel
|
||||
|
||||
from time import time
|
||||
from select import poll, POLLIN
|
||||
@@ -55,7 +55,7 @@ def monitorTest( N=3, seconds=3 ):
|
||||
net = Mininet( topo )
|
||||
net.start()
|
||||
hosts = net.hosts
|
||||
print( "Starting test..." )
|
||||
info( "Starting test...\n" )
|
||||
server = hosts[ 0 ]
|
||||
outfiles, errfiles = {}, {}
|
||||
for h in hosts:
|
||||
@@ -69,10 +69,10 @@ def monitorTest( N=3, seconds=3 ):
|
||||
'>', outfiles[ h ],
|
||||
'2>', errfiles[ h ],
|
||||
'&' )
|
||||
print( "Monitoring output for", seconds, "seconds" )
|
||||
info( "Monitoring output for", seconds, "seconds\n" )
|
||||
for h, line in monitorFiles( outfiles, seconds, timeoutms=500 ):
|
||||
if h:
|
||||
print( '%s: %s' % ( h.name, line ) )
|
||||
info( '%s: %s\n' % ( h.name, line ) )
|
||||
for h in hosts:
|
||||
h.cmd('kill %ping')
|
||||
net.stop()
|
||||
|
||||
Reference in New Issue
Block a user