X-Git-Url: http://git.onelab.eu/?p=nepi.git;a=blobdiff_plain;f=nepi%2Futil%2Fexecfuncs.py;h=a8591f827bc6c4f4f0e3a6d2f9327bdde591499b;hp=a78ef3996fb0aa484764250ba4faadcd519903ce;hb=622ac19fa32cce9fc872cdf6180e7dee8ac5a26e;hpb=6e57dab4b6116a7ec06d0f03a96f4cea98ced1c3 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)