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:
Bob Lantz
2018-07-25 19:44:45 -07:00
parent f94ee8ec97
commit af4921adc5
3 changed files with 5 additions and 4 deletions
+1 -1
View File
@@ -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
+1 -1
View File
@@ -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
+3 -2
View File
@@ -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, ''