mirror of
https://github.com/Pardus-LiderAhenk/ahenk
synced 2024-11-14 06:12:19 +03:00
util.py: log execute command
This commit is contained in:
parent
cc01a2a59b
commit
bdec1d2880
1 changed files with 3 additions and 2 deletions
|
@ -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)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue