ExistenceError from api.files.open()

45 views
Skip to first unread message

googlefox

unread,
Jun 27, 2012, 5:19:11 PM6/27/12
to google-a...@googlegroups.com
I am trying to replace a file that exists on Google storage.

This is the code I am using:

        write_path = files.gs.create(filename= _file_name,
                        acl
='public-read',
                        mime_type
=mime,
                        cache_control
='Expires=' + expiresDate.strftime(formatStr))

        logging
.debug('write_path = ' + write_path)

       
# Write to the file.
       
#http://code.google.com/p/googleappengine/source/browse/trunk/python/google/appengine/api/files/file.py#402
       
with files.open(write_path, 'a', exclusive_lock=True) as fp:
            fp
.write(imageBytes)

       
# Finalize the file so it is readable in Google Cloud Storage.
        files
.finalize(write_path)
 
I am getting the following exception:

Traceback (most recent call last):
  File \\"/base/data/home/apps/s~redacted/dev-v2.359923243624465743/processImageBatch.py\\", line 204, in handle_result
    self._store_zimages( bucketName, url, imageId, code, imageType, response.content)
  File \\"/base/data/home/apps/s~redacted/dev-v2.359923243624465743/processImage.py\\", line 136, in _store_zimages
    self.cloudfile_write( bucketName, imageId, self._get_short_photo_path( imageId, \'s\', \'a\', code = code,ext=urlext), imageBytes)
  File \\"/base/data/home/apps/s~redacted/dev-v2.359923243624465743/processImage.py\\", line 639, in cloudfile_write
    self.gfile_write ( bucketName, str(imageId), filePath,imageBytes,mime)
  File \\"/base/data/home/apps/s~redacted/dev-v2.359923243624465743/processImage.py\\", line 626, in gfile_write
    with files.open(write_path, \'a\', exclusive_lock=True) as fp:
  File \\"/base/python27_runtime/python27_lib/versions/1/google/appengine/api/files/file.py\\", line 496, in open
    exclusive_lock=exclusive_lock)
  File \\"/base/python27_runtime/python27_lib/versions/1/google/appengine/api/files/file.py\\", line 274, in __init__
    self._open()
  File \\"/base/python27_runtime/python27_lib/versions/1/google/appengine/api/files/file.py\\", line 421, in _open
    self._make_rpc_call_with_retry(\'Open\', request, response)
  File \\"/base/python27_runtime/python27_lib/versions/1/google/appengine/api/files/file.py\\", line 425, in _make_rpc_call_with_retry
    _make_call(method, request, response)
  File \\"/base/python27_runtime/python27_lib/versions/1/google/appengine/api/files/file.py\\", line 250, in _make_call
    _raise_app_error(e)
  File \\"/base/python27_runtime/python27_lib/versions/1/google/appengine/api/files/file.py\\", line 175, in _raise_app_error
    raise ExistenceError()
ExistenceError

--
This was not happening before. Has anything regressed?

Reply all
Reply to author
Forward
0 new messages