| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # coding: utf-8 | 2 # coding: utf-8 |
| 3 # | 3 # |
| 4 # Copyright 2007 Google Inc. | 4 # Copyright 2007 Google Inc. |
| 5 # | 5 # |
| 6 # Licensed under the Apache License, Version 2.0 (the "License"); | 6 # Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 # you may not use this file except in compliance with the License. | 7 # you may not use this file except in compliance with the License. |
| 8 # You may obtain a copy of the License at | 8 # You may obtain a copy of the License at |
| 9 # | 9 # |
| 10 # http://www.apache.org/licenses/LICENSE-2.0 | 10 # http://www.apache.org/licenses/LICENSE-2.0 |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 old_timeout = socket.getdefaulttimeout() | 445 old_timeout = socket.getdefaulttimeout() |
| 446 socket.setdefaulttimeout(timeout) | 446 socket.setdefaulttimeout(timeout) |
| 447 try: | 447 try: |
| 448 tries = 0 | 448 tries = 0 |
| 449 while True: | 449 while True: |
| 450 tries += 1 | 450 tries += 1 |
| 451 args = dict(kwargs) | 451 args = dict(kwargs) |
| 452 url = "%s%s" % (self.host, request_path) | 452 url = "%s%s" % (self.host, request_path) |
| 453 if args: | 453 if args: |
| 454 url += "?" + urllib.urlencode(args) | 454 url += "?" + urllib.urlencode(args) |
| 455 req = self._CreateRequest(url=url, data=payload) | 455 req = self._CreateRequest(url=url.encode("utf-8"), data=payload) |
| 456 req.add_header("Content-Type", content_type) | 456 req.add_header("Content-Type", content_type) |
| 457 if extra_headers: | 457 if extra_headers: |
| 458 for header, value in extra_headers.items(): | 458 for header, value in extra_headers.items(): |
| 459 req.add_header(header, value) | 459 req.add_header(header, value) |
| 460 try: | 460 try: |
| 461 f = self.opener.open(req) | 461 f = self.opener.open(req) |
| 462 response = f.read() | 462 response = f.read() |
| 463 f.close() | 463 f.close() |
| 464 return response | 464 return response |
| 465 except urllib2.HTTPError, e: | 465 except urllib2.HTTPError, e: |
| (...skipping 2186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2652 os.environ['LC_ALL'] = 'C' | 2652 os.environ['LC_ALL'] = 'C' |
| 2653 RealMain(sys.argv) | 2653 RealMain(sys.argv) |
| 2654 except KeyboardInterrupt: | 2654 except KeyboardInterrupt: |
| 2655 print | 2655 print |
| 2656 StatusUpdate("Interrupted.") | 2656 StatusUpdate("Interrupted.") |
| 2657 sys.exit(1) | 2657 sys.exit(1) |
| 2658 | 2658 |
| 2659 | 2659 |
| 2660 if __name__ == "__main__": | 2660 if __name__ == "__main__": |
| 2661 main() | 2661 main() |
| OLD | NEW |