diff options
author | Aravinda VK <avishwan@redhat.com> | 2016-03-21 16:57:48 +0530 |
---|---|---|
committer | Aravinda VK <avishwan@redhat.com> | 2016-03-30 06:37:18 -0700 |
commit | 48a0a38fadf9c5164869a908dcff8a951aa21b4b (patch) | |
tree | ecef52c1df7393390635163d7a0e771f76bb7839 /tools/glusterfind/src/main.py | |
parent | 7bbcd6fb692dffc628b723eace8cfcfa466e606f (diff) |
tools/glusterfind: Handling Unicode file names
Unicode filenames handled cleanly with this patch. Changelog
files and output files are opened with utf-8 encoding using codecs.open.
urllib.quote_plus and unquote_plus will not handle Unicode so, encode
Unicode to 8-bit string version before calling unquote. urllib.quote_plus
requires 8-bit string itself so do not decode to Unicode if we need to use
quote_plus(when --no-encode=false). Decode to unicode in --no-encode is set.
BUG: 1319717
Change-Id: If5561c749ab5529445650d322c831eb4da22b65a
Signed-off-by: Aravinda VK <avishwan@redhat.com>
Reviewed-on: http://review.gluster.org/13798
Smoke: Gluster Build System <jenkins@build.gluster.com>
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
CentOS-regression: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Milind Changire <mchangir@redhat.com>
Reviewed-by: Kotresh HR <khiremat@redhat.com>
Diffstat (limited to 'tools/glusterfind/src/main.py')
-rw-r--r-- | tools/glusterfind/src/main.py | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/tools/glusterfind/src/main.py b/tools/glusterfind/src/main.py index 86cfae090b5..9d2b9890b96 100644 --- a/tools/glusterfind/src/main.py +++ b/tools/glusterfind/src/main.py @@ -24,6 +24,7 @@ from utils import setup_logger, human_time, handle_rm_error from utils import get_changelog_rollover_time, cache_output, create_file import conf from changelogdata import OutputMerger +import codecs PROG_DESCRIPTION = """ GlusterFS Incremental API @@ -398,7 +399,7 @@ def enable_volume_options(args): def write_output(args, outfilemerger): - with open(args.outfile, "a") as f: + with codecs.open(args.outfile, "a", encoding="utf-8") as f: for row in outfilemerger.get(): # Multiple paths in case of Hardlinks paths = row[1].split(",") @@ -413,12 +414,9 @@ def write_output(args, outfilemerger): if p_rep == row_2_rep: continue - p_rep = p_rep.encode('utf8', 'replace') - row_2_rep = row_2_rep.encode('utf8', 'replace') - - f.write("{0} {1} {2}\n".format(row[0], - p_rep, - row_2_rep)) + f.write(u"{0} {1} {2}\n".format(row[0], + p_rep, + row_2_rep)) def mode_create(session_dir, args): |