f0c726a42f
This helps with virtualenv although it can open up another security hole if you end up using an unexpected python interpreter. Overall it seems to make sense to err on the side of usability but it's good to be aware of security. However, for the remaining utility scripts that require python 2, we explicitly note this with #!/usr/bin/python2.
30 lines
855 B
Python
Executable File
30 lines
855 B
Python
Executable File
#!/usr/bin/env python
|
|
|
|
from subprocess import check_output as co
|
|
from sys import exit, version_info
|
|
|
|
def run(*args, **kwargs):
|
|
"Run co and decode for python3"
|
|
result = co(*args, **kwargs)
|
|
return result.decode() if version_info[ 0 ] >= 3 else result
|
|
|
|
# Actually run bin/mn rather than importing via python path
|
|
version = 'Mininet ' + run( 'PYTHONPATH=. bin/mn --version 2>&1', shell=True )
|
|
version = version.strip()
|
|
|
|
# Find all Mininet path references
|
|
lines = run( "egrep -or 'Mininet [0-9\.\+]+\w*' *", shell=True )
|
|
|
|
error = False
|
|
|
|
for line in lines.split( '\n' ):
|
|
if line and 'Binary' not in line:
|
|
fname, fversion = line.split( ':' )
|
|
if version != fversion:
|
|
print( "%s: incorrect version '%s' (should be '%s')" % (
|
|
fname, fversion, version ) )
|
|
error = True
|
|
|
|
if error:
|
|
exit( 1 )
|