[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r19774: {projects} Added some more debug messages is sending packages goes wron (in projects/gettor: . gettor)



Author: kaner
Date: 2009-06-22 16:03:58 -0400 (Mon, 22 Jun 2009)
New Revision: 19774

Modified:
   projects/gettor/GetTor.py
   projects/gettor/TODO
   projects/gettor/gettor/packages.py
   projects/gettor/gettor/requests.py
   projects/gettor/gettor/responses.py
Log:
Added some more debug messages is sending packages goes wrong
Add more descriptive error message if main loop exits on error
Let's see if this brings us closer to resolving the sending bug


Modified: projects/gettor/GetTor.py
===================================================================
--- projects/gettor/GetTor.py	2009-06-22 03:00:23 UTC (rev 19773)
+++ projects/gettor/GetTor.py	2009-06-22 20:03:58 UTC (rev 19774)
@@ -369,7 +369,27 @@
 
 if __name__ == "__main__":
     if not main():
-        print >> sys.stderr, "Main loop exited with errors."
+        generalerror = """
+     An error occured while processing your request to GetTor.
+     Most likely this happened because we are too busy at the moment.
+
+     Please try again later, sorry for the inconvenience.
+
+     Best,
+     Your GetTor robot
+     """
+        # XXX This is a heavy cludge to prevent the mail user to see
+        # "Main loop exited with errors." when something bad happened.
+        # Instead, 'generalerror' is send back to the user. 
+        # If GetTor runs from the command line (indicator: args are present),
+        # we presume the "Main loop exited with errors." is more 
+        # appropriate. However, this should go soon and be replaced by real 
+        # error handling (and mail user informing)
+        #   -- kaner
+        if len(sys.argv) == 1:
+            print >> sys.stderr, generalerror
+        else:
+            print >> sys.stderr, "Main loop exited with errors."
         exit(1)
     else:
         exit(0)

Modified: projects/gettor/TODO
===================================================================
--- projects/gettor/TODO	2009-06-22 03:00:23 UTC (rev 19773)
+++ projects/gettor/TODO	2009-06-22 20:03:58 UTC (rev 19774)
@@ -14,6 +14,6 @@
     - Perhaps we want to email the admin of GetTor with the error?
     - Perhaps we want to respond to the user with a useful message?
 - Add torbutton (Mike, please sign torbutton and populate a proper .asc)
-- Update the README to fix the XXX issues
 - Fix rsync to follow symlinks properly. We want the data not a link to data.
 - Add a nice little note about the size of the files users may request
+- Strip HTML mails (!)

Modified: projects/gettor/gettor/packages.py
===================================================================
--- projects/gettor/gettor/packages.py	2009-06-22 03:00:23 UTC (rev 19773)
+++ projects/gettor/gettor/packages.py	2009-06-22 20:03:58 UTC (rev 19774)
@@ -94,6 +94,7 @@
         if len(self.packageList) > 0:
             return True
         else:
+            log.error(_("Failed at building packages"))
             return False
 
     def syncWithMirror(self):

Modified: projects/gettor/gettor/requests.py
===================================================================
--- projects/gettor/gettor/requests.py	2009-06-22 03:00:23 UTC (rev 19773)
+++ projects/gettor/gettor/requests.py	2009-06-22 20:03:58 UTC (rev 19774)
@@ -16,8 +16,12 @@
 import dkim
 import re
 
+import gettor.gtlog
+
 __all__ = ["requestMail"]
 
+log = gettor.gtlog.getLogger()
+
 class requestMail:
 
     defaultLang = "en"
@@ -55,6 +59,7 @@
                 match = re.match(package, line)    
                 if match: 
                     self.returnPackage = package
+                    log.info(_("User requested package %s") % self.returnPackage)
 
         self.replyLocale = None
         pattern = re.compile("^Lang:\s+(.*)$")
@@ -62,11 +67,13 @@
             match = pattern.match(line)
             if match:
                 self.replyLocale = match.group(1)
+                log.info(_("User requested locale %s") % self.replyLocale)
 
         for (key, lang) in self.supportedLangs.items():
             if self.replyLocale == key:
                 break
         else:
+            log.info(_("Requested language %s not supported. Falling back to %s") % (self.replyLocale, self.defaultLang))
             self.replyLocale = self.defaultLang
 
     def getRawMessage(self):

Modified: projects/gettor/gettor/responses.py
===================================================================
--- projects/gettor/gettor/responses.py	2009-06-22 03:00:23 UTC (rev 19773)
+++ projects/gettor/gettor/responses.py	2009-06-22 20:03:58 UTC (rev 19774)
@@ -18,8 +18,11 @@
 import base64
 import gettext
 
+import gettor.gtlog
+
 __all__ = ["gettorResponse"]
 
+log = gettor.gtlog.getLogger()
 
 class gettorResponse:
 
@@ -65,6 +68,7 @@
         try:
             status = self.sendMessage(help, source, destination)
         except:
+            log.error(_("Could not send help message to user"))
             status = False
         self.setLang(self.logLang)
 
@@ -92,6 +96,7 @@
             status = self.sendMessage(help, source, destination)
         except:
             status = False
+            log.error(_("Could not send package help message to user"))
         self.setLang(self.logLang)
 
         return status
@@ -103,6 +108,7 @@
         try:
             status = self.sendMessage(help, source, destination)
         except:
+            log.error(_("Could not send generic help message to user"))
             status = False
         self.setLang(self.logLang)
         return status
@@ -152,6 +158,7 @@
         try:
             status = self.sendMessage(package, source, destination)
         except:
+            log.error(_("Could not send package to user"))
             status = False
         self.setLang(self.mailLang)
 
@@ -190,7 +197,35 @@
             smtp.sendmail(src, dst, message.getvalue())
             smtp.quit()
             status = True
+        except smtplib.SMTPAuthenticationError:
+            log.error(_("SMTP authentication error"))
+            return False
+        except smtplib.SMTPHeloError:
+            log.error(_("SMTP HELO error"))
+            return False
+        except smtplib.SMTPConnectError:
+            log.error(_("SMTP connection error"))
+            return False
+        except smtplib.SMTPDataError:
+            log.error(_("SMTP data error"))
+            return False
+        except smtplib.SMTPRecipientsRefused:
+            log.error(_("SMTP refused to send to recipients"))
+            return False
+        except smtplib.SMTPSenderRefused:
+            log.error(_("SMTP sender address refused"))
+            return False
+        except smtplib.SMTPResponseException:
+            log.error(_("SMTP response exception received"))
+            return False
+        except smtplib.SMTPServerDisconnected:
+            log.error(_("SMTP server disconnect exception received"))
+            return False
+        except smtplib.SMTPException:
+            log.error(_("General SMTP error caught"))
+            return False
         except:
+            log.error(_("Unknown SMTP error while trying to send via local MTA"))
             return False
 
         return status