From 622ac19fa32cce9fc872cdf6180e7dee8ac5a26e Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Fri, 4 Mar 2016 17:25:29 +0100 Subject: [PATCH] locally executed commands need to set universal_newlines too in py3 --- nepi/util/execfuncs.py | 16 +++++++++++----- nepi/util/sshfuncs.py | 16 ++++++++-------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/nepi/util/execfuncs.py b/nepi/util/execfuncs.py index a78ef399..a8591f82 100644 --- a/nepi/util/execfuncs.py +++ b/nepi/util/execfuncs.py @@ -22,6 +22,8 @@ import logging import shlex import subprocess +from six import PY2 + def lexec(command, user = None, sudo = False, @@ -42,10 +44,12 @@ def lexec(command, #elif user: # command = "su %s ; %s " % (user, command) + extras = {} if PY2 else {'universal_newlines' : True} proc = subprocess.Popen(command, - shell = True, - stdout = subprocess.PIPE, - stderr = subprocess.PIPE) + shell = True, + stdout = subprocess.PIPE, + stderr = subprocess.PIPE, + **extras) out = err = "" log_msg = "lexec - command %s " % command @@ -78,9 +82,11 @@ def lcopy(source, dest, recursive = False): else: args.append(dest) + extras = {} if PY2 else {'universal_newlines' : True} proc = subprocess.Popen(args, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE) + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + **extras) out = err = "" command = " ".join(args) diff --git a/nepi/util/sshfuncs.py b/nepi/util/sshfuncs.py index 1236ed56..7e22b5c8 100644 --- a/nepi/util/sshfuncs.py +++ b/nepi/util/sshfuncs.py @@ -323,14 +323,14 @@ def rexec(command, host, user, blocking = blocking) def rcopy(source, dest, - port = None, - gwuser = None, - gw = None, - recursive = False, - identity = None, - server_key = None, - retry = 3, - strict_host_checking = True): + port = None, + gwuser = None, + gw = None, + recursive = False, + identity = None, + server_key = None, + retry = 3, + strict_host_checking = True): """ Copies from/to remote sites. -- 2.43.0