diff --git a/bin/mn b/bin/mn index 46667ab..3c5a7ec 100755 --- a/bin/mn +++ b/bin/mn @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python """ Mininet runner diff --git a/examples/baresshd.py b/examples/baresshd.py index 39b683a..c04db0e 100755 --- a/examples/baresshd.py +++ b/examples/baresshd.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python "This example doesn't use OpenFlow, but attempts to run sshd in a namespace." diff --git a/examples/bind.py b/examples/bind.py index 9a7272a..d2ee46f 100755 --- a/examples/bind.py +++ b/examples/bind.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python """ bind.py: Bind mount example diff --git a/examples/cluster.py b/examples/cluster.py index 78cfbc0..5ce44e7 100755 --- a/examples/cluster.py +++ b/examples/cluster.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python """ cluster.py: prototyping/experimentation for distributed Mininet, diff --git a/examples/clustercli.py b/examples/clustercli.py index 75cd317..34f0956 100644 --- a/examples/clustercli.py +++ b/examples/clustercli.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python "CLI for Mininet Cluster Edition prototype demo" diff --git a/examples/clusterdemo.py b/examples/clusterdemo.py index b117ba4..0e97cc3 100755 --- a/examples/clusterdemo.py +++ b/examples/clusterdemo.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python "clusterdemo.py: demo of Mininet Cluster Edition prototype" diff --git a/examples/clusterperf.py b/examples/clusterperf.py index ffa48a8..f18f072 100755 --- a/examples/clusterperf.py +++ b/examples/clusterperf.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python "clusterperf.py compare the maximum throughput between SSH and GRE tunnels" diff --git a/examples/consoles.py b/examples/consoles.py index 6a8aca1..a9af8fb 100755 --- a/examples/consoles.py +++ b/examples/consoles.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python """ consoles.py: bring up a bunch of miniature consoles on a virtual network diff --git a/examples/controllers.py b/examples/controllers.py index dad8e5f..4cd8866 100755 --- a/examples/controllers.py +++ b/examples/controllers.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python """ Create a network where different switches are connected to diff --git a/examples/controllers2.py b/examples/controllers2.py index ceefc32..f20bf3c 100755 --- a/examples/controllers2.py +++ b/examples/controllers2.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python """ This example creates a multi-controller network from semi-scratch by diff --git a/examples/controlnet.py b/examples/controlnet.py index eb7aaa5..bba4f00 100755 --- a/examples/controlnet.py +++ b/examples/controlnet.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python """ controlnet.py: Mininet with a custom control network diff --git a/examples/cpu.py b/examples/cpu.py index a5ddded..a983517 100755 --- a/examples/cpu.py +++ b/examples/cpu.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python """ cpu.py: test iperf bandwidth for varying cpu limits diff --git a/examples/emptynet.py b/examples/emptynet.py index 474886c..877e07a 100755 --- a/examples/emptynet.py +++ b/examples/emptynet.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python """ This example shows how to create an empty Mininet object diff --git a/examples/hwintf.py b/examples/hwintf.py index 990beb0..31b8656 100755 --- a/examples/hwintf.py +++ b/examples/hwintf.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python """ This example shows how to add an interface (for example a real diff --git a/examples/intfoptions.py b/examples/intfoptions.py index f7373ed..3df590f 100755 --- a/examples/intfoptions.py +++ b/examples/intfoptions.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python ''' example of using various TCIntf options. diff --git a/examples/limit.py b/examples/limit.py index a75bb50..5063acc 100755 --- a/examples/limit.py +++ b/examples/limit.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python """ limit.py: example of using link and CPU limits diff --git a/examples/linearbandwidth.py b/examples/linearbandwidth.py index e66f36b..6802e7e 100755 --- a/examples/linearbandwidth.py +++ b/examples/linearbandwidth.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python """ Test bandwidth (using iperf) on linear networks of varying size, diff --git a/examples/linuxrouter.py b/examples/linuxrouter.py index 861c319..6f1afa1 100755 --- a/examples/linuxrouter.py +++ b/examples/linuxrouter.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python """ linuxrouter.py: Example network with Linux IP router diff --git a/examples/miniedit.py b/examples/miniedit.py index 24d1ad3..1263a74 100755 --- a/examples/miniedit.py +++ b/examples/miniedit.py @@ -1704,7 +1704,7 @@ class MiniEdit( Frame ): # debug( "Now saving under %s\n" % fileName ) f = open(fileName, 'wb') - f.write("#!/usr/bin/python\n") + f.write("#!/usr/bin/env python\n") f.write("\n") f.write("from mininet.net import Mininet\n") f.write("from mininet.node import Controller, RemoteController, OVSController\n") diff --git a/examples/mobility.py b/examples/mobility.py index 05a8869..ea8f99e 100755 --- a/examples/mobility.py +++ b/examples/mobility.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python """ Simple example of Mobility with Mininet diff --git a/examples/multilink.py b/examples/multilink.py index e95730a..6f7a5fb 100755 --- a/examples/multilink.py +++ b/examples/multilink.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python """ This is a simple example that demonstrates multiple links diff --git a/examples/multiping.py b/examples/multiping.py index 7d723a4..3700f9e 100755 --- a/examples/multiping.py +++ b/examples/multiping.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python """ multiping.py: monitor multiple sets of hosts using ping diff --git a/examples/multipoll.py b/examples/multipoll.py index 13ceaa7..fcf63ed 100755 --- a/examples/multipoll.py +++ b/examples/multipoll.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python """ Simple example of sending output to multiple files and diff --git a/examples/multitest.py b/examples/multitest.py index b208ddf..294a313 100755 --- a/examples/multitest.py +++ b/examples/multitest.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python """ This example shows how to create a network and run multiple tests. diff --git a/examples/nat.py b/examples/nat.py index bb7e8c4..49506b1 100755 --- a/examples/nat.py +++ b/examples/nat.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python """ Example to create a Mininet topology and connect it to the internet via NAT diff --git a/examples/natnet.py b/examples/natnet.py index 638a437..12a1698 100755 --- a/examples/natnet.py +++ b/examples/natnet.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python """ natnet.py: Example network with NATs diff --git a/examples/numberedports.py b/examples/numberedports.py index 0bd1d3e..dd0259e 100755 --- a/examples/numberedports.py +++ b/examples/numberedports.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python """ Create a network with 5 hosts, numbered 1-4 and 9. diff --git a/examples/popen.py b/examples/popen.py index 94e7b45..b710408 100755 --- a/examples/popen.py +++ b/examples/popen.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python """ This example monitors a number of hosts using host.popen() and diff --git a/examples/popenpoll.py b/examples/popenpoll.py index 7f56ef0..3b5312e 100755 --- a/examples/popenpoll.py +++ b/examples/popenpoll.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python "Monitor multiple hosts using popen()/pmonitor()" diff --git a/examples/scratchnet.py b/examples/scratchnet.py index a8d536d..ad43a98 100755 --- a/examples/scratchnet.py +++ b/examples/scratchnet.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python """ Build a simple network from scratch, using mininet primitives. diff --git a/examples/scratchnetuser.py b/examples/scratchnetuser.py index 2c50f9d..99f5bf0 100755 --- a/examples/scratchnetuser.py +++ b/examples/scratchnetuser.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python """ Build a simple network from scratch, using mininet primitives. diff --git a/examples/simpleperf.py b/examples/simpleperf.py index 91e7e01..b29d88a 100755 --- a/examples/simpleperf.py +++ b/examples/simpleperf.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python """ Simple example of setting network and CPU parameters diff --git a/examples/sshd.py b/examples/sshd.py index ac62fb5..80fe0f8 100755 --- a/examples/sshd.py +++ b/examples/sshd.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python """ Create a network and start sshd(8) on each host. diff --git a/examples/tree1024.py b/examples/tree1024.py index e19abae..35a796c 100755 --- a/examples/tree1024.py +++ b/examples/tree1024.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python """ Create a 1024-host network, and run the CLI on it. diff --git a/examples/treeping64.py b/examples/treeping64.py index 1c044b1..3f86679 100755 --- a/examples/treeping64.py +++ b/examples/treeping64.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python "Create a 64-node tree network, and test connectivity using ping." diff --git a/util/doxify.py b/util/doxify.py index c6a78ff..7b9d4c1 100755 --- a/util/doxify.py +++ b/util/doxify.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python2 """ Convert simple documentation to epydoc/pydoctor-compatible markup @@ -83,7 +83,3 @@ if __name__ == '__main__': infile.close() os.close( outfid ) call( [ 'doxypy', outname ] ) - - - - diff --git a/util/unpep8 b/util/unpep8 index 17f5dd5..c6dad6e 100755 --- a/util/unpep8 +++ b/util/unpep8 @@ -1,7 +1,7 @@ -#!/usr/bin/python +#!/usr/bin/python2 """ -Translate from PEP8 Python style to Mininet (i.e. Arista-like) +Translate from PEP8 Python style to Mininet (i.e. Arista-like) Python style usage: unpep8 < old.py > new.py @@ -51,7 +51,7 @@ def fixUnderscoreTriplet( match ): def reinstateCapWords( text ): underscoreTriplet = re.compile( r'[A-Za-z0-9]_[A-Za-z0-9]' ) return underscoreTriplet.sub( fixUnderscoreTriplet, text ) - + def replaceTripleApostrophes( text ): "Replace triple apostrophes with triple quotes." return text.replace( "'''", '"""') @@ -60,7 +60,7 @@ def simplifyTripleQuotes( text ): "Fix single-line doc strings." r = re.compile( r'"""([^\"\n]+)"""' ) return r.sub( r'"\1"', text ) - + def insertExtraSpaces( text ): "Insert extra spaces inside of parentheses and brackets/curly braces." lparen = re.compile( r'\((?![\s\)])' ) @@ -76,9 +76,9 @@ def insertExtraSpaces( text ): lcurly = re.compile( r'\{(?![\s\}])' ) text = lcurly.sub( r'{ ', text ) rcurly = re.compile( r'([^\s\{])(?=\})' ) - text = rcurly.sub( r'\1 ', text) + text = rcurly.sub( r'\1 ', text) return text - + def fixDoxygen( text ): """Translate @param foo to foo:, @return bar to returns: bar, and @author me to author: me""" @@ -96,11 +96,11 @@ def removeCommentFirstBlankLine( text ): "Remove annoying blank lines after first line in comments." line = re.compile( r'("""[^\n]*\n)\s*\n', re.MULTILINE ) return line.sub( r'\1', text ) - + def fixArgs( match, kwarg = re.compile( r'(\w+) = ' ) ): "Replace foo = bar with foo=bar." return kwarg.sub( r'\1=', match.group() ) - + def fixKeywords( text ): "Change keyword argumentsfrom foo = bar to foo=bar." args = re.compile( r'\(([^\)]+)\)', re.MULTILINE ) @@ -115,7 +115,7 @@ def fixKeywords( text ): def lineIter( text ): "Simple iterator over lines in text." for line in text.splitlines(): yield line - + def stringIter( strList ): "Yield strings in strList." for s in strList: yield s @@ -134,7 +134,7 @@ def restoreRegex( regex, old, new ): # This is a cheap hack, and it may not work 100%, since # it doesn't handle multiline strings. # However, it should be mostly harmless... - + def restoreStrings( oldText, newText ): "Restore strings from oldText into newText, returning result." oldLines, newLines = lineIter( oldText ), lineIter( newText ) @@ -149,13 +149,13 @@ def restoreStrings( oldText, newText ): newLine = restoreRegex( tickStrings, oldLine, newLine ) result += newLine + '\n' return result - + # This might be slightly controversial, since it uses # three spaces to line up multiline comments. However, # I much prefer it. Limitations: if you have deeper # indents in comments, they will be eliminated. ;-( -def fixComment( match, +def fixComment( match, indentExp=re.compile( r'\n([ ]*)(?=[^/s])', re.MULTILINE ), trailingQuotes=re.compile( r'\s+"""' ) ): "Re-indent comment, and join trailing quotes." @@ -166,17 +166,17 @@ def fixComment( match, if len( originalIndent ) is not 0: indent += ' ' comment = indentExp.sub( indent, comment ) return originalIndent + trailingQuotes.sub( '"""', comment ) - + def fixCommentIndents( text ): "Fix multiline comment indentation." comments = re.compile( r'^([ ]*)("""[^"]*""")$', re.MULTILINE ) return comments.sub( fixComment, text ) - + def removeBogusLinefeeds( text ): "Remove extra linefeeds at the end of single-line comments." bogusLfs = re.compile( r'"([^"\n]*)\n"', re.MULTILINE ) return bogusLfs.sub( '"\1"', text) - + def convertFromPep8( program ): oldProgram = program # Program text transforms diff --git a/util/versioncheck.py b/util/versioncheck.py index 0a4af2b..a9d6cfc 100755 --- a/util/versioncheck.py +++ b/util/versioncheck.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python from subprocess import check_output as co from sys import exit, version_info diff --git a/util/vm/build.py b/util/vm/build.py index de566ca..a9f2860 100755 --- a/util/vm/build.py +++ b/util/vm/build.py @@ -1,4 +1,4 @@ -#!/usr/bin/python2.7 +#!/usr/bin/python2 """ build.py: build a Mininet VM