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:
@@ -3,7 +3,7 @@
|
||||
"Create a 64-node tree network, and test connectivity using ping."
|
||||
|
||||
|
||||
from mininet.log import setLogLevel
|
||||
from mininet.log import setLogLevel, info
|
||||
from mininet.node import UserSwitch, OVSKernelSwitch # , KernelSwitch
|
||||
from mininet.topolib import TreeNet
|
||||
|
||||
@@ -16,17 +16,16 @@ def treePing64():
|
||||
'Open vSwitch kernel': OVSKernelSwitch }
|
||||
|
||||
for name in switches:
|
||||
print( "*** Testing", name, "datapath" )
|
||||
info( "*** Testing", name, "datapath\n" )
|
||||
switch = switches[ name ]
|
||||
network = TreeNet( depth=2, fanout=8, switch=switch )
|
||||
result = network.run( network.pingAll )
|
||||
results[ name ] = result
|
||||
|
||||
print()
|
||||
print( "*** Tree network ping results:" )
|
||||
info( "\n*** Tree network ping results:\n" )
|
||||
for name in switches:
|
||||
print( "%s: %d%% packet loss" % ( name, results[ name ] ) )
|
||||
print()
|
||||
info( "%s: %d%% packet loss\n" % ( name, results[ name ] ) )
|
||||
info( '\n' )
|
||||
|
||||
if __name__ == '__main__':
|
||||
setLogLevel( 'info' )
|
||||
|
||||
Reference in New Issue
Block a user