diff --git a/Makefile b/Makefile index 1abffcec66..399c086d95 100644 --- a/Makefile +++ b/Makefile @@ -33,11 +33,17 @@ pictureflow : cd ../PyQt && \ mkdir -p .build && \ cd .build && rm -f * && \ - python ../configure.py && make && \ + ${PYTHON} ../configure.py && make && \ cd ../../../../../.. && \ cp src/calibre/gui2/pictureflow/PyQt/.build/pictureflow.so src/calibre/plugins/ && \ rm -rf src/calibre/gui2/pictureflow/.build rm -rf src/calibre/gui2/pictureflow/PyQt/.build +lzx : + mkdir -p src/calibre/plugins && rm -f src/calibre/plugins/*pictureflow* && \ + cd src/calibre/utils/lzx && mkdir .build && cd .build && \ + ${PYTHON} ../configure.py && make && cd - && \ + cp src/calibre/utils/lzx/.build/lzx.so src/calibre/plugins/ && \ + rm -rf src/calibre/utils/lzx/.build/ pot : cd src/calibre/translations && ${PYTHON} __init__.py pot diff --git a/src/calibre/__init__.py b/src/calibre/__init__.py index b52a2bcbc8..2237024963 100644 --- a/src/calibre/__init__.py +++ b/src/calibre/__init__.py @@ -477,13 +477,16 @@ class Settings(QSettings): 'kovidgoyal.net', name) def get(self, key, default=None): - key = str(key) - if not self.contains(key): + try: + key = str(key) + if not self.contains(key): + return default + val = str(self.value(key, QVariant()).toByteArray()) + if not val: + return None + return cPickle.loads(val) + except: return default - val = str(self.value(key, QVariant()).toByteArray()) - if not val: - return None - return cPickle.loads(val) def set(self, key, val): val = cPickle.dumps(val, -1) diff --git a/src/calibre/ebooks/lrf/html/convert_from.py b/src/calibre/ebooks/lrf/html/convert_from.py index e1014d69dd..b118520b82 100644 --- a/src/calibre/ebooks/lrf/html/convert_from.py +++ b/src/calibre/ebooks/lrf/html/convert_from.py @@ -1453,6 +1453,7 @@ class HTMLConverter(object, LoggingInterface): self.page_break_found = True if self.options.add_chapters_to_toc: + self.current_block.must_append = True self.extra_toc_entries.append((self.get_text(tag, limit=1000), self.current_block)) @@ -1666,6 +1667,7 @@ class HTMLConverter(object, LoggingInterface): self.page_break_found = True if self.options.add_chapters_to_toc: + self.current_block.must_append = True self.extra_toc_entries.append((self.get_text(tag, limit=1000), self.current_block)) diff --git a/src/calibre/gui2/main.py b/src/calibre/gui2/main.py index d85acb9dcb..fa3896a4ca 100644 --- a/src/calibre/gui2/main.py +++ b/src/calibre/gui2/main.py @@ -40,7 +40,6 @@ from calibre.gui2.dialogs.search import SearchDialog from calibre.gui2.dialogs.user_profiles import UserProfiles from calibre.gui2.dialogs.choose_format import ChooseFormatDialog from calibre.gui2.dialogs.book_info import BookInfo -from calibre.library.database import DatabaseLocked from calibre.ebooks.metadata.meta import set_metadata from calibre.ebooks.metadata import MetaInformation from calibre.ebooks import BOOK_EXTENSIONS @@ -1247,12 +1246,7 @@ path_to_ebook to the database. '
%s is already running. %s
'%(__appname__, extra)) return 1 initialize_file_icon_provider() - try: - main = Main(single_instance, opts) - except DatabaseLocked, err: - QMessageBox.critical(None, 'Cannot Start '+__appname__, - 'Another program is using the database.
Perhaps %s is already running?
If not try deleting the file %s'%(__appname__, err.lock_file_path))
- return 1
+ main = Main(single_instance, opts)
sys.excepthook = main.unhandled_exception
if len(args) > 1:
main.add_filesystem_book(args[1])
diff --git a/src/calibre/library/database.py b/src/calibre/library/database.py
index d3f4654969..006438746b 100644
--- a/src/calibre/library/database.py
+++ b/src/calibre/library/database.py
@@ -31,47 +31,9 @@ class Concatenate(object):
return self.ans[:-len(self.sep)]
return self.ans
-_lock_file = None
-class DatabaseLocked(Exception):
-
- def __init__(self, msg, lock_file_path):
- Exception.__init__(self, msg)
- self.lock_file_path = lock_file_path
-
-def _lock(path):
- path = os.path.join(os.path.dirname(path), '.'+os.path.basename(path)+'.lock')
- global _lock_file
- if _lock_file is not None:
- raise DatabaseLocked('Database already locked in this instance.', _lock_file.name)
- try:
- _lock_file = open(path, 'wb')
- except IOError:
- raise DatabaseLocked('Database in use by another instance', path)
- try:
- import fcntl, errno
- try:
- fcntl.lockf(_lock_file.fileno(), fcntl.LOCK_EX|fcntl.LOCK_NB)
- except IOError, err:
- path = _lock_file.name
- _lock_file = None
- if err.errno in (errno.EACCES, errno.EAGAIN):
- raise DatabaseLocked('Database in use by another instance', path)
- except ImportError:
- try:
- import msvcrt
- try:
- msvcrt.locking(_lock_file.fileno(), msvcrt.LK_NBLCK, 1)
- except IOError:
- path = _lock_file.name
- _lock_file = None
- raise DatabaseLocked('Database in use by another instance', path)
- except ImportError:
- pass
-
def _connect(path):
if isinstance(path, unicode):
path = path.encode('utf-8')
- #_lock(path)
conn = sqlite.connect(path, detect_types=sqlite.PARSE_DECLTYPES|sqlite.PARSE_COLNAMES)
conn.row_factory = lambda cursor, row : list(row)
conn.create_aggregate('concat', 1, Concatenate)
@@ -794,14 +756,6 @@ ALTER TABLE books ADD COLUMN isbn TEXT DEFAULT "" COLLATE NOCASE;
conn.commit()
- def __del__(self):
- global _lock_file
- import os
- if _lock_file is not None:
- _lock_file.close()
- if os.path.exists(_lock_file.name):
- os.unlink(_lock_file.name)
-
def __init__(self, dbpath, row_factory=False):
self.dbpath = dbpath
self.conn = _connect(dbpath)
diff --git a/src/calibre/manual/faq.rst b/src/calibre/manual/faq.rst
index cb381cb8aa..d130bd9a1b 100644
--- a/src/calibre/manual/faq.rst
+++ b/src/calibre/manual/faq.rst
@@ -133,10 +133,9 @@ The graphical user interface of |app| is not starting on Windows?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If you've never used the graphical user interface before, try deleting the file library1.db (it will be somewhere under :file:`C:\\Documents and Settings` on Windows XP and :file:`C:\\Users` on Windows Vista. If that doesn't fix the problem, locate the file calibre.log (in the same places as library1.db) and post its contents in a help message on the `Forums