From 2bad2c5162157a9d5bc4bf85d0dc483540d9f85a Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 16 May 2009 18:26:32 -0700 Subject: [PATCH 1/6] Fix #2449 (Crashing on mac os X 10.5.7 when cancel metadata search) --- src/calibre/gui2/dialogs/fetch_metadata.py | 2 ++ src/calibre/gui2/dialogs/metadata_single.py | 30 ++++++++++----------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/calibre/gui2/dialogs/fetch_metadata.py b/src/calibre/gui2/dialogs/fetch_metadata.py index 805cc1c3bf..62f26c757f 100644 --- a/src/calibre/gui2/dialogs/fetch_metadata.py +++ b/src/calibre/gui2/dialogs/fetch_metadata.py @@ -187,6 +187,8 @@ class FetchMetadata(QDialog, Ui_FetchMetadata): def terminate(self): if hasattr(self, 'fetcher') and self.fetcher.isRunning(): self.fetcher.terminate() + if hasattr(self, '_hangcheck') and self._hangcheck.isActive(): + self._hangcheck.stop() def __enter__(self, *args): diff --git a/src/calibre/gui2/dialogs/metadata_single.py b/src/calibre/gui2/dialogs/metadata_single.py index 5f2ea375b2..e5ee3bccca 100644 --- a/src/calibre/gui2/dialogs/metadata_single.py +++ b/src/calibre/gui2/dialogs/metadata_single.py @@ -419,22 +419,22 @@ class MetadataSingleDialog(ResizableDialog, Ui_MetadataSingleDialog): publisher = qstring_to_unicode(self.publisher.currentText()) if isbn or title or author or publisher: d = FetchMetadata(self, isbn, title, author, publisher, self.timeout) + self._fetch_metadata_scope = d with d: - d.exec_() - if d.result() == QDialog.Accepted: - book = d.selected_book() - if book: - self.title.setText(book.title) - self.authors.setText(authors_to_string(book.authors)) - if book.author_sort: self.author_sort.setText(book.author_sort) - if book.publisher: self.publisher.setEditText(book.publisher) - if book.isbn: self.isbn.setText(book.isbn) - summ = book.comments - if summ: - prefix = qstring_to_unicode(self.comments.toPlainText()) - if prefix: - prefix += '\n' - self.comments.setText(prefix + summ) + if d.exec_() == QDialog.Accepted: + book = d.selected_book() + if book: + self.title.setText(book.title) + self.authors.setText(authors_to_string(book.authors)) + if book.author_sort: self.author_sort.setText(book.author_sort) + if book.publisher: self.publisher.setEditText(book.publisher) + if book.isbn: self.isbn.setText(book.isbn) + summ = book.comments + if summ: + prefix = qstring_to_unicode(self.comments.toPlainText()) + if prefix: + prefix += '\n' + self.comments.setText(prefix + summ) else: error_dialog(self, _('Cannot fetch metadata'), _('You must specify at least one of ISBN, Title, ' From e8c56353df97f08310a50fc7f4aad990663f2870 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 17 May 2009 10:21:38 -0700 Subject: [PATCH 2/6] Updated recipe ro the Times Online --- src/calibre/gui2/images/news/times_online.png | Bin 0 -> 328 bytes .../web/feeds/recipes/recipe_newsweek.py | 24 ++-- .../web/feeds/recipes/recipe_times_online.py | 107 +++++++++++------- 3 files changed, 78 insertions(+), 53 deletions(-) create mode 100644 src/calibre/gui2/images/news/times_online.png diff --git a/src/calibre/gui2/images/news/times_online.png b/src/calibre/gui2/images/news/times_online.png new file mode 100644 index 0000000000000000000000000000000000000000..c9cd67d5460651db8c5c6fcf9938bfd52f454f2d GIT binary patch literal 328 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%caKYZ?lYt_f1s;*b zK-vS0-A-oPfdtD69Mgd`SU*F|v9*VRoI+0*#}JFt$#=f>JhW$KZRiv_%L4>DC+2t` z@3_1qy*0sDsrsNd*TM%+lR4b3F>Fq_ZEO?wB7*s#ULuEKtarzaDR)^8Ie1E6t$e{S z+op^0M$Um}PIK5MFuUXdHBB9f%stHWq#0|zC<<-l@azX#u3F+6 zQIcGgnpl#mn*t;lj0_Acbq!2)4b4Lg4Xl93$U@h^+{(a!&+FeTn1 Date: Mon, 18 May 2009 12:13:05 -0700 Subject: [PATCH 3/6] Various Hungarian news recipes by Ezmegaz --- src/calibre/devices/bebook/driver.py | 2 +- src/calibre/library/database2.py | 2 ++ src/calibre/web/feeds/recipes/__init__.py | 1 + src/calibre/web/feeds/recipes/recipe_h1.py | 32 ++++++++++++++++++++++ src/calibre/web/feeds/recipes/recipe_h2.py | 21 ++++++++++++++ src/calibre/web/feeds/recipes/recipe_h3.py | 29 ++++++++++++++++++++ 6 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 src/calibre/web/feeds/recipes/recipe_h1.py create mode 100644 src/calibre/web/feeds/recipes/recipe_h2.py create mode 100644 src/calibre/web/feeds/recipes/recipe_h3.py diff --git a/src/calibre/devices/bebook/driver.py b/src/calibre/devices/bebook/driver.py index a0130cd7f8..7313c24253 100644 --- a/src/calibre/devices/bebook/driver.py +++ b/src/calibre/devices/bebook/driver.py @@ -8,7 +8,7 @@ from calibre.devices.usbms.driver import USBMS class BEBOOK(USBMS): # Ordered list of supported formats - FORMATS = ['mobi', 'epub', 'pdf', 'mobi', 'txt'] + FORMATS = ['mobi', 'epub', 'pdf', 'txt'] VENDOR_ID = [0x0525] PRODUCT_ID = [0x8803, 0x6803] diff --git a/src/calibre/library/database2.py b/src/calibre/library/database2.py index 4247e0cad3..d26686e412 100644 --- a/src/calibre/library/database2.py +++ b/src/calibre/library/database2.py @@ -193,6 +193,8 @@ class ResultCache(SearchQueryParser): if query and query.strip(): location = location.lower().strip() query = query.lower() + if not isinstance(query, unicode): + query = query.decode('utf-8') if location in ('tag', 'author', 'format'): location += 's' all = ('title', 'authors', 'publisher', 'tags', 'comments', 'series', 'formats') diff --git a/src/calibre/web/feeds/recipes/__init__.py b/src/calibre/web/feeds/recipes/__init__.py index ae1ae24131..639878b37f 100644 --- a/src/calibre/web/feeds/recipes/__init__.py +++ b/src/calibre/web/feeds/recipes/__init__.py @@ -43,6 +43,7 @@ recipe_modules = ['recipe_' + r for r in ( 'seattle_times', 'scott_hanselman', 'coding_horror', 'twitchfilms', 'stackoverflow', 'telepolis_artikel', 'zaobao', 'usnews', 'straitstimes', 'index_hu', 'pcworld_hu', 'hrt', 'rts', + 'h1', 'h2', 'h3', )] import re, imp, inspect, time, os diff --git a/src/calibre/web/feeds/recipes/recipe_h1.py b/src/calibre/web/feeds/recipes/recipe_h1.py new file mode 100644 index 0000000000..2678e5b2eb --- /dev/null +++ b/src/calibre/web/feeds/recipes/recipe_h1.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python +# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai +from __future__ import with_statement + +__license__ = 'GPL v3' +__copyright__ = '2009, Kovid Goyal ' +__docformat__ = 'restructuredtext en' + +from calibre.web.feeds.news import BasicNewsRecipe + +class H168(BasicNewsRecipe): + title = u'168\xf3ra' + oldest_article = 4 + max_articles_per_feed = 50 + language = _('Hungarian') + __author__ = 'Ezmegaz' + + feeds = [(u'Itthon', + u'http://www.168ora.hu/static/rss/cikkek_itthon.xml'), (u'Gl\xf3busz', + u'http://www.168ora.hu/static/rss/cikkek_globusz.xml'), (u'Punch', + u'http://www.168ora.hu/static/rss/cikkek_punch.xml'), (u'Arte', + u'http://www.168ora.hu/static/rss/cikkek_arte.xml'), (u'Buxa', + u'http://www.168ora.hu/static/rss/cikkek_buxa.xml'), (u'Sebess\xe9g', + u'http://www.168ora.hu/static/rss/cikkek_sebesseg.xml'), (u'Tud\xe1s', + u'http://www.168ora.hu/static/rss/cikkek_tudas.xml'), (u'Sport', + u'http://www.168ora.hu/static/rss/cikkek_sport.xml'), (u'V\xe9lem\xe9ny', + u'http://www.168ora.hu/static/rss/cikkek_velemeny.xml'), (u'Dolce Vita', + u'http://www.168ora.hu/static/rss/cikkek_dolcevita.xml'), (u'R\xe1di\xf3', + u'http://www.168ora.hu/static/rss/radio.xml')] + + + diff --git a/src/calibre/web/feeds/recipes/recipe_h2.py b/src/calibre/web/feeds/recipes/recipe_h2.py new file mode 100644 index 0000000000..20c251ded9 --- /dev/null +++ b/src/calibre/web/feeds/recipes/recipe_h2.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python +# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai +from __future__ import with_statement + +__license__ = 'GPL v3' +__copyright__ = '2009, Kovid Goyal ' +__docformat__ = 'restructuredtext en' + +from calibre.web.feeds.news import BasicNewsRecipe + +class ATV(BasicNewsRecipe): + title = u'ATV' + oldest_article = 5 + max_articles_per_feed = 50 + language = _('Hungarian') + __author__ = 'Ezmegaz' + + + feeds = [(u'H\xedrek', u'http://atv.hu/rss/1'), (u'Cikkek', + u'http://atv.hu/rss/2')] + diff --git a/src/calibre/web/feeds/recipes/recipe_h3.py b/src/calibre/web/feeds/recipes/recipe_h3.py new file mode 100644 index 0000000000..a4da0c71cd --- /dev/null +++ b/src/calibre/web/feeds/recipes/recipe_h3.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python +# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai +from __future__ import with_statement + +__license__ = 'GPL v3' +__copyright__ = '2009, Kovid Goyal ' +__docformat__ = 'restructuredtext en' + +from calibre.web.feeds.news import BasicNewsRecipe + +class H3(BasicNewsRecipe): + title = u'H\xedrszerz\u0151' + oldest_article = 5 + max_articles_per_feed = 50 + language = _('Hungarian') + __author__ = 'Ezmegaz' + + + feeds = [(u'Belf\xf6ld', + u'http://www.hirszerzo.hu/rss.belfold.xml'), (u'K\xfclf\xf6ld', + u'http://www.hirszerzo.hu/rss.kulfold.xml'), (u'Profit', + u'http://www.hirszerzo.hu/rss.profit.xml'), (u'Shake', + u'http://www.hirszerzo.hu/rss.shake.xml'), (u'Publicisztika', + u'http://www.hirszerzo.hu/rss.publicisztika.xml'), (u'Elemz\xe9s', + u'http://www.hirszerzo.hu/rss.elemzes.xml'), (u'Sorok k\xf6z\xf6tt', + u'http://www.hirszerzo.hu/rss.sorok_kozott.xml'), (u'Gal\xe9ria', + u'http://www.hirszerzo.hu/rss.galeria.xml'), (u'Patro', + u'http://www.hirszerzo.hu/rss.patro.xml')] + From 716eb7b890000c38e7ecbd3b30c2485eb77ff0d2 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 18 May 2009 12:46:04 -0700 Subject: [PATCH 4/6] Fix #2465 (Calibre fails after running GlobeTrotter Connect on OS X 10.5) --- src/calibre/devices/usbobserver/usbobserver.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/calibre/devices/usbobserver/usbobserver.c b/src/calibre/devices/usbobserver/usbobserver.c index 20b4944d41..051901f849 100644 --- a/src/calibre/devices/usbobserver/usbobserver.c +++ b/src/calibre/devices/usbobserver/usbobserver.c @@ -71,12 +71,16 @@ usbobserver_get_usb_devices(PyObject *self, PyObject *args) { plugInInterface = NULL; dev = NULL; //Create an intermediate plugin kr = IOCreatePlugInInterfaceForService(usbDevice, kIOUSBDeviceUserClientTypeID, kIOCFPlugInInterfaceID, &plugInInterface, &score); - if ((kIOReturnSuccess != kr) || !plugInInterface) - printf("Unable to create a plug-in (%08x)\n", kr); + if ((kIOReturnSuccess != kr) || !plugInInterface) { + printf("Unable to create a plug-in (%08x)\n", kr); continue; + } //Now create the device interface HRESULT result = (*plugInInterface)->QueryInterface(plugInInterface, CFUUIDGetUUIDBytes(kIOUSBDeviceInterfaceID), (LPVOID)&dev); - if (result || !dev) printf("Couldn't create a device interface (%08x)\n", (int) result); + if (result || !dev) { + printf("Couldn't create a device interface (%08x)\n", (int) result); + continue; + } kr = (*dev)->GetDeviceVendor(dev, &vendor); kr = (*dev)->GetDeviceProduct(dev, &product); From 4b457c14869b7c8c003cb0541d5e727bfc262e18 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 19 May 2009 10:42:20 -0700 Subject: [PATCH 5/6] Add genshi license --- src/calibre/utils/genshi/LICENSE | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/calibre/utils/genshi/LICENSE diff --git a/src/calibre/utils/genshi/LICENSE b/src/calibre/utils/genshi/LICENSE new file mode 100644 index 0000000000..28b70b6fe2 --- /dev/null +++ b/src/calibre/utils/genshi/LICENSE @@ -0,0 +1,28 @@ +Copyright © 2006-2007 Edgewall Software[[BR]] +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The name of the author may not be used to endorse or promote + products derived from this software without specific prior + written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR “AS IS” AND ANY EXPRESS +OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file From a334000e705d3f16512fa30fe4eafc8320bddcb3 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 21 May 2009 07:05:11 -0700 Subject: [PATCH 6/6] Fix #2475 (Calibre 0.5.12 Conversion Error) --- src/calibre/ebooks/mobi/reader.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/calibre/ebooks/mobi/reader.py b/src/calibre/ebooks/mobi/reader.py index de396f4966..85d23d821d 100644 --- a/src/calibre/ebooks/mobi/reader.py +++ b/src/calibre/ebooks/mobi/reader.py @@ -650,12 +650,13 @@ class MobiReader(object): image_index += 1 try: im = PILImage.open(buf) + im = im.convert('RGB') except IOError: continue path = os.path.join(output_dir, '%05d.jpg'%image_index) self.image_names.append(os.path.basename(path)) - im.convert('RGB').save(open(path, 'wb'), format='JPEG') + im.save(open(path, 'wb'), format='JPEG') def get_metadata(stream): mi = MetaInformation(os.path.basename(stream.name), [_('Unknown')])