From: Waldemar Kozaczuk <jwkozac...@gmail.com>
Committer: Waldemar Kozaczuk <jwkozac...@gmail.com>
Branch: master

scripts: upgrade to python 3 - part 1.2

Signed-off-by: Waldemar Kozaczuk <jwkozac...@gmail.com>

---
diff --git a/modules/httpserver-html5-gui/tests/testhttpserver.py 
b/modules/httpserver-html5-gui/tests/testhttpserver.py
--- a/modules/httpserver-html5-gui/tests/testhttpserver.py
+++ b/modules/httpserver-html5-gui/tests/testhttpserver.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 import sys
 import argparse
 import os
@@ -17,6 +17,8 @@
 parser.add_argument('--cmd', help='the command to execute')
 parser.add_argument('--use_sudo', help='Use sudo with -n option instead of 
port forwarding', action='store_true')
 parser.add_argument('--jsondir', help='location of the json files', 
default=os.path.join(module_base, '../httpserver-api/api-doc/listings/'))
+parser.add_argument('--test_image', help='the path to the test image')
+parser.add_argument('--hypervisor', action="store", default="qemu", 
help="choose hypervisor to run: qemu, firecracker")
 client.Client.add_arguments(parser)
 
 if __name__ == '__main__':
diff --git a/scripts/osv/modules/api.py b/scripts/osv/modules/api.py
--- a/scripts/osv/modules/api.py
+++ b/scripts/osv/modules/api.py
@@ -47,11 +47,7 @@ def get_jvm_args(self):
         return []
 
 def get_string_object():
-    import sys
-    if sys.version < '3':
-        return basestring
-    else:
-        return str
+    return str
 
 def _to_args_list(text_or_list):
     if not text_or_list:
diff --git a/tests/tst-tcp-hash-cli.py b/tests/tst-tcp-hash-cli.py
--- a/tests/tst-tcp-hash-cli.py
+++ b/tests/tst-tcp-hash-cli.py
@@ -1,6 +1,6 @@
-#!/bin/env python2
+#!/usr/bin/env python3
 import socket
-from Queue import Queue
+from queue import Queue
 from threading import Thread
 import sys
 
@@ -16,7 +16,7 @@ def run(self):
         while True:
             func, args, kargs = self.tasks.get()
             try: func(*args, **kargs)
-            except Exception, e: print e
+            except Exception as e: print(e)
             self.tasks.task_done()
 
 class ThreadPool:
@@ -67,16 +67,16 @@ def make_connection():
         nthreads = int(sys.argv[1])
         connections = int(sys.argv[2])
     except:
-        print "Usage: ./tst-tcp-hash-cli.py <nthreads> <connections>"
+        print("Usage: ./tst-tcp-hash-cli.py <nthreads> <connections>")
         sys.exit()
 
     #data = range(0, (4096**2)*2, 11)
-    data = range(0,4096, 11)
-    data = map(lambda x: chr(x % 256), data)
+    data = list(range(0,4096, 11))
+    data = [chr(x % 256) for x in data]
     expected = hash_function(data)
 
-    print "Sending %d bytes requests, expected hash: %d" % (len(data), 
expected)
-    print "Creating %d threads and making %d connections, please wait..." % 
(nthreads, connections)
+    print("Sending %d bytes requests, expected hash: %d" % (len(data), 
expected))
+    print("Creating %d threads and making %d connections, please wait..." % 
(nthreads, connections))
 
     drops = 0
     hash_errors = 0
@@ -88,6 +88,6 @@ def make_connection():
     pool.wait_completion()
 
     # FIXME: these metrics may not be accurate as I didn't use locks and 
interfere with the test
-    print "Test completed with %d drops and %d hash errors" % (drops, 
hash_errors)
+    print("Test completed with %d drops and %d hash errors" % (drops, 
hash_errors))
 
 

-- 
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to osv-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/osv-dev/0000000000005f7f84059f29cada%40google.com.

Reply via email to