summaryrefslogtreecommitdiffstats
path: root/tools/glusterfind/src/main.py
diff options
context:
space:
mode:
authorAravinda VK <avishwan@redhat.com>2016-02-19 17:08:56 +0530
committerAravinda VK <avishwan@redhat.com>2016-03-08 01:58:57 -0800
commitf3b8a931b00cfd0ecee46599ed1ef1aaf236e148 (patch)
tree74f50f18ccf803708eaa4a7195e337c0d03334bc /tools/glusterfind/src/main.py
parent5a35bee2057b80809ecdd97abe5cce2d39b2da8a (diff)
tools/glusterfind: New option --no-encode
New option added to skip encoding path in output file. Also handled Unicode strings. File paths can have newline characters, to differentiate between each path patch is encoded according to RFC3986(https://www.ietf.org/rfc/rfc3986.txt). Due to this consumer applications have to decode the path before consuming it. With this option Paths are not encoded, can be directly consumed by applications. Unicode encoding is handled automatically BUG: 1313310 Change-Id: I83d59831997dbd1264b48e9b1aa732c7dfc700b5 Signed-off-by: Aravinda VK <avishwan@redhat.com> Reviewed-on: http://review.gluster.org/13477 Smoke: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Milind Changire <mchangir@redhat.com> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> Reviewed-by: Kotresh HR <khiremat@redhat.com> CentOS-regression: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Venky Shankar <vshankar@redhat.com> (cherry picked from commit 1b897c39ba8c0f1bf180316637cc2d87e6920800) Reviewed-on: http://review.gluster.org/13559
Diffstat (limited to 'tools/glusterfind/src/main.py')
-rw-r--r--tools/glusterfind/src/main.py19
1 files changed, 16 insertions, 3 deletions
diff --git a/tools/glusterfind/src/main.py b/tools/glusterfind/src/main.py
index 70f9ee9fe1d..72f11a7e02c 100644
--- a/tools/glusterfind/src/main.py
+++ b/tools/glusterfind/src/main.py
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+# -*- coding: utf-8 -*-
# Copyright (c) 2015 Red Hat, Inc. <http://www.redhat.com/>
# This file is part of GlusterFS.
@@ -117,6 +118,7 @@ def run_cmd_nodes(task, args, **kwargs):
"--output-prefix",
args.output_prefix] + \
(["--debug"] if args.debug else []) + \
+ (["--no-encode"] if args.no_encode else []) + \
(["--only-namespace-changes"] if args.only_namespace_changes
else [])
@@ -136,6 +138,7 @@ def run_cmd_nodes(task, args, **kwargs):
["--only-query"] + \
["--output-prefix", args.output_prefix] + \
(["--debug"] if args.debug else []) + \
+ (["--no-encode"] if args.no_encode else []) + \
(["--only-namespace-changes"]
if args.only_namespace_changes else [])
@@ -273,6 +276,9 @@ def _get_args():
parser_pre.add_argument("volume", help="Volume Name")
parser_pre.add_argument("outfile", help="Output File", action=StoreAbsPath)
parser_pre.add_argument("--debug", help="Debug", action="store_true")
+ parser_pre.add_argument("--no-encode",
+ help="Do not encode path in output file",
+ action="store_true")
parser_pre.add_argument("--full", help="Full find", action="store_true")
parser_pre.add_argument("--disable-partial", help="Disable Partial find, "
"Fail when one node fails", action="store_true")
@@ -396,12 +402,19 @@ def write_output(args, outfilemerger):
for p in paths:
if p == "":
continue
- p_rep = p.replace("%2F%2F", "%2F")
+ p_rep = p.replace("%2F%2F", "%2F").replace("//", "/")
if not row_2_rep:
- row_2_rep = row[2].replace("%2F%2F", "%2F")
+ row_2_rep = row[2].replace("%2F%2F", "%2F").replace("//",
+ "/")
if p_rep == row_2_rep:
continue
- f.write("%s %s %s\n" % (row[0], p_rep, row_2_rep))
+
+ 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))
def mode_create(session_dir, args):