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

Side by Side Diff: gae/file_reader.py

Issue 1150463002: [chrome-devtools-frontend] Migrate to cloudstorage client (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/chrome-devtools-frontend
Patch Set: Created 5 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 | Annotate | Revision Log
« no previous file with comments | « gae/content_type.py ('k') | gae/pre_cacher.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 from google.appengine.api import files 5 import cloudstorage
6 import logging 6 import logging
7 import traceback 7 import traceback
8 8
9 import cache 9 import cache
10 10
11 def read(config_helper, file_name): 11 def read(config_helper, file_name):
12 content = cache.get_content(file_name) 12 content = cache.get_content(file_name)
13 if content: 13 if content:
14 return content 14 return content
15 # Sometimes remote calls fail for different reasons. Make sure we retry. 15 # Sometimes remote calls fail for different reasons. Make sure we retry.
16 full_path = config_helper.get_full_path(file_name) 16 full_path = config_helper.get_full_path(file_name)
17 for _ in [1, 2, 3]: 17 try:
18 try: 18 with cloudstorage.open(full_path, 'r') as stream:
19 with files.open(full_path, 'r') as stream: 19 content = stream.read()
20 content = stream.read() 20 cache.set_content(file_name, content)
21 cache.set_content(file_name, content) 21 return content
22 return content 22 except:
23 except: 23 logging.error('Full path: %s' % full_path)
24 logging.error('Full path: %s' % full_path) 24 logging.error(traceback.format_exc())
25 logging.error(traceback.format_exc())
26 return None 25 return None
OLDNEW
« no previous file with comments | « gae/content_type.py ('k') | gae/pre_cacher.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698