3 from subprocess import check_output as co
4 from sys import exit, version_info
6 def run(*args, **kwargs):
7 "Run co and decode for python3"
8 result = co(*args, **kwargs)
9 return result.decode() if version_info[ 0 ] >= 3 else result
11 # Actually run bin/mn rather than importing via python path
12 version = 'Mininet ' + run( 'PYTHONPATH=. bin/mn --version 2>&1', shell=True )
13 version = version.strip()
15 # Find all Mininet path references
16 lines = run( "egrep -or 'Mininet [0-9\.\+]+\w*' *", shell=True )
20 for line in lines.split( '\n' ):
21 if line and 'Binary' not in line:
22 fname, fversion = line.split( ':' )
23 if version != fversion:
24 print( "%s: incorrect version '%s' (should be '%s')" % (
25 fname, fversion, version ) )