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

Side by Side Diff: chrome/common/extensions/docs/server2/urlfetch.py

Issue 10387225: Die build.py, Die: Part 1 (BranchUtility and SubversionFetcher) (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Final changes Created 8 years, 7 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 | « chrome/common/extensions/docs/server2/test_urlfetch.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
(Empty)
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 import logging
6
7 from google.appengine.api import urlfetch
8 from google.appengine.api import memcache
9
10 DEFAULT_CACHE_TIME = 300
11
12 class _FetchException(Exception):
13 """Thrown when status code is not 200.
14 """
15 def __init__(self, url):
16 Exception.__init__(self, 'Fetch exception from ' + url)
17
18 def fetch(url):
19 result = memcache.get(url, namespace=__name__)
20 if result is not None:
21 return result
22 logging.info('Fetch cache miss: ' + url)
23
24 result = urlfetch.fetch(url)
25
26 if result.status_code != 200:
27 raise _FetchException(url)
28
29 memcache.add(url, result, DEFAULT_CACHE_TIME, namespace=__name__)
30 return result
OLDNEW
« no previous file with comments | « chrome/common/extensions/docs/server2/test_urlfetch.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698