[or-cvs] r20801: {projects} More cleanups, more verbose logging on failure (in projects/gettor: . gettor)
kaner at seul.org
kaner at seul.org
Sun Oct 18 11:32:44 UTC 2009
Author: kaner
Date: 2009-10-18 07:32:44 -0400 (Sun, 18 Oct 2009)
New Revision: 20801
Modified:
projects/gettor/GetTor.py
projects/gettor/gettor/responses.py
Log:
More cleanups, more verbose logging on failure
Modified: projects/gettor/GetTor.py
===================================================================
--- projects/gettor/GetTor.py 2009-10-18 11:13:18 UTC (rev 20800)
+++ projects/gettor/GetTor.py 2009-10-18 11:32:44 UTC (rev 20801)
@@ -43,11 +43,14 @@
# Ok, information aquired. Initiate reply sequence
try:
reply = gettor.responses.Response(conf, replyTo, lang, pack, split, sig)
+ except:
+ log.error("Parsing the request failed.")
+ log.error("Here is the exception I saw: %s" % sys.exc_info()[0])
+ try:
reply.sendReply()
except:
- log.error("Sending the reply failed. See previous errors for reasons.")
- # XXX Error handling???
- raise
+ log.error("Sending the reply failed.")
+ log.error("Here is the exception I saw: %s" % sys.exc_info()[0])
def processOptions(options, conf):
"""Do everything that's not part of parsing a mail. Prepare GetTor usage,
Modified: projects/gettor/gettor/responses.py
===================================================================
--- projects/gettor/gettor/responses.py 2009-10-18 11:13:18 UTC (rev 20800)
+++ projects/gettor/gettor/responses.py 2009-10-18 11:32:44 UTC (rev 20801)
@@ -124,32 +124,13 @@
def sendDelayAlert(self):
""" Send a delay notification """
log.info("Sending delay alert to %s" % self.replyTo)
- message = gettor.constants.delayalertmsg
- help = self.constructMessage(message, "")
- try:
- status = self.sendMessage(help)
- except:
- status = False
- log.error("Could not send delay alert message to user")
-
- log.info("Send status: %s" % status)
- return status
-
+ return self.sendGenericMessage(gettor.constants.delayalertmsg)
def sendHelp(self):
""" Send a helpful message to the user interacting with us """
log.info("Sending out help message to %s" % self.replyTo)
- message = gettor.constants.helpmsg
- help = self.constructMessage(message, "")
- try:
- status = self.sendMessage(help)
- except:
- log.error("Could not send help message to user")
- status = False
+ return self.sendGenericMessage(gettor.constants.helpmsg)
- log.info("Send status: %s" % status)
- return status
-
## XXX the following line was used below to automatically list the names
## of available packages. But they were being named in an arbitrary
## order, which caused people to always pick the first one. I listed
@@ -160,27 +141,20 @@
def sendPackageHelp(self):
""" Send a helpful message to the user interacting with us """
log.info("Sending package help to %s" % self.replyTo)
- message = gettor.constants.packagehelpmsg
- help = self.constructMessage(message, "")
+ return self.sendGenericMessage(gettor.constants.packagehelpmsg)
+
+ def sendGenericMessage(self, text):
+ """ Send a message of some sort """
+ message = self.constructMessage(text, "")
try:
- status = self.sendMessage(help)
+ status = self.sendMessage(message)
except:
+ log.error("Could not send message to user %s" % self.replyTo)
status = False
- log.error("Could not send package help message to user")
log.info("Send status: %s" % status)
return status
- def sendGenericMessage(self, message):
- """ Send a helpful message of some sort """
- help = self.constructMessage(message, "")
- try:
- status = self.sendMessage(help)
- except:
- log.error("Could not send generic help message to user")
- status = False
- return status
-
def constructMessage(self, messageText, subj, fileName=None):
""" Construct a multi-part mime message, including only the first part
with plaintext."""
More information about the tor-commits
mailing list