changeset 65:4e41e1084e56

better exception handling, i hope; i hate lost messages
author Jeff Hammel <jhammel@mozilla.com>
date Tue, 13 Apr 2010 13:59:43 -0700
parents 292aeb1741f3
children 0f25fe665367 894a2e76bd40
files bitsyblog/blogme.py
diffstat 1 files changed, 5 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/bitsyblog/blogme.py
+++ b/bitsyblog/blogme.py
@@ -134,14 +134,16 @@ def main(args=sys.argv[1:]):
     opener = urllib2.build_opener(authhandler)
     urllib2.install_opener(opener)
     attempts = 5
     for i in range(attempts):
         try:
             connection = urllib2.urlopen(url, data=msg)
             print connection.url # print the blog post's url
             break
-        except urllib2.HTTPError, e:
-            import pdb; pdb.set_trace()
-            print e
+        except (urllib2.HTTPError, urllib2.URLError), e:
+            continue
+    else:
+        print >> sys.stderr, e
+        print msg
 
 if __name__ == '__main__':
     main()