From 3b8f715412c44090d1d279738a14cdc0e6c6dba7 Mon Sep 17 00:00:00 2001 From: jingqinghe Date: Mon, 14 Sep 2020 15:51:53 +0800 Subject: [PATCH] make hdfs utils compatible to python3 --- python/paddle/fluid/contrib/utils/hdfs_utils.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/python/paddle/fluid/contrib/utils/hdfs_utils.py b/python/paddle/fluid/contrib/utils/hdfs_utils.py index 2de4f82bd14..45fb01f9b4e 100644 --- a/python/paddle/fluid/contrib/utils/hdfs_utils.py +++ b/python/paddle/fluid/contrib/utils/hdfs_utils.py @@ -18,6 +18,7 @@ import sys import subprocess import multiprocessing from datetime import datetime +from functools import cmp_to_key import re import copy @@ -419,7 +420,7 @@ class HDFSClient(object): hdfs_path)) lines = [] regex = re.compile('\s+') - out_lines = output.strip().split("\n") + out_lines = output.strip().decode().split("\n") for line in out_lines: re_line = regex.split(line) if len(re_line) == 8: @@ -429,7 +430,7 @@ class HDFSClient(object): lines.append( (re_line[7], re_line[5] + " " + re_line[6])) if sort: - sorted(lines, cmp=sort_by_time) + sorted(lines, key=cmp_to_key(sort_by_time)) ret_lines = [ret[0] for ret in lines] return ret_lines -- GitLab