我正在尝试从远程 api shell 写入云存储中的文件,并看到以下内容:
s~appid> FILENAME = '/gs/test_bucket/test'
s~appid> writable_file = files.gs.create(FILENAME,
mime_type='application/octet-stream', acl='project-private')
s~appid> with files.open(writable_file, 'a') as f:
... f.write('[]')
...
---------------------------------------------------------------------------
FileNotOpenedError Traceback (most recent call last)
/Users/dhruvkaranmehta/Projects/getaround3/tools/g3/shell.pyc in <module>()
1 with files.open(writable_file, 'a') as f:
----> 2 f.write('[]')
3
/usr/local/google_appengine/google/appengine/api/files/file.pyc in
__exit__(self, atype, value, traceback)
288
289 def __exit__(self, atype, value, traceback):
--> 290 self.close()
291
292 def write(self, data, sequence_key=None):
/usr/local/google_appengine/google/appengine/api/files/file.pyc in
close(self, finalize)
282 request.set_filename(self._filename)
283 request.set_finalize(finalize)
--> 284 self._make_rpc_call_with_retry('Close', request, response)
285
286 def __enter__(self):
/usr/local/google_appengine/google/appengine/api/files/file.pyc in
_make_rpc_call_with_retry(self, method, request, response)
395 def _make_rpc_call_with_retry(self, method, request, response):
396 try:
--> 397 _make_call(method, request, response)
398 except (ApiTemporaryUnavailableError,
FileTemporaryUnavailableError):
399
/usr/local/google_appengine/google/appengine/api/files/file.pyc in
_make_call(method, request, response, deadline)
243 rpc.check_success()
244 except apiproxy_errors.ApplicationError, e:
--> 245 _raise_app_error(e)
246
247
/usr/local/google_appengine/google/appengine/api/files/file.pyc in
_raise_app_error(e)
186 elif (e.application_error ==
187 file_service_pb.FileServiceErrors.FILE_NOT_OPENED):
--> 188 raise FileNotOpenedError()
189 elif (e.application_error ==
190 file_service_pb.FileServiceErrors.READ_ONLY):
FileNotOpenedError:
这看起来很奇怪,因为文件刚刚打开。我还看到了另一种情况,在“a”模式下打开文件会导致FinalizationError
.
任何其他信息都将非常有帮助。
谢谢!