From: Aaron Swartz Date: Mon, 28 Jun 2004 12:00:00 +0000 (+0000) Subject: Add rss2email v2.51 X-Git-Tag: v2.51 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=969cbe9a10a930e061ee3f9eb26c9fce051f9da8;p=rss2email.git Add rss2email v2.51 Fix crash on 2.1, 2.2 feed timeout. Downloaded from: http://web.archive.org/web/20040825081604/http://www.aaronsw.com/2002/rss2email/rss2email-2.51.py --- diff --git a/rss2email.py b/rss2email.py index 0b93330..cddd7bf 100644 --- a/rss2email.py +++ b/rss2email.py @@ -10,7 +10,7 @@ Usage: list delete n """ -__version__ = "2.5" +__version__ = "2.51" __author__ = "Aaron Swartz (me@aaronsw.com)" __copyright__ = "(C) 2004 Aaron Swartz. GNU GPL 2." ___contributors__ = ["Dean Jackson (dino@grorg.org)", @@ -95,7 +95,10 @@ except: ### Import Modules ### -import cPickle as pickle, fcntl, md5, time, os, traceback, socket, urllib2, sys +import cPickle as pickle, fcntl, md5, time, os, traceback, urllib2, sys +import socket; socket_errors = [] +for e in ['error', 'gaierror']: + if hasattr(socket, e): socket_errors.append(getattr(socket, e)) if QP_REQUIRED: import mimify; from StringIO import StringIO as SIO if SMTP_SEND: import smtplib; smtpserver = smtplib.SMTP(SMTP_SERVER) else: smtpserver = None @@ -280,18 +283,23 @@ def run(num=None): if http_status != 304 and not r.entries and not r.get('version', ''): if http_status not in [200, 302]: print >>warn, "W: error", http_status, f.url + elif contains(http_headers.get('content-type', 'rss'), 'html'): print >>warn, "W: looks like HTML", f.url + elif http_headers.get('content-length', '1') == '0': print >>warn, "W: empty page", f.url - elif exc_type == socket.timeout: + + elif hasattr(socket, 'timeout') and exc_type == socket.timeout: print >>warn, "W: timed out on", f.url + elif exc_type == urllib2.URLError: - if r.bozo_exception.reason.__class__ is socket.gaierror: + if r.bozo_exception.reason.__class__ in socket_errors: exc_reason = r.bozo_exception.reason.args[1] else: exc_reason = r.bozo_exception.reason print >>warn, "W:", exc_reason, f.url + else: print >>warn, "=== SEND THE FOLLOWING TO rss2email@aaronsw.com ===" print >>warn, "E:", r.get("bozo_exception", "can't process"), f.url