Showing posts with label python-gdata. Show all posts
Showing posts with label python-gdata. Show all posts

Thursday, February 2, 2012

GoogleCL Docs Upload Fixed for Gdata 2.0.15 and 2.0.16

Months ago, we fixed Google Docs Uploads for GoogleCL folks who use python-gdata 2.0.12 through 2.0.14. Today, we tackled the problem for users of python-gdata 2.0.15 and 2.0.16.

A user sent in a patch that fixed the MIMETYPES error we were getting with 2.0.15 and 2.0.16. It looks like python-gdata moved away from declaring MIMETYPES where we were calling them from, so now we name them explicitly in googlecl/src/googlecl/docs/client.py.

That was a great start, but then we started getting a DocsEntry error and uploads still wouldn't work, so we delved further. Here's the error we got after fixing the MIMETYPES problem.
AttributeError: 'module' object has no attribute 'DocsEntry'

One of our earlier searches brought us to the same error posted on python-gdata's buglist.

Then, we found this blog post, by Demon Lord, where they had success replacing the string "gdata.docs.data.DocsEntry" with the string "gdata.data.GDEntry". We tried that throughout the file googlecl/src/googlecl/docs/client.py and sure enough, that fixed it!

We tested 2.0.0 through 2.0.4 to make sure that didn't break anything for those users and then tested 2.0.12 through 2.0.16 to make sure it worked on all the versions that should be able to upload docs. It does so it's now been committed.

Sunday, November 20, 2011

Python Gdata

Short version: To upload Google Docs with a service that utilizes python-gdata, use a version between 2.0.12 and 2.0.14. Keep reading for more details.

Credentiality and I spent a few hours on this tonight. Here's a brief history and a beautiful table to show you what to expect.

An SSL error occurs in a few platforms using gdata when you try to upload files to Google Docs and it doesn't appear to be limited to python-gdata. It may relate to this. Credentiality and I work on  GoogleCL sometimes, so we have all the python-gdata versions from 2.0.0 through 2.0.15 and test code with all of them, anyway. Here are some observations and what has worked for us so far.

In May 2, 2011, Google began to allow uploading "all file types" for non-premium users. Now, if you add a resumable uploader fix to a specific GoogleCL client.py file* and you use python-gdata 2.0.10 or 2.0.12 through 2.0.14, GoogleCL should upload a PDF to Google Docs successfully.

Without the resumable uploader fix, python-gdata 2.0.10 or 2.0.12 through 2.0.14 gives us this 403 error:
403, <errors xmlns='http://schemas.google.com/g/2005'><error><domain>GData</domain><code>ServiceForbiddenException</code><internalReason>Files must be uploaded using the resumable upload mechanism.</internalReason></error></errors>

When we use python-gdata 2.0.5 through 2.0.9 or 2.0.11, we get this 403.4 SSL error:
403, <errors xmlns='http://schemas.google.com/g/2005'><error><domain>GData</domain><code>ServiceForbiddenException</code><internalReason>403.4 SSL required</internalReason></error></errors>

The python-gdata versions before 2.0.5 can't upload PDFs to Google Docs, anyway. We get the following error for those:
{'status': 415, 'body': 'Content-Type application/pdf is not a valid input type.', 'reason': 'Unsupported Media Type'}

python-gdata 2.0.15 doesn't work with GoogleCL to upload to Google Docs, either. Currently, we get this error, which seems to be a GoogleCL error related to some change in gdata from 2.0.14 to 2.0.15:

from gdata.docs.data import MIMETYPES
ImportError: cannot import name MIMETYPES





*In the directory: googlecl/src/googlecl/docs/ .