added logging mechanism to ease debugging
work related to Bug 3315 - make simpaweb django app a packageable application
This commit is contained in:
parent
c387b9dce2
commit
654e449007
|
@ -2,6 +2,7 @@ import time
|
|||
import subprocess
|
||||
import io
|
||||
import re
|
||||
import logging
|
||||
# from wol import *
|
||||
# import os
|
||||
# import signal
|
||||
|
@ -72,20 +73,22 @@ def executeCommandOn(target_machine_fqdn, command, user=None):
|
|||
execute command on a local or remote machine (using ssh then)
|
||||
:param str user: if not None, the user that should be used to execute the command (instead of the current user)
|
||||
"""
|
||||
print("comparing %s and %s" % (getHostName(), target_machine_fqdn.split('.')[0]))
|
||||
logging.debug("executing %s on %s as %s" % (command, target_machine_fqdn, user))
|
||||
if getHostName() == target_machine_fqdn.split('.')[0]:
|
||||
if user is not None:
|
||||
# su -c "ls -l /tmp" graffy
|
||||
return executeCommand("su -c '%s' %s" % (command, user))
|
||||
result = executeCommand("su -c '%s' %s" % (command, user))
|
||||
else:
|
||||
return executeCommand(command)
|
||||
result = executeCommand(command)
|
||||
else:
|
||||
if user is not None:
|
||||
target = '%s@%s' % (user, target_machine_fqdn)
|
||||
else:
|
||||
target = target_machine_fqdn
|
||||
|
||||
return executeProgram(['ssh', target, "%s" % command])
|
||||
result = executeProgram(['ssh', target, "%s" % command])
|
||||
logging.debug("finished executing %s on %s as %s" % (command, target_machine_fqdn, user))
|
||||
return result
|
||||
|
||||
|
||||
def getUpsStatus():
|
||||
|
|
Loading…
Reference in New Issue