From 8688acab659fc1fefb5435828e52a76a29b616b6 Mon Sep 17 00:00:00 2001 From: Cyril Jaquier Date: Mon, 1 Aug 2005 16:38:07 +0000 Subject: [PATCH] - Removed log4py dependency - Better handling of the return value of os.system() git-svn-id: https://fail2ban.svn.sourceforge.net/svnroot/fail2ban/branches/FAIL2BAN-0_5@163 a942ae1a-1317-0410-a47c-b1dcaea8d605 --- utils/process.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/utils/process.py b/utils/process.py index 4739303e..0b5a0983 100644 --- a/utils/process.py +++ b/utils/process.py @@ -24,10 +24,10 @@ __date__ = "$Date$" __copyright__ = "Copyright (c) 2004 Cyril Jaquier" __license__ = "GPL" -import os, log4py, signal +import os, logging, signal -# Gets the instance of log4py. -logSys = log4py.Logger().get_instance() +# Gets the instance of the logger. +logSys = logging.getLogger("fail2ban") def createDaemon(): """Detach a process from the controlling terminal and run it in the @@ -111,6 +111,7 @@ def checkForPID(lockfile): try: fileHandler = open(lockfile) pid = fileHandler.readline() + fileHandler.close() return pid except IOError: return False @@ -151,6 +152,9 @@ def executeCmd(cmd, debug): logSys.debug(cmd) if not debug: - return os.system(cmd) + retval = os.system(cmd) + if not retval == 0: + logSys.error("'" + cmd + "' returned " + `retval`) + return retval else: return None