From c6fcb017b840e46110f45ddb3c6aa93fe46ddea7 Mon Sep 17 00:00:00 2001 From: Yen Chi Hsuan Date: Tue, 9 May 2017 01:55:03 +0800 Subject: [PATCH] Use universal_newlines=True whereever the output is used (#4626) --- certbot/util.py | 3 ++- letshelp-certbot/letshelp_certbot/apache.py | 12 ++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/certbot/util.py b/certbot/util.py index 1cbef7e80..e343fdcb1 100644 --- a/certbot/util.py +++ b/certbot/util.py @@ -429,7 +429,8 @@ def get_python_os_info(): elif os_type.startswith('darwin'): os_ver = subprocess.Popen( ["sw_vers", "-productVersion"], - stdout=subprocess.PIPE + stdout=subprocess.PIPE, + universal_newlines=True, ).communicate()[0].rstrip('\n') elif os_type.startswith('freebsd'): # eg "9.3-RC3-p1" diff --git a/letshelp-certbot/letshelp_certbot/apache.py b/letshelp-certbot/letshelp_certbot/apache.py index 2391a30bb..b13057ca5 100755 --- a/letshelp-certbot/letshelp_certbot/apache.py +++ b/letshelp-certbot/letshelp_certbot/apache.py @@ -183,19 +183,22 @@ def setup_tempdir(args): config_fd.write(args.config_file + "\n") proc = subprocess.Popen([args.apache_ctl, "-v"], - stdout=subprocess.PIPE, stderr=subprocess.PIPE) + stdout=subprocess.PIPE, stderr=subprocess.PIPE, + universal_newlines=True) with open(os.path.join(tempdir, "version"), "w") as version_fd: version_fd.write(proc.communicate()[0]) proc = subprocess.Popen([args.apache_ctl, "-d", args.server_root, "-f", args.config_file, "-M"], - stdout=subprocess.PIPE, stderr=subprocess.PIPE) + stdout=subprocess.PIPE, stderr=subprocess.PIPE, + universal_newlines=True) with open(os.path.join(tempdir, "modules"), "w") as modules_fd: modules_fd.write(proc.communicate()[0]) proc = subprocess.Popen([args.apache_ctl, "-d", args.server_root, "-f", args.config_file, "-t", "-D", "DUMP_VHOSTS"], - stdout=subprocess.PIPE, stderr=subprocess.PIPE) + stdout=subprocess.PIPE, stderr=subprocess.PIPE, + universal_newlines=True) with open(os.path.join(tempdir, "vhosts"), "w") as vhosts_fd: vhosts_fd.write(proc.communicate()[0]) @@ -231,7 +234,8 @@ def locate_config(apache_ctl): """ try: proc = subprocess.Popen([apache_ctl, "-V"], - stdout=subprocess.PIPE, stderr=subprocess.PIPE) + stdout=subprocess.PIPE, stderr=subprocess.PIPE, + universal_newlines=True) output, _ = proc.communicate() except OSError: sys.exit(_NO_APACHECTL)