summaryrefslogtreecommitdiffstats
path: root/tools/glusterfind/src/utils.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/utils.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/utils.py')
-rw-r--r--tools/glusterfind/src/utils.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/tools/glusterfind/src/utils.py b/tools/glusterfind/src/utils.py
index fdf61fe0f9e..b3b0bdfffa3 100644
--- a/tools/glusterfind/src/utils.py
+++ b/tools/glusterfind/src/utils.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.
@@ -228,14 +229,17 @@ def get_changelog_rollover_time(volumename):
return DEFAULT_CHANGELOG_INTERVAL
-def output_path_prepare(path, output_prefix):
+def output_path_prepare(path, args):
"""
If Prefix is set, joins to Path, removes ending slash
and encodes it.
"""
- if output_prefix != ".":
- path = os.path.join(output_prefix, path)
+ if args.output_prefix != ".":
+ path = os.path.join(args.output_prefix, path)
if path.endswith("/"):
path = path[0:len(path)-1]
- return urllib.quote_plus(path)
+ if args.no_encode:
+ return path
+ else:
+ return urllib.quote_plus(path)