From b38e0dfb1e5fd707792b9c85a3d3a5a8e643295f Mon Sep 17 00:00:00 2001 From: Cyril Jaquier Date: Sun, 10 Sep 2006 20:46:19 +0000 Subject: [PATCH] - Better output when server is not started git-svn-id: https://fail2ban.svn.sourceforge.net/svnroot/fail2ban/trunk@342 a942ae1a-1317-0410-a47c-b1dcaea8d605 --- fail2ban-client | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/fail2ban-client b/fail2ban-client index 746e8821..599804c0 100755 --- a/fail2ban-client +++ b/fail2ban-client @@ -25,7 +25,8 @@ __date__ = "$Date$" __copyright__ = "Copyright (c) 2004 Cyril Jaquier" __license__ = "GPL" -import sys, string, os, pickle, re, logging, getopt, time, readline, shlex +import sys, string, os, pickle, re, logging +import getopt, time, readline, shlex, socket # Inserts our own modules path first in the list # fix for bug #343821 @@ -132,20 +133,23 @@ class Fail2banClient: beautifier.setInputCmd(c) try: client = CSocket() + ret = client.send(c) + if ret[0] == 0: + logSys.debug("OK : " + `ret[1]`) + if showRet: + print beautifier.beautify(ret[1]) + else: + logSys.debug("NOK: " + `ret[1].args`) + print beautifier.beautifyError(ret[1]) + return False + except socket.error: + logSys.error("Unable to contact server. Is it running?") + return False except Exception, e: if showRet: logSys.error(e) logSys.error("Arrggh... Start the server first") return False - ret = client.send(c) - if ret[0] == 0: - logSys.debug("OK : " + `ret[1]`) - if showRet: - print beautifier.beautify(ret[1]) - else: - logSys.debug("NOK: " + `ret[1].args`) - print beautifier.beautifyError(ret[1]) - return False return True ## @@ -181,11 +185,6 @@ class Fail2banClient: else: logSys.error("Could not find server") return False - elif len(cmd) == 1 and cmd[0] == "stop": - # Workaround for the shutdown - ret = self.processCmd([cmd]) - self.ping() - return ret else: return self.processCmd([cmd])