On Sep 14, "Garland, Ken R" <[EMAIL PROTECTED]> wrote:

> Is there a place in the code which shows version number/name? similar
> to module.__version__

Not in the imdb package; it's only in the setup.py.
I'll consider adding it somewhere in the package; thanks for the hint!

> >>> import imdb
> >>> ia = imdb.IMDb()
> >>> results = ia.search_movie('goonies')
> >>> for movie in results:
> ...     ia.update(movie)
> ...     if movie.has_key('cover url'):
> ...         print movie['title'] + ' ' + movie['cover url']

Here - with the 'if movie.has_key('cover url')' clause - you're
skipping movies without a cover; is it ok for you?
You can use movie.get('cover url') instead: it will return None if
'cover url' is not available; you can also specify a different default
with a second argument:
  movie.get('cover url', 'http://localhost/cover_unknown.jpg')

>     raise IMDbDataAccessError, {'errcode': e.errno,
> imdb._exceptions.IMDbDataAccessError: {'exception type': 'IOError',
> 'url': 'http://akas.imdb.com/title/tt0106531/plotsummary', 'errcode':
> 'socket error', 'proxy': '', 'original exception': <exceptions.IOError
> instance at 0xb7afff6c>, 'errmsg': "(-2, 'Name or service not
> known')"}

Looks like an I/O error on the socket, and not something related
to IMDbPY.
The 'Name or service not known' message suggests that you had problem
with the resolution of the akas.imdb.com domain name; maybe your
connection was too slow/busy, and a timeout occurred.

> something a bit simpler that works:
> 
> >>> for movie in results:
> ...     ia.update(movie)
> ...     print movie['title']

I can't think of any reason for this one to work, while the first one
failed: it was just a coincidence, I assume.

Unfortunately there is not much you can do, if your connection
is unreliable (or if it was just an hiccup).
The best thing you can do is to trap the exception and ignore it.

An example:

import imdb
import warnings

ia = imdb.IMDb()

try:
    results = ia.search_movie('goonies')
except IMDbDataAccessError, e:
    warnings.warn('Unable to execute a search: %s' % e)
    results = []

for movie in results:
    try:
        ia.update(movie)
    except IMDbDataAccessError, e:
        warnings.warn('Unable to retrieve info for movie %s: %s)' %
                      (movie.get('title'), e))
        continue
    print movie['title']


But honestly: generally it doesn't make much sense to check this kind
of exceptions.  Do it only if you need an absolutely reliable program
and you know how to manage these corner cases, otherwise it's better
to just leave the program exits with an error.


HTH,
-- 
Davide Alberani <[EMAIL PROTECTED]> [PGP KeyID: 0x465BFD47]
http://erlug.linux.it/~da/

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Imdbpy-devel mailing list
Imdbpy-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/imdbpy-devel

Reply via email to