changeset 61:04866e5abb5a

try a few times before giving up
author k0s <k0scist@gmail.com>
date Thu, 14 Jan 2010 13:06:46 -0500
parents 94dddb3a5d77
children 4038c2a052da
files bitsyblog/blogme.py
diffstat 1 files changed, 9 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/bitsyblog/blogme.py	Thu Jan 14 13:06:36 2010 -0500
+++ b/bitsyblog/blogme.py	Thu Jan 14 13:06:46 2010 -0500
@@ -133,11 +133,15 @@
     authhandler.add_password('bitsyblog', url, options.user, options.password)
     opener = urllib2.build_opener(authhandler)
     urllib2.install_opener(opener)
-    try:
-        url = urllib2.urlopen(url, data=msg)
-        print url.url # print the blog post's url
-    except urllib2.HTTPError, e:
-        print e
+    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
 
 if __name__ == '__main__':
     main()