util.py: log execute command

This commit is contained in:
tncyclk 2017-08-27 09:45:05 +03:00
parent cc01a2a59b
commit bdec1d2880

View file

@ -12,6 +12,7 @@ import shutil
import stat import stat
import subprocess import subprocess
import uuid import uuid
from base.scope import Scope
class Util: class Util:
@ -137,9 +138,11 @@ class Util:
try: try:
if ip: if ip:
command = 'ssh root@{0} "{1}"'.format(ip, command) command = 'ssh root@{0} "{1}"'.format(ip, command)
Scope.get_instance().get_logger().debug('Executing command: ' +str(command))
elif as_user: elif as_user:
command = 'su - {0} -c "{1}"'.format(as_user, command) command = 'su - {0} -c "{1}"'.format(as_user, command)
Scope.get_instance().get_logger().debug('Executing command: ' +str(command))
process = subprocess.Popen(command, stdin=stdin, env=env, cwd=cwd, stderr=subprocess.PIPE, process = subprocess.Popen(command, stdin=stdin, env=env, cwd=cwd, stderr=subprocess.PIPE,
stdout=subprocess.PIPE, shell=shell) stdout=subprocess.PIPE, shell=shell)
@ -171,8 +174,6 @@ class Util:
command.append(script_path) command.append(script_path)
else: else:
raise Exception('[Util] Script is required') raise Exception('[Util] Script is required')
if parameters is not None:
for p in parameters: for p in parameters:
command.append(p) command.append(p)