diff options
| author | Kotresh HR <khiremat@redhat.com> | 2018-09-24 21:18:30 +0530 | 
|---|---|---|
| committer | Amar Tumballi <amarts@redhat.com> | 2018-09-25 17:26:18 +0000 | 
| commit | 65aed1070cc2e44959cf3a0fbfde635de7e03103 (patch) | |
| tree | a9de71674500abbc06129bf8f4c54ba14c7551b7 /geo-replication/syncdaemon/syncdutils.py | |
| parent | 89636be4c73b12de2e11c75d8e59527bb243f147 (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>
Diffstat (limited to 'geo-replication/syncdaemon/syncdutils.py')
| -rw-r--r-- | geo-replication/syncdaemon/syncdutils.py | 11 | 
1 files changed, 7 insertions, 4 deletions
diff --git a/geo-replication/syncdaemon/syncdutils.py b/geo-replication/syncdaemon/syncdutils.py index b2b866f8817..27b548c9d52 100644 --- a/geo-replication/syncdaemon/syncdutils.py +++ b/geo-replication/syncdaemon/syncdutils.py @@ -261,7 +261,8 @@ def finalize(*args, **kwargs):              umount_cmd = rconf.mbr_umount_cmd + [rconf.mount_point, 'lazy']          else:              umount_cmd = ['umount', '-l', rconf.mount_point] -        p0 = subprocess.Popen(umount_cmd, stderr=subprocess.PIPE) +        p0 = subprocess.Popen(umount_cmd, stderr=subprocess.PIPE, +                              universal_newlines=True)          _, errdata = p0.communicate()          if p0.returncode == 0:              try: @@ -636,7 +637,8 @@ def unshare_propagation_supported():      unshare_mnt_propagation = False      p = subprocess.Popen(["unshare", "--help"],                           stderr=subprocess.PIPE, -                         stdout=subprocess.PIPE) +                         stdout=subprocess.PIPE, +                         universal_newlines=True)      out, err = p.communicate()      if p.returncode == 0:          if "propagation" in out: @@ -653,7 +655,8 @@ def get_rsync_version(rsync_cmd):      rsync_version = "0"      p = subprocess.Popen([rsync_cmd, "--version"],                           stderr=subprocess.PIPE, -                         stdout=subprocess.PIPE) +                         stdout=subprocess.PIPE, +                         universal_newlines=True)      out, err = p.communicate()      if p.returncode == 0:          rsync_version = out.split(" ", 4)[3] @@ -856,7 +859,7 @@ class Volinfo(object):      def __init__(self, vol, host='localhost', prelude=[]):          po = Popen(prelude + ['gluster', '--xml', '--remote-host=' + host,                                'volume', 'info', vol], -                   stdout=PIPE, stderr=PIPE) +                   stdout=PIPE, stderr=PIPE, universal_newlines=True)          vix = po.stdout.read()          po.wait()          po.terminate_geterr()  | 
