diff --git a/cocluto/Util.py b/cocluto/Util.py index 037872f..5edf720 100644 --- a/cocluto/Util.py +++ b/cocluto/Util.py @@ -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():