mirror of
https://github.com/Pardus-LiderAhenk/ahenk
synced 2024-11-22 09:42:15 +03:00
execute code remote machine feature added
This commit is contained in:
parent
6496b0e35e
commit
4301037dd2
1 changed files with 6 additions and 3 deletions
|
@ -132,10 +132,13 @@ class Util:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def execute(command, stdin=None, env=None, cwd=None, shell=True, result=True, as_user=None):
|
def execute(command, stdin=None, env=None, cwd=None, shell=True, result=True, as_user=None, ip=None):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if as_user is not None:
|
if ip:
|
||||||
|
command = 'ssh root@{0} "{1}"'.format(ip, command)
|
||||||
|
|
||||||
|
elif as_user:
|
||||||
command = 'su - {0} -c "{1}"'.format(as_user, command)
|
command = 'su - {0} -c "{1}"'.format(as_user, 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)
|
||||||
|
|
Loading…
Reference in a new issue