From: Thierry Parmentelat Date: Fri, 4 Mar 2016 16:25:29 +0000 (+0100) Subject: locally executed commands need to set universal_newlines too in py3 X-Git-Tag: nepi-6.0.7-pypi~1 X-Git-Url: http://git.onelab.eu/?p=nepi.git;a=commitdiff_plain;h=622ac19fa32cce9fc872cdf6180e7dee8ac5a26e;hp=6e57dab4b6116a7ec06d0f03a96f4cea98ced1c3 locally executed commands need to set universal_newlines too in py3 --- 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.