gdata-2.0.14 で client.ResumableUploader.UpdateFile を呼び出すと socket.sslerror が出てしまう。
File "C:\Users\XXXXX\Documents\workspace\gdsync\src\gdsync.py", line 176, in UpdateNewRevisionDoc
updated_entry = ru.UpdateFile(entry_or_resumable_edit_link = e)
File "C:\Users\XXXXX\Documents\workspace\gdsync\src\gdata\client.py", line 1090, in update_file
auth_token=auth_token)
File "C:\Users\XXXXX\Documents\workspace\gdsync\src\gdata\client.py", line 1028, in upload_file
auth_token=auth_token, entry=entry)
File "C:\Users\XXXXX\Documents\workspace\gdsync\src\gdata\client.py", line 945, in _init_session
http_request=http_request)
File "C:\Users\XXXXX\Documents\workspace\gdsync\src\gdata\client.py", line 265, in request
uri=uri, auth_token=auth_token, http_request=http_request, **kwargs)
File "c:\python\Lib\site-packages\atom\client.py", line 117, in request
return self.http_client.request(http_request)
File "c:\python\Lib\site-packages\atom\http_core.py", line 420, in request
http_request.headers, http_request._body_parts)
File "c:\python\Lib\site-packages\atom\http_core.py", line 494, in _http_request
_send_data_part(part, connection)
File "c:\python\Lib\site-packages\atom\http_core.py", line 503, in _send_data_part
connection.send(data)
File "c:\python\lib\httplib.py", line 711, in send
self.sock.sendall(str)
File "c:\python\lib\httplib.py", line 1108, in send
return self._ssl.write(stuff)
socket.sslerror: (8, 'EOF occurred in violation of protocol')
client.py の 929 行目 ResumableUploader._init_session を修正する。
// 修正前
# Send empty POST if Atom XML wasn't specified.
if entry is None:
http_request.add_body_part('', self.content_type, size=0)
else:
http_request.add_body_part(str(entry), 'application/atom+xml',
size=len(str(entry)))
// 修正後
# Send empty POST if Atom XML wasn't specified.
if entry is None:
http_request.headers['Content-Length'] = '0'
http_request.add_body_part(None, self.content_type, size=0)
else:
http_request.add_body_part(str(entry), 'application/atom+xml',
size=len(str(entry)))
また ResumableUploader.UpdateFile を呼び出すとき、新しいリビジョンでアップロードするには URL に ?new-revision=true を追加する。
// 修正前(1079行目)
if isinstance(entry_or_resumable_edit_link, gdata.data.GDEntry):
resumable_edit_link = entry_or_resumable_edit_link.find_url(
'http://schemas.google.com/g/2005#resumable-edit-media')
customer_headers['If-Match'] = entry_or_resumable_edit_link.etag
else:
resumable_edit_link = entry_or_resumable_edit_link
// 修正後
if isinstance(entry_or_resumable_edit_link, gdata.data.GDEntry):
resumable_edit_link = entry_or_resumable_edit_link.find_url(
'http://schemas.google.com/g/2005#resumable-edit-media') + '?new-revision=true'
customer_headers['If-Match'] = entry_or_resumable_edit_link.etag
新しいリビジョンでアップロードすると、上書きはされず過去のバージョンも保持される。

0 コメント:
コメントを投稿