[WIP] ONOS-8091 Port python script and utilities to python3
Steps performed so far:
- Updated bash scripts and similar to explicitly invoke python3 (instead of python)
- Updated all python scripts using 2to3
Testing these changes will be a major headache because:
- different scripts are executed in different environments
(e.g., Jenkins, cell servers, tutorial VMs, etc.)
- we don’t have control on all environments
- some environments we used to control have been dismissed
(e.g., cell servers)
The approach for now is to focus on the essentials:
- Jenkins jobs for pre-merge and release
Test and fix everything else as the need arises.
Change-Id: I943e214760c9dea9a7ded0d47ef08adbc0ed0bec
diff --git a/tools/dev/mininet/examples/ha.py b/tools/dev/mininet/examples/ha.py
index 18f1222..1ec6932 100755
--- a/tools/dev/mininet/examples/ha.py
+++ b/tools/dev/mininet/examples/ha.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
"""
NOTES
@@ -196,13 +196,13 @@
def start( self ):
output( "(starting HTTP Server)" )
# start python web server as a bg process
- self.cmd( 'python -m SimpleHTTPServer &> web.log &' )
+ self.cmd( 'python3 -m SimpleHTTPServer &> web.log &' )
def stop( self ):
# XXX is this ever called?
- print "Stopping HTTP Server..."
- print self.cmd( 'fg' )
- print self.cmd( '\x03' ) # ctrl-c
+ print("Stopping HTTP Server...")
+ print(self.cmd( 'fg' ))
+ print(self.cmd( '\x03' )) # ctrl-c
class DynamicONOSNode( onos.ONOSNode ):
@@ -278,7 +278,7 @@
l.rotate( -1 )
return perms
- print "Generating %s with %s" % ( location, str(nodes) )
+ print("Generating %s with %s" % ( location, str(nodes) ))
port = 9876
ips = [ node.IP() for node in nodes ]
node = lambda k: { 'id': k, 'ip': k, 'port': port }
@@ -411,7 +411,7 @@
for node in cluster.activeNodes:
node.shouldStart = True
else:
- print "Incorrect test"
+ print("Incorrect test")
return
net.start()
if args.interactive:
diff --git a/tools/dev/mininet/examples/multicluster.py b/tools/dev/mininet/examples/multicluster.py
index 29e2b56..1ad7c5b 100755
--- a/tools/dev/mininet/examples/multicluster.py
+++ b/tools/dev/mininet/examples/multicluster.py
@@ -1,5 +1,4 @@
-#!/usr/bin/python
-
+#!/usr/bin/python3
"""
multicluster.py: multiple ONOS clusters example
@@ -85,7 +84,7 @@
cmap.setdefault( c, [] ).append( s.name )
for c in sorted( cmap.keys() ):
switches = ' '.join( cmap[ c ] )
- print '%s: %s' % ( c, switches )
+ print('%s: %s' % ( c, switches ))
ONOSCLI.do_controllers = do_controllers