import shlex
import subprocess
+from six import PY2
+
def lexec(command,
user = None,
sudo = False,
#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
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)