~ubuntu-branches/debian/sid/calibre/sid

« back to all changes in this revision

Viewing changes to src/calibre/gui2/tweak_book/main.py

  • Committer: Package Import Robot
  • Author(s): Martin Pitt
  • Date: 2014-02-27 07:48:06 UTC
  • mto: This revision was merged to the branch mainline in revision 74.
  • Revision ID: package-import@ubuntu.com-20140227074806-64wdebb3ptosxhhx
Tags: upstream-1.25.0+dfsg
ImportĀ upstreamĀ versionĀ 1.25.0+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
__license__ = 'GPL v3'
7
7
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
8
8
 
9
 
import sys, os, importlib
 
9
import sys, os, importlib, time
10
10
 
11
11
from PyQt4.Qt import QIcon
12
12
 
13
13
from calibre.constants import islinux, iswindows
14
 
from calibre.gui2 import Application, ORG_NAME, APP_UID, setup_gui_option_parser, detach_gui
 
14
from calibre.gui2 import Application, ORG_NAME, APP_UID, setup_gui_option_parser, detach_gui, decouple
15
15
from calibre.ptempfile import reset_base_dir
16
16
from calibre.utils.config import OptionParser
17
17
 
54
54
    opts, args = parser.parse_args(args)
55
55
    if getattr(opts, 'detach', False):
56
56
        detach_gui()
 
57
    decouple('edit-book-')
57
58
    override = 'calibre-edit-book' if islinux else None
58
59
    app = Application(args, override_program_name=override)
59
60
    app.load_builtin_fonts()
66
67
    if len(args) > 1:
67
68
        main.boss.open_book(args[1], edit_file=opts.edit_file, clear_notify_data=False)
68
69
    app.exec_()
 
70
    # Ensure that the parse worker has quit so that temp files can be deleted
 
71
    # on windows
 
72
    st = time.time()
 
73
    from calibre.gui2.tweak_book.preview import parse_worker
 
74
    while parse_worker.is_alive() and time.time() - st < 120:
 
75
        time.sleep(0.1)
69
76
 
70
77
def main(args=sys.argv):
71
78
    _run(args)