diff options
Diffstat (limited to 'main.py')
-rwxr-xr-x | main.py | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -273,6 +273,15 @@ class _UserAgentHandler(urllib2.BaseHandler): | |||
273 | req.add_header('User-Agent', _UserAgent()) | 273 | req.add_header('User-Agent', _UserAgent()) |
274 | return req | 274 | return req |
275 | 275 | ||
276 | class _BasicAuthHandler(urllib2.HTTPBasicAuthHandler): | ||
277 | def http_error_auth_reqed(self, authreq, host, req, headers): | ||
278 | try: | ||
279 | return urllib2.AbstractBasicAuthHandler.http_error_auth_reqed( | ||
280 | self, authreq, host, req, headers) | ||
281 | except: | ||
282 | self.reset_retry_count() | ||
283 | raise | ||
284 | |||
276 | def init_http(): | 285 | def init_http(): |
277 | handlers = [_UserAgentHandler()] | 286 | handlers = [_UserAgentHandler()] |
278 | 287 | ||
@@ -287,7 +296,7 @@ def init_http(): | |||
287 | pass | 296 | pass |
288 | except IOError: | 297 | except IOError: |
289 | pass | 298 | pass |
290 | handlers.append(urllib2.HTTPBasicAuthHandler(mgr)) | 299 | handlers.append(_BasicAuthHandler(mgr)) |
291 | 300 | ||
292 | if 'http_proxy' in os.environ: | 301 | if 'http_proxy' in os.environ: |
293 | url = os.environ['http_proxy'] | 302 | url = os.environ['http_proxy'] |