]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
tests: Make misc. Python tests compatible with Python 3 10177/head
authorOleh Prypin <oleh@pryp.in>
Fri, 24 Jun 2016 12:54:20 +0000 (15:54 +0300)
committerOleh Prypin <oleh@pryp.in>
Thu, 21 Jul 2016 15:35:17 +0000 (18:35 +0300)
Signed-off-by: Oleh Prypin <oleh@pryp.in>
src/test/admin_socket/objecter_requests
src/test/bench/smalliobenchprocessor.py

index 8083dcafe88d2a2043d248a299367fb0354d0575..c2655cdb74b7c08d92710ceeb5fe42c08d756bbf 100755 (executable)
@@ -29,8 +29,8 @@ def check_osd_ops(ops):
     def add_to_mapping(mapping, key, value, msg):
         if key in mapping:
             if mapping[key] != value:
-                print mapping[key], '!=', value
-                print msg
+                print('%s != %s' % (mapping[key], value))
+                print(msg)
                 found_error[0] = True
         else:
             mapping[key] = value
index b0a7f08bd3aa108eb80af3975a181c4d3aeb0614..7286db9640155c1ddd7573c8b0b511f2c544f77c 100644 (file)
@@ -2,12 +2,13 @@ import json
 import sys
 from pylab import hist
 import gzip
+import io
 
 def get_next_line(line, output):
     val = json.loads(line)
     if val['type'] not in output:
         output[val['type']] = {}
-    for (name, value) in val.iteritems():
+    for (name, value) in val.items():
         if name == "type":
             continue
         if name == "seq":
@@ -17,11 +18,10 @@ def get_next_line(line, output):
         output[val['type']][name] += [float(value)]
 
 def wrapgz(gfilename):
-    def retval():
-        gfile = gzip.open(gfilename, 'rb')
-        gfile.__exit__ = lambda: gfile.close()
-        return gfile
-    return (gfilename, retval)
+    gfile = gzip.open(gfilename, 'rb')
+    if sys.version_info[0] >= 3:
+        gfile = io.TextIOWrapper(gfile)
+    return gfile
 
 def read_all_input(filename):
     cur = {}
@@ -30,7 +30,7 @@ def read_all_input(filename):
         openfn = wrapgz
     with openfn(filename) as fh:
         for line in fh:
-            get_next_line(line, cur);
+            get_next_line(line, cur)
     return cur
 
 def write_committed_latency(out, bins, **kwargs):