Exemple #1
0
        if si and opts.shutdown_running_calibre:
            return 0
        run_main(app, opts, args, gui_debug, si)
    if after_quit_actions['restart_after_quit']:
        restart_after_quit()


def run_main(app, opts, args, gui_debug, si):
    if si:
        return run_gui(opts, args, app, gui_debug=gui_debug)
    communicate(opts, args)
    return 0


if __name__ == '__main__':
    try:
        sys.exit(main())
    except Exception as err:
        if not iswindows:
            raise
        tb = traceback.format_exc()
        from qt.core import QErrorMessage
        logfile = os.path.join(os.path.expanduser('~'), 'calibre.log')
        if os.path.exists(logfile):
            with open(logfile) as f:
                log = f.read().decode('utf-8', 'ignore')
            d = QErrorMessage()
            d.showMessage(('<b>Error:</b>%s<br><b>Traceback:</b><br>'
                           '%s<b>Log:</b><br>%s') % (str(err), str(tb).replace(
                               '\n', '<br>'), log.replace('\n', '<br>')))