blob: e701cb557472d5a97109e57923eefeee178aec4a [file] [log] [blame]
# Copyright (c) 2013 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import cloudstorage
import logging
import traceback
import cache
def read(config_helper, file_name):
content = cache.get_content(file_name)
if content:
return content
# Sometimes remote calls fail for different reasons. Make sure we retry.
full_path = config_helper.get_full_path(file_name)
try:
with cloudstorage.open(full_path, 'r') as stream:
content = stream.read()
cache.set_content(file_name, content)
return content
except:
logging.error('Full path: %s' % full_path)
logging.error(traceback.format_exc())
return None