Skip to content

Commit

Permalink
Merge pull request #10177 from BlaXpirit/ceph-tests-py3
Browse files Browse the repository at this point in the history
pybind: Port Python-based tests and remaining Python bindings to Python 3

Reviewed-by: Case Bodley <cbodley@redhat.com>
Reviewed-by: John Spray <jspray@redhat.com>
Reviewed-by: Josh Durgin <jdurgin@redhat.com>
  • Loading branch information
jdurgin committed Jul 29, 2016
2 parents a955647 + b775b3d commit e5b3ee0
Show file tree
Hide file tree
Showing 12 changed files with 280 additions and 258 deletions.
3 changes: 1 addition & 2 deletions src/pybind/cephfs/cephfs.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -613,8 +613,7 @@ cdef class LibCephFS(object):

if not isinstance(mode, int):
raise TypeError('mode must be an int')
if isinstance(flags, basestring):
flags = cstr(flags, 'flags')
if isinstance(flags, str):
cephfs_flags = 0
if flags == '':
cephfs_flags = os.O_RDONLY
Expand Down
12 changes: 6 additions & 6 deletions src/pybind/rbd/rbd.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ class RBD(object):
break
elif ret != -errno.ERANGE:
raise make_ex(ret, 'error listing images')
return [decode_cstr(name) for name in c_names[:ret].split('\0')
return [decode_cstr(name) for name in c_names[:ret].split(b'\0')
if name]
finally:
free(c_names)
Expand Down Expand Up @@ -1913,8 +1913,8 @@ written." % (self.name, ret, length))
raise make_ex(ret, 'error listing images')
if ret == 0:
return []
pools = map(decode_cstr, c_pools[:pools_size - 1].split('\0'))
images = map(decode_cstr, c_images[:images_size - 1].split('\0'))
pools = map(decode_cstr, c_pools[:pools_size - 1].split(b'\0'))
images = map(decode_cstr, c_images[:images_size - 1].split(b'\0'))
return list(zip(pools, images))
finally:
free(c_pools)
Expand Down Expand Up @@ -1961,9 +1961,9 @@ written." % (self.name, ret, length))
raise make_ex(ret, 'error listing images')
if ret == 0:
return []
clients = map(decode_cstr, c_clients[:clients_size - 1].split('\0'))
cookies = map(decode_cstr, c_cookies[:cookies_size - 1].split('\0'))
addrs = map(decode_cstr, c_addrs[:addrs_size - 1].split('\0'))
clients = map(decode_cstr, c_clients[:clients_size - 1].split(b'\0'))
cookies = map(decode_cstr, c_cookies[:cookies_size - 1].split(b'\0'))
addrs = map(decode_cstr, c_addrs[:addrs_size - 1].split(b'\0'))
return {
'tag' : decode_cstr(c_tag),
'exclusive' : exclusive == 1,
Expand Down
4 changes: 2 additions & 2 deletions src/test/admin_socket/objecter_requests
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions src/test/bench/smalliobenchprocessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
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":
Expand All @@ -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 = {}
Expand All @@ -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):
Expand Down
Loading

0 comments on commit e5b3ee0

Please sign in to comment.