def _add_platform_profile(): # Platform info import platform from calibre.constants import (__appname__, get_version, isportable, isosx, isfrozen, is64bit, iswindows) calibre_profile = "{0} {1}{2} isfrozen:{3} is64bit:{4}".format( __appname__, get_version(), ' Portable' if isportable else '', isfrozen, is64bit) device_profile['CalibreProfile'] = calibre_profile platform_profile = "{0} {1} {2}".format( platform.platform(), platform.system(), platform.architecture()) device_profile['PlatformProfile'] = platform_profile try: if iswindows: os_profile = "Windows {0}".format(platform.win32_ver()) if not is64bit: try: import win32process if win32process.IsWow64Process(): os_profile += " 32bit process running on 64bit windows" except: pass elif isosx: os_profile = "OS X {0}".format(platform.mac_ver()[0]) else: os_profile = "Linux {0}".format(platform.linux_distribution()) except: import traceback self._log(traceback.format_exc()) os_profile = "unknown" device_profile['OSProfile'] = os_profile
def print_basic_debug_info(out=None): if out is None: out = sys.stdout out = functools.partial(prints, file=out) import platform from calibre.constants import (__appname__, get_version, isportable, isosx, isfrozen, is64bit) out(__appname__, get_version(), 'Portable' if isportable else '', 'isfrozen:', isfrozen, 'is64bit:', is64bit) out(platform.platform(), platform.system(), platform.architecture()) if iswindows and not is64bit: try: import win32process if win32process.IsWow64Process(): out('32bit process running on 64bit windows') except: pass out(platform.system_alias(platform.system(), platform.release(), platform.version())) out('Python', platform.python_version()) try: if iswindows: out('Windows:', platform.win32_ver()) elif isosx: out('OSX:', platform.mac_ver()) else: out('Linux:', platform.linux_distribution()) except: pass from calibre.customize.ui import has_external_plugins, initialized_plugins if has_external_plugins(): names = (p.name for p in initialized_plugins() if getattr(p, 'plugin_path', None) is not None) out('Successfully initialized third party plugins:', ' && '.join(names))
def print_basic_debug_info(out=None): if out is None: out = sys.stdout out = functools.partial(prints, file=out) import platform from contextlib import suppress from calibre.constants import (__appname__, get_version, isportable, ismacos, isfrozen, is64bit) from calibre.utils.localization import set_translators out(__appname__, get_version(), 'Portable' if isportable else '', 'embedded-python:', isfrozen, 'is64bit:', is64bit) out(platform.platform(), platform.system(), platform.architecture()) if iswindows and not is64bit: from calibre_extensions.winutil import is_wow64_process with suppress(Exception): if is_wow64_process(): out('32bit process running on 64bit windows') out(platform.system_alias(platform.system(), platform.release(), platform.version())) out('Python', platform.python_version()) try: if iswindows: out('Windows:', platform.win32_ver()) elif ismacos: out('OSX:', platform.mac_ver()) else: out('Linux:', platform.linux_distribution()) except: pass out('Interface language:', unicode_type(set_translators.lang)) from calibre.customize.ui import has_external_plugins, initialized_plugins if has_external_plugins(): names = ('{0} {1}'.format(p.name, p.version) for p in initialized_plugins() if getattr(p, 'plugin_path', None) is not None) out('Successfully initialized third party plugins:', ' && '.join(names))
def ipython(user_ns=None): try: import IPython from IPython.config.loader import Config except ImportError: return simple_repl(user_ns=user_ns) defns = {'os':os, 're':re, 'sys':sys} if not user_ns: user_ns = defns else: defns.update(user_ns) user_ns = defns c = Config() c.InteractiveShellApp.exec_lines = [ 'from __future__ import division, absolute_import, unicode_literals, print_function', ] c.TerminalInteractiveShell.confirm_exit = False c.PromptManager.in_template = (r'{color.LightGreen}calibre ' '{color.LightBlue}[{color.LightCyan}%s{color.LightBlue}]' r'{color.Green}|\#> '%get_version()) c.PromptManager.in2_template = r'{color.Green}|{color.LightGreen}\D{color.Green}> ' c.PromptManager.out_template = r'<\#> ' c.TerminalInteractiveShell.banner1 = BANNER c.PromptManager.justify = True c.TerminalIPythonApp.ipython_dir = ipydir os.environ['IPYTHONDIR'] = ipydir c.InteractiveShell.separate_in = '' c.InteractiveShell.separate_out = '' c.InteractiveShell.separate_out2 = '' c.PrefilterManager.multi_line_specials = True IPython.embed(config=c, user_ns=user_ns)
def print_basic_debug_info(out=None): if out is None: out = sys.stdout out = functools.partial(prints, file=out) import platform from calibre.constants import (__appname__, get_version, isportable, isosx, isfrozen, is64bit) out(__appname__, get_version(), 'Portable' if isportable else '', 'isfrozen:', isfrozen, 'is64bit:', is64bit) out(platform.platform(), platform.system(), platform.architecture()) if iswindows and not is64bit: try: import win32process if win32process.IsWow64Process(): out('32bit process running on 64bit windows') except: pass out(platform.system_alias(platform.system(), platform.release(), platform.version())) out('Python', platform.python_version()) try: if iswindows: out('Windows:', platform.win32_ver()) elif isosx: out('OSX:', platform.mac_ver()) else: out('Linux:', platform.linux_distribution()) except: pass
def __init__(self, parent=None): QStatusBar.__init__(self, parent) self.base_msg = '%s %s' % (__appname__, get_version()) self.version = get_version() self.device_string = '' self.update_label = UpdateLabel('') self.total = self.current = self.selected = self.library_total = 0 self.addPermanentWidget(self.update_label) self.update_label.setVisible(False) self._font = QFont() self._font.setBold(True) self.setFont(self._font) self.defmsg = QLabel('') self.defmsg.setFont(self._font) self.addWidget(self.defmsg) self.set_label()
def __init__(self, usage='%prog [options] filename', version=None, epilog=None, gui_mode=False, conflict_handler='resolve', **kwds): import textwrap from calibre.utils.terminal import colored usage = textwrap.dedent(usage) if epilog is None: epilog = _('Created by ')+colored(__author__, fg='cyan') usage += '\n\n'+_('''Whenever you pass arguments to %prog that have spaces in them, ''' '''enclose the arguments in quotation marks. For example: "{}"''').format( "C:\\some path with spaces" if iswindows else '/some path/with spaces') +'\n' if version is None: version = '%%prog (%s %s)'%(__appname__, get_version()) optparse.OptionParser.__init__(self, usage=usage, version=version, epilog=epilog, formatter=CustomHelpFormatter(), conflict_handler=conflict_handler, **kwds) self.gui_mode = gui_mode if False: # Translatable string from optparse _("Options") _("show this help message and exit") _("show program's version number and exit")
def print_basic_debug_info(out=None): if out is None: out = sys.stdout out = functools.partial(prints, file=out) import platform from calibre.constants import (__appname__, get_version, isportable, isosx, isfrozen, is64bit) out(__appname__, get_version(), 'Portable' if isportable else '', 'embedded-python:', isfrozen, 'is64bit:', is64bit) out(platform.platform(), platform.system(), platform.architecture()) if iswindows and not is64bit: try: import win32process if win32process.IsWow64Process(): out('32bit process running on 64bit windows') except: pass out(platform.system_alias(platform.system(), platform.release(), platform.version())) out('Python', platform.python_version()) try: if iswindows: out('Windows:', platform.win32_ver()) elif isosx: out('OSX:', platform.mac_ver()) else: out('Linux:', platform.linux_distribution()) except: pass from calibre.customize.ui import has_external_plugins, initialized_plugins if has_external_plugins(): names = (p.name for p in initialized_plugins() if getattr(p, 'plugin_path', None) is not None) out('Successfully initialized third party plugins:', ' && '.join(names))
def __init__(self, usage='%prog [options] filename', version=None, epilog=None, gui_mode=False, conflict_handler='resolve', **kwds): import textwrap from calibre.utils.terminal import colored usage = textwrap.dedent(usage) if epilog is None: epilog = _('Created by ') + colored(__author__, fg='cyan') usage += '\n\n' + _( '''Whenever you pass arguments to %prog that have spaces in them, ''' '''enclose the arguments in quotation marks. For example: "{}"''' ).format("C:\\some path with spaces" if iswindows else '/some path/with spaces') + '\n' if version is None: version = '%%prog (%s %s)' % (__appname__, get_version()) optparse.OptionParser.__init__(self, usage=usage, version=version, epilog=epilog, formatter=CustomHelpFormatter(), conflict_handler=conflict_handler, **kwds) self.gui_mode = gui_mode if False: # Translatable string from optparse _("Options") _("show this help message and exit") _("show program's version number and exit")
def ipython(user_ns=None): try: import IPython from IPython.config.loader import Config except ImportError: return simple_repl(user_ns=user_ns) if not user_ns: user_ns = {} c = Config() c.InteractiveShellApp.exec_lines = [ 'from __future__ import division, absolute_import, unicode_literals, print_function', ] c.TerminalInteractiveShell.confirm_exit = False c.PromptManager.in_template = ( r'{color.LightGreen}calibre ' '{color.LightBlue}[{color.LightCyan}%s{color.LightBlue}]' r'{color.Green}|\#> ' % get_version()) c.PromptManager.in2_template = r'{color.Green}|{color.LightGreen}\D{color.Green}> ' c.PromptManager.out_template = r'<\#> ' c.TerminalInteractiveShell.banner1 = BANNER c.PromptManager.justify = True c.TerminalIPythonApp.ipython_dir = ipydir os.environ['IPYTHONDIR'] = ipydir c.InteractiveShell.separate_in = '' c.InteractiveShell.separate_out = '' c.InteractiveShell.separate_out2 = '' c.PrefilterManager.multi_line_specials = True IPython.embed(config=c, user_ns=user_ns)
def report_version(self, log): try: platform_info = platform.platform() except Exception: platform_info = sys.platform # handle failure to retrieve platform seen on linux log.info("Software versions: %s %s, calibre %s, %s" % (self.name, ".".join([str(v) for v in self.version]), get_version(), platform_info)) log.info("KFX Output plugin help is available at http://www.mobileread.com/forums/showthread.php?t=272407")
def __init__(self, opts, notify=None): MainWindow.__init__(self, opts, disable_automatic_gc=True) try: install_new_plugins() except Exception: import traceback traceback.print_exc() self.setWindowTitle(self.APP_NAME) self.boss = Boss(self, notify=notify) self.setWindowIcon(QIcon(I('tweak.png'))) self.opts = opts self.path_to_ebook = None self.container = None self.current_metadata = None self.blocking_job = BlockingJob(self) self.keyboard = KeyboardManager(self, config_name='shortcuts/tweak_book') self.central = Central(self) self.setCentralWidget(self.central) self.check_book = Check(self) self.spell_check = SpellCheck(parent=self) self.toc_view = TOCViewer(self) self.text_search = TextSearch(self) self.saved_searches = SavedSearches(self) self.image_browser = InsertImage(self, for_browsing=True) self.reports = Reports(self) self.check_external_links = CheckExternalLinks(self) self.insert_char = CharSelect(self) self.manage_fonts = ManageFonts(self) self.sr_debug_output = DebugOutput(self) self.create_actions() self.create_toolbars() self.create_docks() self.create_menubar() self.status_bar = self.statusBar() self.status_bar.addPermanentWidget( self.boss.save_manager.status_widget) self.cursor_position_widget = CursorPositionWidget(self) self.status_bar.addPermanentWidget(self.cursor_position_widget) self.status_bar_default_msg = la = QLabel( ' ' + _('{0} {1} created by {2}').format( __appname__, get_version(), 'Kovid Goyal')) la.base_template = unicode_type(la.text()) self.status_bar.addWidget(la) f = self.status_bar.font() f.setBold(True) self.status_bar.setFont(f) self.boss(self) g = QApplication.instance().desktop().availableGeometry(self) self.resize(g.width() - 50, g.height() - 50) self.restore_state() self.apply_settings()
def __init__(self, parent=None): QStatusBar.__init__(self, parent) self.version = get_version() self.base_msg = f'{get_appname_for_display()} {self.version}' self.device_string = '' self.update_label = UpdateLabel('') self.total = self.current = self.selected = self.library_total = 0 self.addPermanentWidget(self.update_label) self.update_label.setVisible(False) self.defmsg = VersionLabel(self) self.addWidget(self.defmsg) self.set_label()
def __init__(self, opts, notify=None): MainWindow.__init__(self, opts, disable_automatic_gc=True) self.boss = Boss(self, notify=notify) self.setWindowTitle(self.APP_NAME) self.setWindowIcon(QIcon(I("tweak.png"))) self.opts = opts self.path_to_ebook = None self.container = None self.current_metadata = None self.blocking_job = BlockingJob(self) self.keyboard = KeyboardManager(self, config_name="shortcuts/tweak_book") self.central = Central(self) self.setCentralWidget(self.central) self.check_book = Check(self) self.spell_check = SpellCheck(parent=self) self.toc_view = TOCViewer(self) self.saved_searches = SavedSearches(self) self.image_browser = InsertImage(self, for_browsing=True) self.insert_char = CharSelect(self) self.manage_fonts = ManageFonts(self) self.create_actions() self.create_toolbars() self.create_docks() self.create_menubar() self.status_bar = self.statusBar() self.status_bar.addPermanentWidget(self.boss.save_manager.status_widget) self.cursor_position_widget = CursorPositionWidget(self) self.status_bar.addPermanentWidget(self.cursor_position_widget) self.status_bar_default_msg = la = QLabel( _("{0} {1} created by {2}").format(__appname__, get_version(), "Kovid Goyal") ) la.base_template = unicode(la.text()) self.status_bar.addWidget(la) f = self.status_bar.font() f.setBold(True) self.status_bar.setFont(f) self.boss(self) g = QApplication.instance().desktop().availableGeometry(self) self.resize(g.width() - 50, g.height() - 50) self.restore_state() self.apply_settings()
def __init__(self, parent=None): QStatusBar.__init__(self, parent) self.version = get_version() self.base_msg = "%s %s" % (__appname__, self.version) if tweaks.get("use_new_db", False): self.base_msg += " [newdb]" self.device_string = "" self.update_label = UpdateLabel("") self.total = self.current = self.selected = self.library_total = 0 self.addPermanentWidget(self.update_label) self.update_label.setVisible(False) self._font = QFont() self._font.setBold(True) self.setFont(self._font) self.defmsg = QLabel("") self.defmsg.setFont(self._font) self.addWidget(self.defmsg) self.set_label()
def print_basic_debug_info(out=None): if out is None: out = sys.stdout out = functools.partial(prints, file=out) import platform from calibre.constants import __appname__, get_version, isportable, isosx out(__appname__, get_version(), 'Portable' if isportable else '') out(platform.platform(), platform.system()) out(platform.system_alias(platform.system(), platform.release(), platform.version())) out('Python', platform.python_version()) try: if iswindows: out('Windows:', platform.win32_ver()) elif isosx: out('OSX:', platform.mac_ver()) else: out('Linux:', platform.linux_distribution()) except: pass
def __init__(self, opts, notify=None): MainWindow.__init__(self, opts, disable_automatic_gc=True) self.boss = Boss(self, notify=notify) self.setWindowTitle(self.APP_NAME) self.setWindowIcon(QIcon(I('tweak.png'))) self.opts = opts self.path_to_ebook = None self.container = None self.current_metadata = None self.blocking_job = BlockingJob(self) self.keyboard = KeyboardManager(self, config_name='shortcuts/tweak_book') self.central = Central(self) self.setCentralWidget(self.central) self.check_book = Check(self) self.toc_view = TOCViewer(self) self.create_actions() self.create_toolbars() self.create_docks() self.create_menubar() self.status_bar = self.statusBar() self.status_bar.addPermanentWidget( self.boss.save_manager.status_widget) self.cursor_position_widget = CursorPositionWidget(self) self.status_bar.addPermanentWidget(self.cursor_position_widget) self.status_bar.addWidget( QLabel( _('{0} {1} created by {2}').format(__appname__, get_version(), 'Kovid Goyal'))) f = self.status_bar.font() f.setBold(True) self.status_bar.setFont(f) self.boss(self) g = QApplication.instance().desktop().availableGeometry(self) self.resize(g.width() - 50, g.height() - 50) self.restore_state() self.keyboard.finalize()
def print_basic_debug_info(out=None): if out is None: out = sys.stdout out = functools.partial(prints, file=out) import platform from calibre.constants import __appname__, get_version, isportable, isosx, isfrozen, is64bit out(__appname__, get_version(), "Portable" if isportable else "", "isfrozen:", isfrozen, "is64bit:", is64bit) out(platform.platform(), platform.system(), platform.architecture()) out(platform.system_alias(platform.system(), platform.release(), platform.version())) out("Python", platform.python_version()) try: if iswindows: out("Windows:", platform.win32_ver()) elif isosx: out("OSX:", platform.mac_ver()) else: out("Linux:", platform.linux_distribution()) except: pass
def get_version(self): return get_version()
print_function) import os, subprocess, errno, shutil, tempfile, sys from io import BytesIO from threading import Thread from PyQt5.Qt import QImage, QByteArray, QBuffer, Qt, QImageReader, QColor, QImageWriter, QTransform from calibre import fit_image, force_unicode from calibre.constants import iswindows, plugins, get_version from calibre.utils.config_base import tweaks from calibre.utils.filenames import atomic_rename # Utilities {{{ imageops, imageops_err = plugins['imageops'] if imageops is None: if '*' in get_version(): raise RuntimeError('You are running from source, which requires the new binary module, imageops. You can' ' get it by installing the betas from: http://www.mobileread.com/forums/showthread.php?t=274030') raise RuntimeError(imageops_err) class NotImage(ValueError): pass def normalize_format_name(fmt): fmt = fmt.lower() if fmt == 'jpg': fmt = 'jpeg' return fmt def get_exe_path(name): from calibre.ebooks.pdf.pdftohtml import PDFTOHTML
from __future__ import (unicode_literals, division, absolute_import, print_function) import os, subprocess, errno, shutil, tempfile, sys from io import BytesIO from threading import Thread from PyQt5.Qt import QImage, QByteArray, QBuffer, Qt, QImageReader, QColor, QImageWriter, QTransform from calibre import fit_image, force_unicode from calibre.constants import iswindows, plugins, get_version from calibre.utils.config_base import tweaks from calibre.utils.filenames import atomic_rename # Utilities {{{ imageops, imageops_err = plugins['imageops'] if imageops is None: if '*' in get_version(): raise RuntimeError( 'You are running from source, which requires the new binary module, imageops. You can' ' get it by installing the betas from: http://www.mobileread.com/forums/showthread.php?t=274030' ) raise RuntimeError(imageops_err) class NotImage(ValueError): pass def normalize_format_name(fmt): fmt = fmt.lower() if fmt == 'jpg': fmt = 'jpeg'
def in_prompt_tokens(self, cli=None): return [ (Token.Prompt, 'calibre['), (Token.PromptNum, get_version()), (Token.Prompt, ']> '), ]
def __init__(self, opts, notify=None): MainWindow.__init__(self, opts, disable_automatic_gc=True) self.boss = Boss(self, notify=notify) self.setWindowTitle(self.APP_NAME) self.setWindowIcon(QIcon(I('tweak.png'))) self.opts = opts self.path_to_ebook = None self.container = None self.current_metadata = None self.blocking_job = BlockingJob(self) self.keyboard = KeyboardManager(self, config_name='shortcuts/tweak_book') self.central = Central(self) self.setCentralWidget(self.central) self.check_book = Check(self) self.toc_view = TOCViewer(self) self.create_actions() self.create_toolbars() self.create_docks() self.create_menubar() self.status_bar = self.statusBar() self.status_bar.addPermanentWidget(self.boss.save_manager.status_widget) self.cursor_position_widget = CursorPositionWidget(self) self.status_bar.addPermanentWidget(self.cursor_position_widget) self.status_bar.addWidget(QLabel(_('{0} {1} created by {2}').format(__appname__, get_version(), 'Kovid Goyal'))) f = self.status_bar.font() f.setBold(True) self.status_bar.setFont(f) self.boss(self) g = QApplication.instance().desktop().availableGeometry(self) self.resize(g.width()-50, g.height()-50) self.restore_state() self.keyboard.finalize()