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/changelog.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/changelog.py')
-rw-r--r-- | tools/glusterfind/src/changelog.py | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/tools/glusterfind/src/changelog.py b/tools/glusterfind/src/changelog.py index d6f3dc188ac..a58a7ebebe3 100644 --- a/tools/glusterfind/src/changelog.py +++ b/tools/glusterfind/src/changelog.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. @@ -53,7 +54,7 @@ def pgfid_to_path(brick, changelog_data): try: path = symlink_gfid_to_path(brick, row[0]) - path = output_path_prepare(path, args.output_prefix) + path = output_path_prepare(path, args) changelog_data.gfidpath_set_path1(path, row[0]) except (IOError, OSError) as e: logger.warn("Error converting to path: %s" % e) @@ -69,7 +70,7 @@ def pgfid_to_path(brick, changelog_data): try: path = symlink_gfid_to_path(brick, row[0]) - path = output_path_prepare(path, args.output_prefix) + path = output_path_prepare(path, args) changelog_data.gfidpath_set_path2(path, row[0]) except (IOError, OSError) as e: logger.warn("Error converting to path: %s" % e) @@ -90,7 +91,7 @@ def populate_pgfid_and_inodegfid(brick, changelog_data): # It is a Directory if GFID backend path is symlink try: path = symlink_gfid_to_path(brick, gfid) - path = output_path_prepare(path, args.output_prefix) + path = output_path_prepare(path, args) changelog_data.gfidpath_update({"path1": path}, {"gfid": gfid}) except (IOError, OSError) as e: @@ -145,7 +146,7 @@ def gfid_to_path_using_pgfid(brick, changelog_data, args): path = path.strip() path = path[brick_path_len+1:] - path = output_path_prepare(path, args.output_prefix) + path = output_path_prepare(path, args) changelog_data.append_path1(path, inode) changelog_data.inodegfid_update({"converted": 1}, {"inode": inode}) @@ -193,7 +194,7 @@ def gfid_to_path_using_batchfind(brick, changelog_data): # Also updates converted flag in inodegfid table as 1 path = path.strip() path = path[brick_path_len+1:] - path = output_path_prepare(path, args.output_prefix) + path = output_path_prepare(path, args) changelog_data.append_path1(path, inode) @@ -230,7 +231,7 @@ def parse_changelog_to_db(changelog_data, filename, args): changelog_data.when_rename(changelogfile, data) elif data[0] == "E" and data[2] in ["UNLINK", "RMDIR"]: # UNLINK/RMDIR - changelog_data.when_unlink_rmdir(changelogfile, data, args) + changelog_data.when_unlink_rmdir(changelogfile, data) def get_changes(brick, hash_dir, log_file, start, end, args): @@ -260,7 +261,7 @@ def get_changes(brick, hash_dir, log_file, start, end, args): fail("%s Changelog register failed: %s" % (brick, e), logger=logger) # Output files to record GFIDs and GFID to Path failure GFIDs - changelog_data = ChangelogData(args.outfile) + changelog_data = ChangelogData(args.outfile, args) # Changelogs path(Hard coded to BRICK/.glusterfs/changelogs cl_path = os.path.join(brick, ".glusterfs/changelogs") @@ -354,6 +355,9 @@ def _get_args(): parser.add_argument("--only-query", help="Query mode only (no session)", action="store_true") parser.add_argument("--debug", help="Debug", action="store_true") + parser.add_argument("--no-encode", + help="Do not encode path in outfile", + action="store_true") parser.add_argument("--output-prefix", help="File prefix in output", default=".") parser.add_argument("-N", "--only-namespace-changes", |