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 subprocess
|
||||||
import io
|
import io
|
||||||
import re
|
import re
|
||||||
|
import logging
|
||||||
# from wol import *
|
# from wol import *
|
||||||
# import os
|
# import os
|
||||||
# import signal
|
# 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)
|
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)
|
: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 getHostName() == target_machine_fqdn.split('.')[0]:
|
||||||
if user is not None:
|
if user is not None:
|
||||||
# su -c "ls -l /tmp" graffy
|
# su -c "ls -l /tmp" graffy
|
||||||
return executeCommand("su -c '%s' %s" % (command, user))
|
result = executeCommand("su -c '%s' %s" % (command, user))
|
||||||
else:
|
else:
|
||||||
return executeCommand(command)
|
result = executeCommand(command)
|
||||||
else:
|
else:
|
||||||
if user is not None:
|
if user is not None:
|
||||||
target = '%s@%s' % (user, target_machine_fqdn)
|
target = '%s@%s' % (user, target_machine_fqdn)
|
||||||
else:
|
else:
|
||||||
target = target_machine_fqdn
|
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():
|
def getUpsStatus():
|
||||||
|
|
Loading…
Reference in New Issue