diff options
author | Aravinda VK <avishwan@redhat.com> | 2016-02-19 17:08:56 +0530 |
---|---|---|
committer | Venky Shankar <vshankar@redhat.com> | 2016-02-26 02:11:08 -0800 |
commit | 1b897c39ba8c0f1bf180316637cc2d87e6920800 (patch) | |
tree | 78f974a872e202c831d63e275e7fccb6e2a3eda3 /tools/glusterfind/src/main.py | |
parent | bf2004bc1346890e69292c5177a5d8e002b696e2 (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: 1310080
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>
Diffstat (limited to 'tools/glusterfind/src/main.py')
-rw-r--r-- | tools/glusterfind/src/main.py | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/tools/glusterfind/src/main.py b/tools/glusterfind/src/main.py index 6d03cbed5f2..86cfae090b5 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. @@ -121,6 +122,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 []) @@ -140,6 +142,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 []) @@ -277,6 +280,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") @@ -400,12 +406,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): |