| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # | 2 # |
| 3 # Copyright 2007 Google Inc. | 3 # Copyright 2007 Google Inc. |
| 4 # | 4 # |
| 5 # Licensed under the Apache License, Version 2.0 (the "License"); | 5 # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 # you may not use this file except in compliance with the License. | 6 # you may not use this file except in compliance with the License. |
| 7 # You may obtain a copy of the License at | 7 # You may obtain a copy of the License at |
| 8 # | 8 # |
| 9 # http://www.apache.org/licenses/LICENSE-2.0 | 9 # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 # | 10 # |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 req = self._CreateRequest(url=url, data=payload) | 395 req = self._CreateRequest(url=url, data=payload) |
| 396 req.add_header("Content-Type", content_type) | 396 req.add_header("Content-Type", content_type) |
| 397 if extra_headers: | 397 if extra_headers: |
| 398 for header, value in extra_headers.items(): | 398 for header, value in extra_headers.items(): |
| 399 req.add_header(header, value) | 399 req.add_header(header, value) |
| 400 try: | 400 try: |
| 401 f = self.opener.open(req) | 401 f = self.opener.open(req) |
| 402 response = f.read() | 402 response = f.read() |
| 403 f.close() | 403 f.close() |
| 404 return response | 404 return response |
| 405 except urllib2.URLError, e: |
| 406 reason = e.reason |
| 407 if isinstance(reason, str) and reason.find("110") != -1: |
| 408 # Connection timeout error. |
| 409 if tries <= 3: |
| 410 # Try again. |
| 411 continue |
| 412 raise |
| 405 except urllib2.HTTPError, e: | 413 except urllib2.HTTPError, e: |
| 406 if tries > 3: | 414 if tries > 3: |
| 407 raise | 415 raise |
| 408 elif e.code == 401 or e.code == 302: | 416 elif e.code == 401 or e.code == 302: |
| 409 url_loc = urlparse.urlparse(url) | 417 url_loc = urlparse.urlparse(url) |
| 410 self._Authenticate('%s://%s' % (url_loc[0], url_loc[1])) | 418 self._Authenticate('%s://%s' % (url_loc[0], url_loc[1])) |
| 411 ## elif e.code >= 500 and e.code < 600: | 419 ## elif e.code >= 500 and e.code < 600: |
| 412 ## # Server Error - try again. | 420 ## # Server Error - try again. |
| 413 ## continue | 421 ## continue |
| 414 elif e.code == 301: | 422 elif e.code == 301: |
| (...skipping 1362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1777 try: | 1785 try: |
| 1778 RealMain(sys.argv) | 1786 RealMain(sys.argv) |
| 1779 except KeyboardInterrupt: | 1787 except KeyboardInterrupt: |
| 1780 print | 1788 print |
| 1781 StatusUpdate("Interrupted.") | 1789 StatusUpdate("Interrupted.") |
| 1782 sys.exit(1) | 1790 sys.exit(1) |
| 1783 | 1791 |
| 1784 | 1792 |
| 1785 if __name__ == "__main__": | 1793 if __name__ == "__main__": |
| 1786 main() | 1794 main() |
| OLD | NEW |