Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Side by Side Diff: third_party/upload.py

Issue 2431893002: Automatically map urls to their raw appengine forms (Closed)
Patch Set: Rebase Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « appengine_mapper.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 import re 48 import re
49 import socket 49 import socket
50 import subprocess 50 import subprocess
51 import sys 51 import sys
52 import urllib 52 import urllib
53 import urllib2 53 import urllib2
54 import urlparse 54 import urlparse
55 55
56 from multiprocessing.pool import ThreadPool 56 from multiprocessing.pool import ThreadPool
57 57
58 import appengine_mapper
59
58 # The configparser module was renamed in Python 3. 60 # The configparser module was renamed in Python 3.
59 try: 61 try:
60 import configparser 62 import configparser
61 except ImportError: 63 except ImportError:
62 import ConfigParser as configparser 64 import ConfigParser as configparser
63 65
64 # The md5 module was deprecated in Python 2.5. 66 # The md5 module was deprecated in Python 2.5.
65 try: 67 try:
66 from hashlib import md5 68 from hashlib import md5
67 except ImportError: 69 except ImportError:
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 438
437 old_timeout = socket.getdefaulttimeout() 439 old_timeout = socket.getdefaulttimeout()
438 socket.setdefaulttimeout(timeout) 440 socket.setdefaulttimeout(timeout)
439 auth_attempted = False 441 auth_attempted = False
440 try: 442 try:
441 tries = 0 443 tries = 0
442 while True: 444 while True:
443 tries += 1 445 tries += 1
444 args = dict(kwargs) 446 args = dict(kwargs)
445 url = "%s%s%s" % (self.host, self.request_path_prefix, request_path) 447 url = "%s%s%s" % (self.host, self.request_path_prefix, request_path)
448 url = appengine_mapper.MapUrl(url)
446 if args: 449 if args:
447 url += "?" + urllib.urlencode(args) 450 url += "?" + urllib.urlencode(args)
448 req = self._CreateRequest(url=url, data=payload) 451 req = self._CreateRequest(url=url, data=payload)
449 req.add_header("Content-Type", content_type) 452 req.add_header("Content-Type", content_type)
450 if extra_headers: 453 if extra_headers:
451 for header, value in extra_headers.items(): 454 for header, value in extra_headers.items():
452 req.add_header(header, value) 455 req.add_header(header, value)
453 try: 456 try:
454 f = self.opener.open(req, timeout=70) 457 f = self.opener.open(req, timeout=70)
455 response = f.read() 458 response = f.read()
(...skipping 2072 matching lines...) Expand 10 before | Expand all | Expand 10 after
2528 print 2531 print
2529 StatusUpdate("Interrupted.") 2532 StatusUpdate("Interrupted.")
2530 sys.exit(1) 2533 sys.exit(1)
2531 except auth.AuthenticationError as e: 2534 except auth.AuthenticationError as e:
2532 print(e, file=sys.stderr) 2535 print(e, file=sys.stderr)
2533 sys.exit(1) 2536 sys.exit(1)
2534 2537
2535 2538
2536 if __name__ == "__main__": 2539 if __name__ == "__main__":
2537 main() 2540 main()
OLDNEW
« no previous file with comments | « appengine_mapper.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698