Minor changes for Python 3
items() vs. iteritems() and decode() bytes in monitorFiles Probably not strictly correct if bytes are split - we still need to deal with this properly.
This commit is contained in:
+1
-1
@@ -126,7 +126,7 @@ class ClusterCleanup( object ):
|
|||||||
def cleanup( cls ):
|
def cleanup( cls ):
|
||||||
"Clean up"
|
"Clean up"
|
||||||
info( '*** Cleaning up cluster\n' )
|
info( '*** Cleaning up cluster\n' )
|
||||||
for server, user in cls.serveruser.iteritems():
|
for server, user in cls.serveruser.items():
|
||||||
if server == 'localhost':
|
if server == 'localhost':
|
||||||
# Handled by mininet.clean.cleanup()
|
# Handled by mininet.clean.cleanup()
|
||||||
continue
|
continue
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ class MininetFacade( object ):
|
|||||||
args: unnamed networks passed as arguments
|
args: unnamed networks passed as arguments
|
||||||
kwargs: named networks passed as arguments"""
|
kwargs: named networks passed as arguments"""
|
||||||
self.net = net
|
self.net = net
|
||||||
self.nets = [ net ] + list( args ) + kwargs.values()
|
self.nets = [ net ] + list( args ) + list( kwargs.values() )
|
||||||
self.nameToNet = kwargs
|
self.nameToNet = kwargs
|
||||||
self.nameToNet['net'] = net
|
self.nameToNet['net'] = net
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ monitoring them
|
|||||||
from mininet.topo import SingleSwitchTopo
|
from mininet.topo import SingleSwitchTopo
|
||||||
from mininet.net import Mininet
|
from mininet.net import Mininet
|
||||||
from mininet.log import info, setLogLevel
|
from mininet.log import info, setLogLevel
|
||||||
|
from mininet.util import decode
|
||||||
|
|
||||||
from time import time
|
from time import time
|
||||||
from select import poll, POLLIN
|
from select import poll, POLLIN
|
||||||
@@ -19,7 +20,7 @@ def monitorFiles( outfiles, seconds, timeoutms ):
|
|||||||
"Monitor set of files and return [(host, line)...]"
|
"Monitor set of files and return [(host, line)...]"
|
||||||
devnull = open( '/dev/null', 'w' )
|
devnull = open( '/dev/null', 'w' )
|
||||||
tails, fdToFile, fdToHost = {}, {}, {}
|
tails, fdToFile, fdToHost = {}, {}, {}
|
||||||
for h, outfile in outfiles.iteritems():
|
for h, outfile in outfiles.items():
|
||||||
tail = Popen( [ 'tail', '-f', outfile ],
|
tail = Popen( [ 'tail', '-f', outfile ],
|
||||||
stdout=PIPE, stderr=devnull )
|
stdout=PIPE, stderr=devnull )
|
||||||
fd = tail.stdout.fileno()
|
fd = tail.stdout.fileno()
|
||||||
@@ -40,7 +41,7 @@ def monitorFiles( outfiles, seconds, timeoutms ):
|
|||||||
host = fdToHost[ fd ]
|
host = fdToHost[ fd ]
|
||||||
# Wait for a line of output
|
# Wait for a line of output
|
||||||
line = f.readline().strip()
|
line = f.readline().strip()
|
||||||
yield host, line
|
yield host, decode( line )
|
||||||
else:
|
else:
|
||||||
# If we timed out, return nothing
|
# If we timed out, return nothing
|
||||||
yield None, ''
|
yield None, ''
|
||||||
|
|||||||
Reference in New Issue
Block a user