[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/build/uploadToS3.py b/tools/build/uploadToS3.py
index 720878c..40ebe34 100755
--- a/tools/build/uploadToS3.py
+++ b/tools/build/uploadToS3.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
"""
Upload a file to S3
"""
@@ -20,7 +20,7 @@
key = basename( filename )
else:
key = dest + basename( filename ) #FIXME add the /
- print '* Uploading', filename, 'to bucket', bucket, 'as', key
+ print('* Uploading', filename, 'to bucket', bucket, 'as', key)
stdout.flush()
start = time()
def callback( transmitted, size ):
@@ -28,9 +28,9 @@
elapsed = time() - start
percent = 100.0 * transmitted / size
kbps = .001 * transmitted / elapsed
- print ( '\r%d bytes transmitted of %d (%.2f%%),'
+ print(( '\r%d bytes transmitted of %d (%.2f%%),'
' %.2f KB/sec ' %
- ( transmitted, size, percent, kbps ) ),
+ ( transmitted, size, percent, kbps ) ), end=' ')
stdout.flush()
conn = S3Connection()
bucket = conn.get_bucket( bucket )
@@ -38,11 +38,11 @@
k.key = key
if overwrite or not k.exists():
k.set_contents_from_filename( filename, cb=callback, num_cb=100 )
- print
+ print()
elapsed = time() - start
- print "* elapsed time: %.2f seconds" % elapsed
+ print("* elapsed time: %.2f seconds" % elapsed)
else:
- print 'file', basename( filename ), 'already exists in', bucket.name
+ print('file', basename( filename ), 'already exists in', bucket.name)
def testAccess( bucket=None ):
"Verify access to a bucket"
@@ -51,7 +51,7 @@
conn = S3Connection()
bucket = conn.get_bucket( bucket )
- print bucket.get_acl()
+ print(bucket.get_acl())
if __name__ == '__main__':