diff options
author | Patrick Uiterwijk <patrick@puiterwijk.org> | 2017-01-10 23:52:13 +0000 |
---|---|---|
committer | Jeff Darcy <jdarcy@redhat.com> | 2017-01-12 11:02:01 -0800 |
commit | 2010eedfe8edbb9842d022b93d6bf2a5226cedc0 (patch) | |
tree | a44cbec0f01451900a29cb1775dcce8ffc847a4f /api/examples | |
parent | b3fbd95233b5f6db6ae0921c4917316175a1d082 (diff) |
Make getvolfile.py example pep8 compliant
Change-Id: I7d3c1e871b9fa3859745f4d67acf05f16c7ccf5f
BUG: 1412002
Signed-off-by: Patrick Uiterwijk <patrick@puiterwijk.org>
Reviewed-on: http://review.gluster.org/16372
Smoke: Gluster Build System <jenkins@build.gluster.org>
Reviewed-by: Niels de Vos <ndevos@redhat.com>
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Diffstat (limited to 'api/examples')
-rwxr-xr-x | api/examples/getvolfile.py | 59 |
1 files changed, 30 insertions, 29 deletions
diff --git a/api/examples/getvolfile.py b/api/examples/getvolfile.py index 184586c632d..0c95213f0b6 100755 --- a/api/examples/getvolfile.py +++ b/api/examples/getvolfile.py @@ -7,37 +7,38 @@ api = ctypes.CDLL(ctypes.util.find_library("gfapi")) api.glfs_get_volfile.argtypes = [ctypes.c_void_p, ctypes.c_void_p, ctypes.c_ulong] -api.glfs_get_volfile.restype = ctypes.c_long; +api.glfs_get_volfile.restype = ctypes.c_long -def get_volfile (host, volume): - # This is set to a large value to exercise the "buffer not big enough" - # path. More realistically, you'd just start with a huge buffer. - BUF_LEN = 0 - fs = api.glfs_new(volume) - #api.glfs_set_logging(fs,"/dev/stderr",7) - api.glfs_set_volfile_server(fs,"tcp",host,24007) - api.glfs_init(fs) - vbuf = ctypes.create_string_buffer(BUF_LEN) - vlen = api.glfs_get_volfile(fs,vbuf,BUF_LEN) - if vlen < 0: - vlen = BUF_LEN - vlen - vbuf = ctypes.create_string_buffer(vlen) - vlen = api.glfs_get_volfile(fs,vbuf,vlen) - api.glfs_fini(fs) - if vlen <= 0: - return vlen - return vbuf.value[:vlen] + +def get_volfile(host, volume): + # This is set to a large value to exercise the "buffer not big enough" + # path. More realistically, you'd just start with a huge buffer. + BUF_LEN = 0 + fs = api.glfs_new(volume) + # api.glfs_set_logging(fs,"/dev/stderr",7) + api.glfs_set_volfile_server(fs, "tcp", host, 24007) + api.glfs_init(fs) + vbuf = ctypes.create_string_buffer(BUF_LEN) + vlen = api.glfs_get_volfile(fs, vbuf, BUF_LEN) + if vlen < 0: + vlen = BUF_LEN - vlen + vbuf = ctypes.create_string_buffer(vlen) + vlen = api.glfs_get_volfile(fs, vbuf, vlen) + api.glfs_fini(fs) + if vlen <= 0: + return vlen + return vbuf.value[:vlen] if __name__ == "__main__": - import sys + import sys - try: - res = apply(get_volfile,sys.argv[1:3]) - except: - print "fetching volfile failed (volume not started?)" + try: + res = apply(get_volfile, sys.argv[1:3]) + except: + print "fetching volfile failed (volume not started?)" - try: - for line in res.split('\n'): - print line - except: - print "bad return value %s" % res + try: + for line in res.split('\n'): + print line + except: + print "bad return value %s" % res |