summaryrefslogtreecommitdiffstats
path: root/tools/glusterfind/src/changelog.py
diff options
context:
space:
mode:
authorKotresh HR <khiremat@redhat.com>2020-01-10 16:48:14 +0530
committerKotresh HR <khiremat@redhat.com>2020-01-10 16:56:15 +0530
commit45894c39a4d05ed1f6a6f1bdbeafb5fe74ef29c3 (patch)
treefba794327dac678b862eb35d99be1951aaa5a7ce /tools/glusterfind/src/changelog.py
parent497d9f7d51443f4f463ca00f4fdddc42c6464e0f (diff)
glusterfind: Fix py2/py3 issues
1. In dictionary values(), returns list in py2 and not in py3. So explicitly convert it into list. 2. xattr module returns values in bytes. So explicitly convert them to str to work both with py2 and py3 fixes: bz#1789439 Change-Id: I27a639cda4f7a4ece9744a97c3d16e247906bd94 Signed-off-by: Kotresh HR <khiremat@redhat.com>
Diffstat (limited to 'tools/glusterfind/src/changelog.py')
-rw-r--r--tools/glusterfind/src/changelog.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/tools/glusterfind/src/changelog.py b/tools/glusterfind/src/changelog.py
index 6c1a8caf316..a5e9ea4288f 100644
--- a/tools/glusterfind/src/changelog.py
+++ b/tools/glusterfind/src/changelog.py
@@ -14,6 +14,7 @@ import sys
import time
import xattr
import logging
+from gfind_py2py3 import bytearray_to_str
from argparse import ArgumentParser, RawDescriptionHelpFormatter
import hashlib
try:
@@ -105,9 +106,10 @@ def populate_pgfid_and_inodegfid(brick, changelog_data):
changelog_data.inodegfid_add(os.stat(p).st_ino, gfid)
file_xattrs = xattr.list(p)
for x in file_xattrs:
- if x.startswith("trusted.pgfid."):
+ x_str = bytearray_to_str(x)
+ if x_str.startswith("trusted.pgfid."):
# PGFID in pgfid table
- changelog_data.pgfid_add(x.split(".")[-1])
+ changelog_data.pgfid_add(x_str.split(".")[-1])
except (IOError, OSError):
# All OS Errors ignored, since failures will be logged
# in End. All GFIDs present in gfidpath table
@@ -122,10 +124,12 @@ def enum_hard_links_using_gfid2path(brick, gfid, args):
try:
file_xattrs = xattr.list(p)
for x in file_xattrs:
- if x.startswith("trusted.gfid2path."):
+ x_str = bytearray_to_str(x)
+ if x_str.startswith("trusted.gfid2path."):
# get the value for the xattr i.e. <PGFID>/<BN>
- v = xattr.getxattr(p, x)
- pgfid, bn = v.split(os.sep)
+ v = xattr.getxattr(p, x_str)
+ v_str = bytearray_to_str(v)
+ pgfid, bn = v_str.split(os.sep)
try:
path = symlink_gfid_to_path(brick, pgfid)
fullpath = os.path.join(path, bn)