locally executed commands need to set universal_newlines too in py3
authorThierry Parmentelat <thierry.parmentelat@inria.fr>
Fri, 4 Mar 2016 16:25:29 +0000 (17:25 +0100)
committerThierry Parmentelat <thierry.parmentelat@inria.fr>
Fri, 4 Mar 2016 16:25:29 +0000 (17:25 +0100)
nepi/util/execfuncs.py
nepi/util/sshfuncs.py

index a78ef39..a8591f8 100644 (file)
@@ -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)
index 1236ed5..7e22b5c 100644 (file)
@@ -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.