def debug(self): try: from calibre.devices import debug raw = debug() self.log.setPlainText(raw) finally: self.bbox.setEnabled(True)
def main(args=sys.argv): from calibre.constants import debug debug() opts, args = option_parser().parse_args(args) if opts.gui: from calibre.gui2.main import main print_basic_debug_info() main(['calibre']) elif opts.gui_debug is not None: run_debug_gui(opts.gui_debug) elif opts.show_gui_debug: import time, re time.sleep(1) from calibre.gui2 import open_local_file if iswindows: with open(opts.show_gui_debug, 'r+b') as f: raw = f.read() raw = re.sub('(?<!\r)\n', '\r\n', raw) f.seek(0) f.truncate() f.write(raw) open_local_file(opts.show_gui_debug) elif opts.viewer: from calibre.gui2.viewer.main import main vargs = ['ebook-viewer', '--debug-javascript'] if len(args) > 1: vargs.append(args[-1]) main(vargs) elif opts.py_console: from calibre.utils.pyconsole.main import main main() elif opts.command: sys.argv = args exec(opts.command) elif opts.debug_device_driver: debug_device_driver() elif opts.add_simple_plugin is not None: add_simple_plugin(opts.add_simple_plugin) elif opts.paths: prints('CALIBRE_RESOURCES_PATH='+sys.resources_location) prints('CALIBRE_EXTENSIONS_PATH='+sys.extensions_location) prints('CALIBRE_PYTHON_PATH='+os.pathsep.join(sys.path)) elif opts.reinitialize_db is not None: reinit_db(opts.reinitialize_db) elif opts.inspect_mobi: for path in args[1:]: inspect_mobi(path) elif opts.tweak_book: from calibre.gui2.tweak_book.main import main main(['ebook-tweak'] + args[1:]) elif opts.test_build: from calibre.test_build import test test() elif opts.shutdown_running_calibre: from calibre.gui2.main import shutdown_other shutdown_other() elif opts.subset_font: from calibre.utils.fonts.sfnt.subset import main main(['subset-font']+[opts.subset_font]+args[1:]) elif opts.exec_file: run_script(opts.exec_file, args[1:]) elif opts.run_plugin: from calibre.customize.ui import find_plugin plugin = find_plugin(opts.run_plugin) if plugin is None: prints(_('No plugin named %s found')%opts.run_plugin) raise SystemExit(1) plugin.cli_main([plugin.name] + args[1:]) elif len(args) >= 2 and args[1].rpartition('.')[-1] in {'py', 'recipe'}: run_script(args[1], args[2:]) elif len(args) >= 2 and args[1].rpartition('.')[-1] in {'mobi', 'azw', 'azw3', 'docx'}: for path in args[1:]: ext = path.rpartition('.')[-1] if ext == 'docx': from calibre.ebooks.docx.dump import dump dump(path) elif ext in {'mobi', 'azw', 'azw3'}: inspect_mobi(path) else: print ('Cannot dump unknown filetype: %s' % path) else: from calibre import ipython ipython() return 0
def debug_device_driver(): from calibre.devices import debug debug(ioreg_to_tmp=True, buf=sys.stdout) if iswindows: raw_input('Press Enter to continue...')
def main(args=sys.argv): from calibre.constants import debug debug() opts, args = option_parser().parse_args(args) if opts.gui: from calibre.gui_launch import calibre print_basic_debug_info() calibre(['calibre']) elif opts.gui_debug is not None: run_debug_gui(opts.gui_debug) elif opts.viewer: from calibre.gui_launch import ebook_viewer ebook_viewer(['ebook-viewer', '--debug-javascript'] + args[1:]) elif opts.py_console: from calibre.utils.pyconsole.main import main main() elif opts.command: sys.argv = args exec(opts.command) elif opts.debug_device_driver: debug_device_driver() elif opts.add_simple_plugin is not None: add_simple_plugin(opts.add_simple_plugin) elif opts.paths: prints('CALIBRE_RESOURCES_PATH='+sys.resources_location) prints('CALIBRE_EXTENSIONS_PATH='+sys.extensions_location) prints('CALIBRE_PYTHON_PATH='+os.pathsep.join(sys.path)) elif opts.reinitialize_db is not None: reinit_db(opts.reinitialize_db) elif opts.inspect_mobi: for path in args[1:]: inspect_mobi(path) elif opts.edit_book: from calibre.gui_launch import ebook_edit ebook_edit(['ebook-edit'] + args[1:]) elif opts.explode_book: from calibre.ebooks.tweak import tweak tweak(opts.explode_book) elif opts.test_build: from calibre.test_build import test test() elif opts.shutdown_running_calibre: from calibre.gui2.main import shutdown_other shutdown_other() elif opts.subset_font: from calibre.utils.fonts.sfnt.subset import main main(['subset-font'] + args[1:]) elif opts.exec_file: run_script(opts.exec_file, args[1:]) elif opts.run_plugin: from calibre.customize.ui import find_plugin plugin = find_plugin(opts.run_plugin) if plugin is None: prints(_('No plugin named %s found')%opts.run_plugin) raise SystemExit(1) plugin.cli_main([plugin.name] + args[1:]) elif opts.diff: from calibre.gui2.tweak_book.diff.main import main main(['calibre-diff'] + args[1:]) elif opts.default_programs: if not iswindows: raise SystemExit('Can only be run on Microsoft Windows') if opts.default_programs == 'register': from calibre.utils.winreg.default_programs import register as func else: from calibre.utils.winreg.default_programs import unregister as func print 'Running', func.__name__, '...' func() elif opts.new_server: from calibre.srv.standalone import main main(args) elif opts.export_all_calibre_data: from calibre.utils.exim import run_exporter run_exporter() elif opts.import_calibre_data: from calibre.utils.exim import run_importer run_importer() elif len(args) >= 2 and args[1].rpartition('.')[-1] in {'py', 'recipe'}: run_script(args[1], args[2:]) elif len(args) >= 2 and args[1].rpartition('.')[-1] in {'mobi', 'azw', 'azw3', 'docx', 'odt'}: for path in args[1:]: ext = path.rpartition('.')[-1] if ext in {'docx', 'odt'}: from calibre.ebooks.docx.dump import dump dump(path) elif ext in {'mobi', 'azw', 'azw3'}: inspect_mobi(path) else: print ('Cannot dump unknown filetype: %s' % path) elif len(args) >= 2 and os.path.exists(os.path.join(args[1], '__main__.py')): sys.path.insert(0, args[1]) run_script(os.path.join(args[1], '__main__.py'), args[2:]) else: from calibre import ipython ipython() return 0
def main(args=sys.argv): from calibre.constants import debug debug() if len(args) > 2 and args[1] in ("-e", "--exec-file"): # Load all plugins user defined plugins so the script can import from the # calibre_plugins namespace import calibre.customize.ui as dummy dummy sys.argv = [args[2]] + args[3:] ef = os.path.abspath(args[2]) base = os.path.dirname(ef) sys.path.insert(0, base) g = globals() g["__name__"] = "__main__" g["__file__"] = ef execfile(ef, g) return opts, args = option_parser().parse_args(args) if opts.gui: from calibre.gui2.main import main main(["calibre"]) elif opts.gui_debug is not None: run_debug_gui(opts.gui_debug) elif opts.show_gui_debug: import time, re time.sleep(1) from calibre.gui2 import open_local_file if iswindows: with open(opts.show_gui_debug, "r+b") as f: raw = f.read() raw = re.sub("(?<!\r)\n", "\r\n", raw) f.seek(0) f.truncate() f.write(raw) open_local_file(opts.show_gui_debug) elif opts.viewer: from calibre.gui2.viewer.main import main vargs = ["ebook-viewer", "--debug-javascript"] if len(args) > 1: vargs.append(args[-1]) main(vargs) elif opts.py_console: from calibre.utils.pyconsole.main import main main() elif opts.command: sys.argv = args exec opts.command elif opts.debug_device_driver: debug_device_driver() elif opts.migrate: if len(args) < 3: print "You must specify the path to library1.db and the path to the new library folder" return 1 migrate(args[1], args[2]) elif opts.add_simple_plugin is not None: add_simple_plugin(opts.add_simple_plugin) elif opts.paths: prints("CALIBRE_RESOURCES_PATH=" + sys.resources_location) prints("CALIBRE_EXTENSIONS_PATH=" + sys.extensions_location) prints("CALIBRE_PYTHON_PATH=" + os.pathsep.join(sys.path)) elif opts.reinitialize_db is not None: sql_dump = None if len(args) > 1 and os.access(args[-1], os.R_OK): sql_dump = args[-1] reinit_db(opts.reinitialize_db, sql_dump=sql_dump) elif opts.inspect_mobi: from calibre.ebooks.mobi.debug.main import inspect_mobi for path in args[1:]: prints("Inspecting:", path) inspect_mobi(path) print elif opts.tweak_book: from calibre.ebooks.tweak import tweak tweak(opts.tweak_book) elif opts.test_build: from calibre.test_build import test test() elif opts.shutdown_running_calibre: from calibre.gui2.main import shutdown_other shutdown_other() else: from calibre import ipython ipython() return 0
def main(args=sys.argv): from calibre.constants import debug debug() opts, args = option_parser().parse_args(args) if opts.gui: from calibre.gui2.main import main print_basic_debug_info() main(['calibre']) elif opts.gui_debug is not None: run_debug_gui(opts.gui_debug) elif opts.viewer: from calibre.gui2.viewer.main import main main(['ebook-viewer'] + args[1:]) elif opts.py_console: from calibre.utils.pyconsole.main import main main() elif opts.command: sys.argv = args exec(opts.command) elif opts.debug_device_driver: debug_device_driver() elif opts.add_simple_plugin is not None: add_simple_plugin(opts.add_simple_plugin) elif opts.paths: prints('CALIBRE_RESOURCES_PATH='+sys.resources_location) prints('CALIBRE_EXTENSIONS_PATH='+sys.extensions_location) prints('CALIBRE_PYTHON_PATH='+os.pathsep.join(sys.path)) elif opts.reinitialize_db is not None: reinit_db(opts.reinitialize_db) elif opts.inspect_mobi: for path in args[1:]: inspect_mobi(path) elif opts.edit_book: from calibre.gui2.tweak_book.main import main main(['ebook-edit'] + args[1:]) elif opts.explode_book: from calibre.ebooks.tweak import tweak tweak(opts.explode_book) elif opts.test_build: from calibre.test_build import test test() elif opts.shutdown_running_calibre: from calibre.gui2.main import shutdown_other shutdown_other() elif opts.subset_font: from calibre.utils.fonts.sfnt.subset import main main(['subset-font']+[opts.subset_font]+args[1:]) elif opts.exec_file: run_script(opts.exec_file, args[1:]) elif opts.run_plugin: from calibre.customize.ui import find_plugin plugin = find_plugin(opts.run_plugin) if plugin is None: prints(_('No plugin named %s found')%opts.run_plugin) raise SystemExit(1) plugin.cli_main([plugin.name] + args[1:]) elif opts.diff: from calibre.gui2.tweak_book.diff.main import main main(['calibre-diff'] + args[1:]) elif len(args) >= 2 and args[1].rpartition('.')[-1] in {'py', 'recipe'}: run_script(args[1], args[2:]) elif len(args) >= 2 and args[1].rpartition('.')[-1] in {'mobi', 'azw', 'azw3', 'docx', 'odt'}: for path in args[1:]: ext = path.rpartition('.')[-1] if ext in {'docx', 'odt'}: from calibre.ebooks.docx.dump import dump dump(path) elif ext in {'mobi', 'azw', 'azw3'}: inspect_mobi(path) else: print ('Cannot dump unknown filetype: %s' % path) else: from calibre import ipython ipython() return 0
def main(args=sys.argv): from calibre.constants import debug debug() opts, args = option_parser().parse_args(args) if opts.gui: from calibre.gui2.main import main print_basic_debug_info() main(["calibre"]) elif opts.gui_debug is not None: run_debug_gui(opts.gui_debug) elif opts.show_gui_debug: import time, re time.sleep(1) from calibre.gui2 import open_local_file if iswindows: with open(opts.show_gui_debug, "r+b") as f: raw = f.read() raw = re.sub("(?<!\r)\n", "\r\n", raw) f.seek(0) f.truncate() f.write(raw) open_local_file(opts.show_gui_debug) elif opts.viewer: from calibre.gui2.viewer.main import main main(["ebook-viewer"] + args[1:]) elif opts.py_console: from calibre.utils.pyconsole.main import main main() elif opts.command: sys.argv = args exec(opts.command) elif opts.debug_device_driver: debug_device_driver() elif opts.add_simple_plugin is not None: add_simple_plugin(opts.add_simple_plugin) elif opts.paths: prints("CALIBRE_RESOURCES_PATH=" + sys.resources_location) prints("CALIBRE_EXTENSIONS_PATH=" + sys.extensions_location) prints("CALIBRE_PYTHON_PATH=" + os.pathsep.join(sys.path)) elif opts.reinitialize_db is not None: reinit_db(opts.reinitialize_db) elif opts.inspect_mobi: for path in args[1:]: inspect_mobi(path) elif opts.edit_book: from calibre.gui2.tweak_book.main import main main(["ebook-edit"] + args[1:]) elif opts.explode_book: from calibre.ebooks.tweak import tweak tweak(opts.explode_book) elif opts.test_build: from calibre.test_build import test test() elif opts.shutdown_running_calibre: from calibre.gui2.main import shutdown_other shutdown_other() elif opts.subset_font: from calibre.utils.fonts.sfnt.subset import main main(["subset-font"] + [opts.subset_font] + args[1:]) elif opts.exec_file: run_script(opts.exec_file, args[1:]) elif opts.run_plugin: from calibre.customize.ui import find_plugin plugin = find_plugin(opts.run_plugin) if plugin is None: prints(_("No plugin named %s found") % opts.run_plugin) raise SystemExit(1) plugin.cli_main([plugin.name] + args[1:]) elif opts.diff: from calibre.gui2.tweak_book.diff.main import main main(["calibre-diff"] + args[1:]) elif len(args) >= 2 and args[1].rpartition(".")[-1] in {"py", "recipe"}: run_script(args[1], args[2:]) elif len(args) >= 2 and args[1].rpartition(".")[-1] in {"mobi", "azw", "azw3", "docx", "odt"}: for path in args[1:]: ext = path.rpartition(".")[-1] if ext in {"docx", "odt"}: from calibre.ebooks.docx.dump import dump dump(path) elif ext in {"mobi", "azw", "azw3"}: inspect_mobi(path) else: print("Cannot dump unknown filetype: %s" % path) else: from calibre import ipython ipython() return 0
def main(args=sys.argv): from calibre.constants import debug debug() opts, args = option_parser().parse_args(args) if opts.gui: from calibre.gui2.main import main print_basic_debug_info() main(['calibre']) elif opts.gui_debug is not None: run_debug_gui(opts.gui_debug) elif opts.viewer: from calibre.gui2.viewer.main import main main(['ebook-viewer', '--debug-javascript'] + args[1:]) elif opts.py_console: from calibre.utils.pyconsole.main import main main() elif opts.command: sys.argv = args exec(opts.command) elif opts.debug_device_driver: debug_device_driver() elif opts.add_simple_plugin is not None: add_simple_plugin(opts.add_simple_plugin) elif opts.paths: prints('CALIBRE_RESOURCES_PATH=' + sys.resources_location) prints('CALIBRE_EXTENSIONS_PATH=' + sys.extensions_location) prints('CALIBRE_PYTHON_PATH=' + os.pathsep.join(sys.path)) elif opts.reinitialize_db is not None: reinit_db(opts.reinitialize_db) elif opts.inspect_mobi: for path in args[1:]: inspect_mobi(path) elif opts.edit_book: from calibre.gui2.tweak_book.main import main main(['ebook-edit'] + args[1:]) elif opts.explode_book: from calibre.ebooks.tweak import tweak tweak(opts.explode_book) elif opts.test_build: from calibre.test_build import test test() elif opts.shutdown_running_calibre: from calibre.gui2.main import shutdown_other shutdown_other() elif opts.subset_font: from calibre.utils.fonts.sfnt.subset import main main(['subset-font'] + [opts.subset_font] + args[1:]) elif opts.exec_file: run_script(opts.exec_file, args[1:]) elif opts.run_plugin: from calibre.customize.ui import find_plugin plugin = find_plugin(opts.run_plugin) if plugin is None: prints(_('No plugin named %s found') % opts.run_plugin) raise SystemExit(1) plugin.cli_main([plugin.name] + args[1:]) elif opts.diff: from calibre.gui2.tweak_book.diff.main import main main(['calibre-diff'] + args[1:]) elif len(args) >= 2 and args[1].rpartition('.')[-1] in {'py', 'recipe'}: run_script(args[1], args[2:]) elif len(args) >= 2 and args[1].rpartition('.')[-1] in { 'mobi', 'azw', 'azw3', 'docx', 'odt' }: for path in args[1:]: ext = path.rpartition('.')[-1] if ext in {'docx', 'odt'}: from calibre.ebooks.docx.dump import dump dump(path) elif ext in {'mobi', 'azw', 'azw3'}: inspect_mobi(path) else: print('Cannot dump unknown filetype: %s' % path) elif len(args) >= 2 and os.path.exists(os.path.join( args[1], '__main__.py')): sys.path.insert(0, args[1]) run_script(os.path.join(args[1], '__main__.py'), args[2:]) else: from calibre import ipython ipython() return 0
def main(args=sys.argv): from calibre.constants import debug debug() opts, args = option_parser().parse_args(args) if opts.gui: from calibre.gui_launch import calibre calibre(['calibre'] + args[1:]) elif opts.gui_debug is not None: run_debug_gui(opts.gui_debug) elif opts.viewer: from calibre.gui_launch import ebook_viewer ebook_viewer(['ebook-viewer', '--debug-javascript'] + args[1:]) elif opts.command: sys.argv = args exec(opts.command) elif opts.debug_device_driver: debug_device_driver() elif opts.add_simple_plugin is not None: add_simple_plugin(opts.add_simple_plugin) elif opts.paths: prints('CALIBRE_RESOURCES_PATH=' + sys.resources_location) prints('CALIBRE_EXTENSIONS_PATH=' + sys.extensions_location) prints('CALIBRE_PYTHON_PATH=' + os.pathsep.join(sys.path)) elif opts.reinitialize_db is not None: reinit_db(opts.reinitialize_db) elif opts.inspect_mobi: for path in args[1:]: inspect_mobi(path) elif opts.edit_book: from calibre.gui_launch import ebook_edit ebook_edit(['ebook-edit'] + args[1:]) elif opts.explode_book or opts.implode_book: from calibre.ebooks.tweak import explode, implode try: a1, a2 = args[1:] except Exception: raise SystemExit('Must provide exactly two arguments') f = explode if opts.explode_book else implode f(a1, a2) elif opts.test_build: from calibre.test_build import test test() elif opts.shutdown_running_calibre: from calibre.gui2.main import shutdown_other shutdown_other() elif opts.subset_font: from calibre.utils.fonts.sfnt.subset import main main(['subset-font'] + args[1:]) elif opts.exec_file: run_script(opts.exec_file, args[1:]) elif opts.run_plugin: from calibre.customize.ui import find_plugin plugin = find_plugin(opts.run_plugin) if plugin is None: prints(_('No plugin named %s found') % opts.run_plugin) raise SystemExit(1) plugin.cli_main([plugin.name] + args[1:]) elif opts.diff: from calibre.gui2.tweak_book.diff.main import main main(['calibre-diff'] + args[1:]) elif opts.default_programs: if not iswindows: raise SystemExit('Can only be run on Microsoft Windows') if opts.default_programs == 'register': from calibre.utils.winreg.default_programs import register as func else: from calibre.utils.winreg.default_programs import unregister as func print('Running', func.__name__, '...') func() elif opts.export_all_calibre_data: args = args[1:] from calibre.utils.exim import run_exporter run_exporter(args=args) elif opts.import_calibre_data: from calibre.utils.exim import run_importer run_importer() elif len(args) >= 2 and args[1].rpartition('.')[-1] in {'py', 'recipe'}: run_script(args[1], args[2:]) elif len(args) >= 2 and args[1].rpartition('.')[-1] in { 'mobi', 'azw', 'azw3', 'docx', 'odt' }: for path in args[1:]: ext = path.rpartition('.')[-1] if ext in {'docx', 'odt'}: from calibre.ebooks.docx.dump import dump dump(path) elif ext in {'mobi', 'azw', 'azw3'}: inspect_mobi(path) else: print('Cannot dump unknown filetype: %s' % path) elif len(args) >= 2 and os.path.exists(os.path.join( args[1], '__main__.py')): sys.path.insert(0, args[1]) run_script(os.path.join(args[1], '__main__.py'), args[2:]) else: load_user_plugins() from calibre import ipython ipython() return 0
def main(args=sys.argv): from calibre.constants import debug debug() opts, args = option_parser().parse_args(args) if opts.gui: from calibre.gui2.main import main print_basic_debug_info() main(['calibre']) elif opts.gui_debug is not None: run_debug_gui(opts.gui_debug) elif opts.show_gui_debug: import time, re time.sleep(1) from calibre.gui2 import open_local_file if iswindows: with open(opts.show_gui_debug, 'r+b') as f: raw = f.read() raw = re.sub('(?<!\r)\n', '\r\n', raw) f.seek(0) f.truncate() f.write(raw) open_local_file(opts.show_gui_debug) elif opts.viewer: from calibre.gui2.viewer.main import main vargs = ['ebook-viewer', '--debug-javascript'] if len(args) > 1: vargs.append(args[-1]) main(vargs) elif opts.py_console: from calibre.utils.pyconsole.main import main main() elif opts.command: sys.argv = args exec(opts.command) elif opts.debug_device_driver: debug_device_driver() elif opts.add_simple_plugin is not None: add_simple_plugin(opts.add_simple_plugin) elif opts.paths: prints('CALIBRE_RESOURCES_PATH=' + sys.resources_location) prints('CALIBRE_EXTENSIONS_PATH=' + sys.extensions_location) prints('CALIBRE_PYTHON_PATH=' + os.pathsep.join(sys.path)) elif opts.reinitialize_db is not None: reinit_db(opts.reinitialize_db) elif opts.inspect_mobi: for path in args[1:]: inspect_mobi(path) elif opts.edit_book: from calibre.gui2.tweak_book.main import main main(['ebook-edit'] + args[1:]) elif opts.explode_book: from calibre.ebooks.tweak import tweak tweak(opts.explode_book) elif opts.test_build: from calibre.test_build import test test() elif opts.shutdown_running_calibre: from calibre.gui2.main import shutdown_other shutdown_other() elif opts.subset_font: from calibre.utils.fonts.sfnt.subset import main main(['subset-font'] + [opts.subset_font] + args[1:]) elif opts.exec_file: run_script(opts.exec_file, args[1:]) elif opts.run_plugin: from calibre.customize.ui import find_plugin plugin = find_plugin(opts.run_plugin) if plugin is None: prints(_('No plugin named %s found') % opts.run_plugin) raise SystemExit(1) plugin.cli_main([plugin.name] + args[1:]) elif len(args) >= 2 and args[1].rpartition('.')[-1] in {'py', 'recipe'}: run_script(args[1], args[2:]) elif len(args) >= 2 and args[1].rpartition('.')[-1] in { 'mobi', 'azw', 'azw3', 'docx' }: for path in args[1:]: ext = path.rpartition('.')[-1] if ext == 'docx': from calibre.ebooks.docx.dump import dump dump(path) elif ext in {'mobi', 'azw', 'azw3'}: inspect_mobi(path) else: print('Cannot dump unknown filetype: %s' % path) else: from calibre import ipython ipython() return 0
def main(args=sys.argv): from calibre.constants import debug debug() if len(args) > 2 and args[1] in ('-e', '--exec-file'): # Load all plugins user defined plugins so the script can import from the # calibre_plugins namespace import calibre.customize.ui as dummy dummy sys.argv = [args[2]] + args[3:] ef = os.path.abspath(args[2]) base = os.path.dirname(ef) sys.path.insert(0, base) g = globals() g['__name__'] = '__main__' g['__file__'] = ef execfile(ef, g) return if len(args) > 1 and args[1] in ('-f', '--subset-font'): from calibre.utils.fonts.sfnt.subset import main main(['subset-font']+args[2:]) return opts, args = option_parser().parse_args(args) if opts.gui: from calibre.gui2.main import main print_basic_debug_info() main(['calibre']) elif opts.gui_debug is not None: run_debug_gui(opts.gui_debug) elif opts.show_gui_debug: import time, re time.sleep(1) from calibre.gui2 import open_local_file if iswindows: with open(opts.show_gui_debug, 'r+b') as f: raw = f.read() raw = re.sub('(?<!\r)\n', '\r\n', raw) f.seek(0) f.truncate() f.write(raw) open_local_file(opts.show_gui_debug) elif opts.viewer: from calibre.gui2.viewer.main import main vargs = ['ebook-viewer', '--debug-javascript'] if len(args) > 1: vargs.append(args[-1]) main(vargs) elif opts.py_console: from calibre.utils.pyconsole.main import main main() elif opts.command: sys.argv = args exec opts.command elif opts.debug_device_driver: debug_device_driver() elif opts.add_simple_plugin is not None: add_simple_plugin(opts.add_simple_plugin) elif opts.paths: prints('CALIBRE_RESOURCES_PATH='+sys.resources_location) prints('CALIBRE_EXTENSIONS_PATH='+sys.extensions_location) prints('CALIBRE_PYTHON_PATH='+os.pathsep.join(sys.path)) elif opts.reinitialize_db is not None: sql_dump = None if len(args) > 1 and os.access(args[-1], os.R_OK): sql_dump = args[-1] reinit_db(opts.reinitialize_db, sql_dump=sql_dump) elif opts.inspect_mobi: from calibre.ebooks.mobi.debug.main import inspect_mobi for path in args[1:]: prints('Inspecting:', path) inspect_mobi(path) print elif opts.tweak_book: from calibre.ebooks.tweak import tweak tweak(opts.tweak_book) elif opts.test_build: from calibre.test_build import test test() elif opts.shutdown_running_calibre: from calibre.gui2.main import shutdown_other shutdown_other() else: from calibre import ipython ipython() return 0