From 654e449007cd0e1b571ac807cffe04c7354d2d7f Mon Sep 17 00:00:00 2001 From: Guillaume Raffy Date: Tue, 23 May 2023 11:43:29 +0200 Subject: [PATCH] added logging mechanism to ease debugging work related to Bug 3315 - make simpaweb django app a packageable application --- cocluto/Util.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) 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():