diff options
author | Kaleb S. KEITHLEY <kkeithle@redhat.com> | 2018-04-13 09:13:16 -0400 |
---|---|---|
committer | Kaleb KEITHLEY <kkeithle@redhat.com> | 2018-05-02 11:28:46 +0000 |
commit | 4e7b423d3c3137c3f83b71b36279e1a544154833 (patch) | |
tree | e59dc57aa319a5e145161a0e32fba9fc74773e91 /tests/utils | |
parent | 9da91172538a2a95fba609c93e199db159fd1938 (diff) | |
download | glusterfs-4e7b423d3c3137c3f83b71b36279e1a544154833.tar.gz glusterfs-4e7b423d3c3137c3f83b71b36279e1a544154833.tar.xz glusterfs-4e7b423d3c3137c3f83b71b36279e1a544154833.zip |
core/various: python3 compat, prepare for python2 -> python3
see https://review.gluster.org/#/c/19788/
use print fn from __future__
Change-Id: If5075d8d9ca9641058fbc71df8a52aa35804cda4
updates: #411
Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
Diffstat (limited to 'tests/utils')
-rwxr-xr-x | tests/utils/getfattr.py | 19 | ||||
-rwxr-xr-x | tests/utils/gfid-access.py | 7 | ||||
-rwxr-xr-x | tests/utils/pidof.py | 11 |
3 files changed, 20 insertions, 17 deletions
diff --git a/tests/utils/getfattr.py b/tests/utils/getfattr.py index 6636644f67..7d1f7368e3 100755 --- a/tests/utils/getfattr.py +++ b/tests/utils/getfattr.py @@ -1,5 +1,6 @@ #!/usr/bin/python2 +from __future__ import print_function import os import sys from optparse import OptionParser @@ -32,22 +33,22 @@ def getfattr(path, option): def print_getfattr (path, option, encoded_attr=None): if encoded_attr: if option.encoding == "hex": - print ("%s=0x%s" % (option.name, encoded_attr)) + print(("%s=0x%s" % (option.name, encoded_attr))) elif option.encoding == "base64": - print ("%s=0s%s" % (option.name, encoded_attr)) + print(("%s=0s%s" % (option.name, encoded_attr))) else: - print ("%s=\"%s\"" % (option.name, encoded_attr)) + print(("%s=\"%s\"" % (option.name, encoded_attr))) else: - print option.name + print(option.name) return def print_header (path, absnames): if absnames: - print ("# file: %s" % path) + print(("# file: %s" % path)) else: print ("getfattr: Removing leading '/' from absolute path names") - print ("# file: %s" % path[1:]) + print(("# file: %s" % path[1:])) if __name__ == '__main__': usage = "usage: %prog [-n name|-d] [-e en] [-m pattern] path...." @@ -99,8 +100,8 @@ if __name__ == '__main__': if (not (option.encoding.strip() == "hex" or option.encoding.strip() == "base64" or option.encoding.strip() == "text")): - print ("unrecognized encoding parameter... %s, please use" - " `text`, `base64` or `hex`" % option.encoding) + print(("unrecognized encoding parameter... %s, please use" + " `text`, `base64` or `hex`" % option.encoding)) sys.exit(1) args[0] = os.path.abspath(args[0]) @@ -110,7 +111,7 @@ if __name__ == '__main__': try: getfattr(args[0], option) except KeyError as err: - print ("Invalid key %s" % err) + print(("Invalid key %s" % err)) sys.exit(1) except IOError as err: print (err) diff --git a/tests/utils/gfid-access.py b/tests/utils/gfid-access.py index 4ca1665fec..2a58bfebc4 100755 --- a/tests/utils/gfid-access.py +++ b/tests/utils/gfid-access.py @@ -9,6 +9,7 @@ # cases as published by the Free Software Foundation. # +from __future__ import print_function import os import sys import stat @@ -53,8 +54,8 @@ def entry_pack_symlink(gf, bn, lnk, mo, uid, gid): if __name__ == '__main__': if len(sys.argv) < 9: - print("USAGE: %s <mount> <pargfid|ROOT> <filename> <GFID> <file type>" - " <uid> <gid> <file permission(octal str)>" % (sys.argv[0])) + print(("USAGE: %s <mount> <pargfid|ROOT> <filename> <GFID> <file type>" + " <uid> <gid> <file permission(octal str)>" % (sys.argv[0]))) sys.exit(-1) # nothing to do mtpt = sys.argv[1] pargfid = sys.argv[2] @@ -92,5 +93,5 @@ if __name__ == '__main__': if not ex.errno in [EEXIST]: raise sys.exit(-1) - print "File creation OK" + print("File creation OK") sys.exit(0) diff --git a/tests/utils/pidof.py b/tests/utils/pidof.py index 01f2f0ad5b..9f4a6a48a3 100755 --- a/tests/utils/pidof.py +++ b/tests/utils/pidof.py @@ -1,5 +1,6 @@ #!/usr/bin/python2 +from __future__ import print_function import sys try: @@ -21,14 +22,14 @@ def pidof(processname): continue if "gluster" in processname: if processname == "glusterd" and pmap_find(p, "glusterd"): - print (p.pid) + print((p.pid)) if processname == "glusterfs" and pmap_find(p, "client"): - print (p.pid) + print((p.pid)) if processname == "glusterfsd" and pmap_find(p, "posix-acl"): - print (p.pid) + print((p.pid)) continue if processname.strip() == p.name(): - print (p.pid) + print((p.pid)) def main(argv): if len(argv) < 2: @@ -37,7 +38,7 @@ def main(argv): try: pidof(argv[1]) except Exception as err: - print err + print(err) sys.stderr.write("Please be root - %s\n" % err); sys.exit(1) |