Mercurial > hg > bitsyblog
comparison bitsyblog/blogme.py @ 61:04866e5abb5a
try a few times before giving up
author | k0s <k0scist@gmail.com> |
---|---|
date | Thu, 14 Jan 2010 13:06:46 -0500 |
parents | 66bfcceea3b4 |
children | 4e41e1084e56 |
comparison
equal
deleted
inserted
replaced
60:94dddb3a5d77 | 61:04866e5abb5a |
---|---|
131 url += '&privacy=secret' | 131 url += '&privacy=secret' |
132 authhandler = urllib2.HTTPDigestAuthHandler() | 132 authhandler = urllib2.HTTPDigestAuthHandler() |
133 authhandler.add_password('bitsyblog', url, options.user, options.password) | 133 authhandler.add_password('bitsyblog', url, options.user, options.password) |
134 opener = urllib2.build_opener(authhandler) | 134 opener = urllib2.build_opener(authhandler) |
135 urllib2.install_opener(opener) | 135 urllib2.install_opener(opener) |
136 try: | 136 attempts = 5 |
137 url = urllib2.urlopen(url, data=msg) | 137 for i in range(attempts): |
138 print url.url # print the blog post's url | 138 try: |
139 except urllib2.HTTPError, e: | 139 connection = urllib2.urlopen(url, data=msg) |
140 print e | 140 print connection.url # print the blog post's url |
141 break | |
142 except urllib2.HTTPError, e: | |
143 import pdb; pdb.set_trace() | |
144 print e | |
141 | 145 |
142 if __name__ == '__main__': | 146 if __name__ == '__main__': |
143 main() | 147 main() |