Merging changes to book_data.py
authorChristopher Hawthorne <cdchawthorne@gmail.com>
Sat, 9 Nov 2013 04:44:16 +0000 (23:44 -0500)
committerChristopher Hawthorne <cdchawthorne@gmail.com>
Sat, 9 Nov 2013 04:44:16 +0000 (23:44 -0500)
1  2 
book_data.py

diff --cc book_data.py
@@@ -36,11 -37,11 +37,13 @@@ Keys
  def openLibrary_isbn(ISBN):
      isbn = str(ISBN)
      try:
 -        jsondata = urlopen("http://openlibrary.org/api/books?format=json&jscmd=data&bibkeys=ISBN:"+isbn, timeout=3)
 +        jsondata = urlopen("http://openlibrary.org/api/books"
 +                           "?format=json&jscmd=data&bibkeys=ISBN:"+isbn,
 +                           timeout=3)
-     except URLError:
-         return {}
+     except URLError as e:
+         return {'title':e}
+     except timeout:
+         return {'title':'Timeout while connecting to OpenLibrary.org'}
      openBook = loads(jsondata.read().decode('utf-8'))
      if "ISBN:"+isbn not in openBook:
          return {'isbn':isbn,'title':'Book not found'}