This is an automated email from the ASF dual-hosted git repository. echekanskiy pushed a commit to branch branch-2.6 in repository https://gitbox.apache.org/repos/asf/ambari.git
The following commit(s) were added to refs/heads/branch-2.6 by this push: new 68aa59f AMBARI-23135. Fix unicode_tolerant_fs.py (echekanskiy) 68aa59f is described below commit 68aa59f0fa734f3c0012990f11da48a814961021 Author: Eugene Chekanskiy <echekans...@hortonworks.com> AuthorDate: Sat Mar 3 01:13:37 2018 +0200 AMBARI-23135. Fix unicode_tolerant_fs.py (echekanskiy) --- .../src/main/python/ambari_commons/unicode_tolerant_fs.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/ambari-common/src/main/python/ambari_commons/unicode_tolerant_fs.py b/ambari-common/src/main/python/ambari_commons/unicode_tolerant_fs.py index a2b8e6b..ab95c60 100644 --- a/ambari-common/src/main/python/ambari_commons/unicode_tolerant_fs.py +++ b/ambari-common/src/main/python/ambari_commons/unicode_tolerant_fs.py @@ -19,6 +19,11 @@ Ambari Agent """ +def get_encoded_string(data): + try: + return data.encode("utf8") + except UnicodeDecodeError: + return data def unicode_walk(top, topdown=True, onerror=None, followlinks=False): """ @@ -31,7 +36,7 @@ def unicode_walk(top, topdown=True, onerror=None, followlinks=False): islink, join, isdir = os.path.islink, os.path.join, os.path.isdir - top = top.encode("utf8") + top = get_encoded_string(top) try: # Note that listdir and error are globals in this module due @@ -44,7 +49,7 @@ def unicode_walk(top, topdown=True, onerror=None, followlinks=False): dirs, nondirs = [], [] for name in names: - name = name.encode("utf8") + name = get_encoded_string(name) if isdir(join(top, name)): dirs.append(name) else: @@ -53,7 +58,7 @@ def unicode_walk(top, topdown=True, onerror=None, followlinks=False): if topdown: yield top, dirs, nondirs for name in dirs: - name = name.encode("utf8") + name = get_encoded_string(name) new_path = join(top, name) if followlinks or not islink(new_path): for x in unicode_walk(new_path, topdown, onerror, followlinks): -- To stop receiving notification emails like this one, please contact echekans...@apache.org.