Hi Jeffers,
On Dec 15, 2:28 am, Jeff S <
j...@google.com> wrote:
> Hi again Håvard,
>
> I've checked the photos modules into gdata-python-client and added a
> few short unit tests. Do you think you could try it out and confirm
> that I haven't missed anything? Thanks again for putting all of this
Good news.
I've taken a look and it seems you didn't get the latest changes.
__init__.py is fine, but the service.py file is not up to scratch.
Can you please apply this patch to it?
--------------8<---------------
--- service.py 2007-12-16 23:31:20.000000000 +0100
+++ /home/havard/dev/picasapush/picasaweb/service.py 2007-12-11
15:35:50.000000000 +0100
@@ -77,10 +77,10 @@
__author__ =
u'hav...@gulldahl.no'# (Håvard Gulldahl)' #BUG: pydoc
chokes on non-ascii chars in __author__
__license__ = 'Apache License v2'
-__version__ = '$Revision: 170 $'[11:-2]
+__version__ = '$Revision: 176 $'[11:-2]
@@ -567,24 +570,27 @@
os.path.exists(filename_or_handle): # it's a file name
photoblob = gdata.MediaSource()
photoblob.setFile(filename_or_handle, content_type)
- elif hasattr(filename_or_handle, 'read') \
- and hasattr(filename_or_handle, 'len'):
- file_handle = filename_or_handle # it's a file-like resource
- if hasattr(file_handle, 'seek'):
- file_handle.seek(0) # rewind pointer to the start of the file
- photoblob = gdata.MediaSource(file_handle, content_type,
- content_length=file_handle.len, file_name='image')
+ elif hasattr(filename_or_handle, 'read'):# it's a file-like
resource
+ if hasattr(filename_or_handle, 'seek'):
+ filename_or_handle.seek(0) # rewind pointer to the start of
the file
+ # gdata.MediaSource needs the content length, so read the whole
image
+ file_handle = StringIO.StringIO(filename_or_handle.read())
+ name = 'image'
+ if hasattr(filename_or_handle, 'name'):
+ name =
filename_or_handle.name
+ mediasource = gdata.MediaSource(file_handle, content_type,
+ content_length=file_handle.len, file_name=name)
else: #filename_or_handle is not valid
raise GooglePhotosException({'status':GPHOTOS_INVALID_ARGUMENT,
'body':'`filename_or_handle` must be a path name or a file-
like object',
- 'reason':'Found %s, not path name or object that has .read()
and .len attributes' % \
+ 'reason':'Found %s, not path name or an object with .read()
method' % \
type(filename_or_handle)
})
if isinstance(photo_or_uri, (str, unicode)):
entry_uri = photo_or_uri # it's a uri
elif hasattr(photo_or_uri, 'GetEditMediaLink'):
- entry_uri = photo.GetEditMediaLink().href
+ entry_uri = photo_or_uri.GetEditMediaLink().href
try:
return self.Put(photoblob, entry_uri,
converter=gdata.photos.PhotoEntryFromString)
--------------8<------------------
> together! The photos modules present some unique challenges and I
> really like your approach.
Cool. Once you get the .media, .exif and .geo modules in there I'll
give it some exhaustive testing.
>
> Happy coding,
Yes, speaking of which.. I've noticed some new elements in the xml
stream lately. Notably, gphoto:snippet, gphoto:snippettype and
gphoto:truncated. We should add support for them as well, shouldn't
we... I'll whip up a patch.
Håvard