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

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: Resource fetcher 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
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 memcache import MemcacheAdd, MemcacheGet
Aaron Boodman 2012/05/24 06:10:23 memcache will need to be dependency injected at so
9
10 class FetchException(Exception):
Aaron Boodman 2012/05/24 06:10:23 Prefix with _.
cduvall 2012/05/25 20:02:23 Done.
11 """Thrown when status code is not 200.
12 """
13 def __init__(self, url):
14 Exception.__init__(self, 'Fetch exception from ' + url)
15
16 def fetch(url):
17 result = MemcacheGet(url, 'urls')
Aaron Boodman 2012/05/24 06:10:23 Is there a way in python to get introspect a modul
cduvall 2012/05/25 20:02:23 Done.
18 if result is not None:
19 return result
20 logging.info('Fetch cache miss: ' + url)
21
22 result = urlfetch.fetch(url)
23
24 if result.status_code != 200:
25 raise FetchException(url)
26
27 MemcacheAdd(url, result, 'urls')
28 return result
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698