OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Native Client Authors. All rights reserved. | 2 # Copyright (c) 2012 The Native Client Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Provide Google Storage access. | 6 """Provide Google Storage access. |
7 | 7 |
8 Provide an high-level interface to Google Storage. | 8 Provide an high-level interface to Google Storage. |
9 Operations are provided to read/write whole files and to | 9 Operations are provided to read/write whole files and to |
10 read/write strings. This allows google storage to be treated | 10 read/write strings. This allows google storage to be treated |
11 more or less like a key+value data-store. | 11 more or less like a key+value data-store. |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 Data from storage, or None for failure. | 146 Data from storage, or None for failure. |
147 """ | 147 """ |
148 work_dir = tempfile.mkdtemp(prefix='gdstore', suffix='.tmp') | 148 work_dir = tempfile.mkdtemp(prefix='gdstore', suffix='.tmp') |
149 try: | 149 try: |
150 path = os.path.join(work_dir, 'data') | 150 path = os.path.join(work_dir, 'data') |
151 if self.GetFile(key, path) is not None: | 151 if self.GetFile(key, path) is not None: |
152 return file_tools.ReadFile(path) | 152 return file_tools.ReadFile(path) |
153 return None | 153 return None |
154 finally: | 154 finally: |
155 shutil.rmtree(work_dir) | 155 shutil.rmtree(work_dir) |
OLD | NEW |