summaryrefslogtreecommitdiffstats
path: root/geo-replication/syncdaemon/resource.py
diff options
context:
space:
mode:
authorKotresh HR <khiremat@redhat.com>2018-09-24 21:18:30 +0530
committerShyamsundar Ranganathan <srangana@redhat.com>2018-10-05 14:22:54 +0000
commit1330456911f4e0606d9ebd103151917a160e2623 (patch)
tree0ac73ea6d0b263a0dcec91b3039ad5cda066377b /geo-replication/syncdaemon/resource.py
parent3acb6955594402835dea8e309f202a9fc9e38ae0 (diff)
georep: python3 compatibility (Popen)
The file objects for python3 by default is opened in binary mode where as in python2 it's opened as text by default. The geo-rep code parses the output of Popen assuming it as text, hence used the 'universal_newlines' flag which provides backward compatibility for the same. Change-Id: I371a03b6348af9666164cb2e8b93d47475431ad9 Updates: #411 Signed-off-by: Kotresh HR <khiremat@redhat.com> (cherry picked from commit 65aed1070cc2e44959cf3a0fbfde635de7e03103)
Diffstat (limited to 'geo-replication/syncdaemon/resource.py')
-rw-r--r--geo-replication/syncdaemon/resource.py19
1 files changed, 12 insertions, 7 deletions
diff --git a/geo-replication/syncdaemon/resource.py b/geo-replication/syncdaemon/resource.py
index 0c1b9818d2f..a0edeb7d56b 100644
--- a/geo-replication/syncdaemon/resource.py
+++ b/geo-replication/syncdaemon/resource.py
@@ -834,7 +834,8 @@ class Mounter(object):
def umount_l(self, d):
"""perform lazy umount"""
- po = Popen(self.make_umount_argv(d), stderr=subprocess.PIPE)
+ po = Popen(self.make_umount_argv(d), stderr=subprocess.PIPE,
+ universal_newlines=True)
po.wait()
return po
@@ -956,7 +957,7 @@ class DirectMounter(Mounter):
"""mounter backend which calls mount(8), umount(8) directly"""
- mountkw = {'stderr': subprocess.PIPE}
+ mountkw = {'stderr': subprocess.PIPE, 'universal_newlines': True}
glusterprog = 'glusterfs'
@staticmethod
@@ -979,7 +980,8 @@ class MountbrokerMounter(Mounter):
"""mounter backend using the mountbroker gluster service"""
- mountkw = {'stderr': subprocess.PIPE, 'stdout': subprocess.PIPE}
+ mountkw = {'stderr': subprocess.PIPE, 'stdout': subprocess.PIPE,
+ 'universal_newlines': True}
glusterprog = 'gluster'
@classmethod
@@ -1481,9 +1483,10 @@ class SSH(object):
# Else rsync will write to stdout and nobody is their
# to consume. If PIPE is full rsync hangs.
po = Popen(argv, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
- stderr=subprocess.PIPE)
+ stderr=subprocess.PIPE, universal_newlines=True)
else:
- po = Popen(argv, stdin=subprocess.PIPE, stderr=subprocess.PIPE)
+ po = Popen(argv, stdin=subprocess.PIPE, stderr=subprocess.PIPE,
+ universal_newlines=True)
for f in files:
po.stdin.write(f)
@@ -1532,8 +1535,10 @@ class SSH(object):
[host, "tar"] + \
["--overwrite", "-xf", "-", "-C", rdir]
p0 = Popen(tar_cmd, stdout=subprocess.PIPE,
- stdin=subprocess.PIPE, stderr=subprocess.PIPE)
- p1 = Popen(ssh_cmd, stdin=p0.stdout, stderr=subprocess.PIPE)
+ stdin=subprocess.PIPE, stderr=subprocess.PIPE,
+ universal_newlines=True)
+ p1 = Popen(ssh_cmd, stdin=p0.stdout, stderr=subprocess.PIPE,
+ universal_newlines=True)
for f in files:
p0.stdin.write(f)
p0.stdin.write('\n')