From 4dff7ecf95f0fa2ab160fa1831cfbfb776996759 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 5 Aug 2008 22:33:19 -0700 Subject: [PATCH] Switch to using lit2oeb to explode LIT files. --- installer/linux/freeze.py | 3 +- installer/osx/freeze.py | 6 ---- installer/windows/freeze.py | 3 -- pyqtdistutils.py | 2 +- src/calibre/ebooks/lrf/lit/convert_from.py | 38 ++-------------------- src/calibre/trac/plugins/download.py | 6 +--- upload.py | 2 +- 7 files changed, 7 insertions(+), 53 deletions(-) diff --git a/installer/linux/freeze.py b/installer/linux/freeze.py index f33b059903..f32286092a 100644 --- a/installer/linux/freeze.py +++ b/installer/linux/freeze.py @@ -10,7 +10,6 @@ import glob, sys, subprocess, tarfile, os, re, py_compile, shutil HOME = '/home/kovid' PYINSTALLER = os.path.expanduser('~/build/pyinstaller') CALIBREPREFIX = '___' -CLIT = '/usr/bin/clit' PDFTOHTML = '/usr/bin/pdftohtml' LIBUNRAR = '/usr/lib/libunrar.so' QTDIR = '/usr/lib/qt4' @@ -117,7 +116,7 @@ for f in glob.glob(os.path.join(CALIBREPLUGINS, '*.so.*')): binaries += [(os.path.basename(f), f, 'BINARY')] print 'Adding external programs...' -binaries += [('clit', CLIT, 'BINARY'), ('pdftohtml', PDFTOHTML, 'BINARY'), +binaries += [('pdftohtml', PDFTOHTML, 'BINARY'), ('libunrar.so', LIBUNRAR, 'BINARY')] print 'Adding external libraries...' diff --git a/installer/osx/freeze.py b/installer/osx/freeze.py index 30fd2647a2..a57b3ce375 100644 --- a/installer/osx/freeze.py +++ b/installer/osx/freeze.py @@ -244,12 +244,6 @@ _check_symlinks_prescript() print - print 'Adding clit' - os.link(os.path.expanduser('~/clit'), os.path.join(frameworks_dir, 'clit')) - print - print 'Adding unrtf' - os.link(os.path.expanduser('~/unrtf'), os.path.join(frameworks_dir, 'unrtf')) - print print 'Adding pdftohtml' os.link(os.path.expanduser('~/pdftohtml'), os.path.join(frameworks_dir, 'pdftohtml')) print 'Adding plugins' diff --git a/installer/windows/freeze.py b/installer/windows/freeze.py index 8d7f53228e..63de45ebc2 100644 --- a/installer/windows/freeze.py +++ b/installer/windows/freeze.py @@ -10,7 +10,6 @@ QT_DIR = 'C:\\Qt\\4.4.0' DEVCON = 'C:\\devcon\\i386\\devcon.exe' LIBUSB_DIR = 'C:\\libusb' LIBUNRAR = 'C:\\Program Files\\UnrarDLL\\unrar.dll' -CLIT = 'C:\\clit\\clit.exe' PDFTOHTML = 'C:\\pdftohtml\\pdftohtml.exe' IMAGEMAGICK_DIR = 'C:\\ImageMagick' FONTCONFIG_DIR = 'C:\\fontconfig' @@ -105,8 +104,6 @@ class BuildEXE(py2exe.build_exe.py2exe): shutil.copyfile(DEVCON, os.path.join(tdir, os.path.basename(DEVCON))) print '\tAdding unrar' shutil.copyfile(LIBUNRAR, os.path.join(PY2EXE_DIR, os.path.basename(LIBUNRAR))) - print '\tAdding ConvertLIT' - shutil.copyfile(CLIT, os.path.join(PY2EXE_DIR, os.path.basename(CLIT))) print '\tAdding pdftohtml' shutil.copyfile(PDFTOHTML, os.path.join(PY2EXE_DIR, os.path.basename(PDFTOHTML))) print '\tAdding ImageMagick' diff --git a/pyqtdistutils.py b/pyqtdistutils.py index 9c225dcf20..f80486e314 100644 --- a/pyqtdistutils.py +++ b/pyqtdistutils.py @@ -98,7 +98,7 @@ CONFIG += x86 ppc def build_extension(self, ext): - self.inplace = True + self.inplace = True # Causes extensions to be built in the source tree if not isinstance(ext, PyQtExtension): return _build_ext.build_extension(self, ext) diff --git a/src/calibre/ebooks/lrf/lit/convert_from.py b/src/calibre/ebooks/lrf/lit/convert_from.py index 987fd97354..2f2e591b37 100644 --- a/src/calibre/ebooks/lrf/lit/convert_from.py +++ b/src/calibre/ebooks/lrf/lit/convert_from.py @@ -3,19 +3,12 @@ __copyright__ = '2008, Kovid Goyal ' import os, sys, shutil, glob, logging from tempfile import mkdtemp -from subprocess import Popen, PIPE from calibre.ebooks.lrf import option_parser as lrf_option_parser from calibre.ebooks.lit.reader import LitReader from calibre.ebooks import ConversionError from calibre.ebooks.lrf.html.convert_from import process_file as html_process_file from calibre.ebooks.metadata.opf import OPFReader -from calibre import isosx, __appname__, setup_cli_handlers, islinux - -CLIT = 'clit' -if isosx and hasattr(sys, 'frameworks_dir'): - CLIT = os.path.join(getattr(sys, 'frameworks_dir'), CLIT) -if islinux and getattr(sys, 'frozen_path', False): - CLIT = os.path.join(getattr(sys, 'frozen_path'), 'clit') +from calibre import __appname__, setup_cli_handlers def option_parser(): parser = lrf_option_parser( @@ -24,11 +17,9 @@ _('''Usage: %prog [options] mybook.lit %prog converts mybook.lit to mybook.lrf''') ) - parser.add_option('--lit2oeb', default=False, dest='lit2oeb', action='store_true', - help='Use the new lit2oeb to convert lit files instead of convertlit.') return parser -def generate_html2(pathtolit, logger): +def generate_html(pathtolit, logger): if not os.access(pathtolit, os.R_OK): raise ConversionError, 'Cannot read from ' + pathtolit tdir = mkdtemp(prefix=__appname__+'_'+'lit2oeb_') @@ -37,36 +28,13 @@ def generate_html2(pathtolit, logger): lr.extract_content(tdir) return tdir -def generate_html(pathtolit, logger): - if isinstance(pathtolit, unicode): - pathtolit = pathtolit.encode(sys.getfilesystemencoding()) - if not os.access(pathtolit, os.R_OK): - raise ConversionError, 'Cannot read from ' + pathtolit - tdir = mkdtemp(prefix=__appname__+'_') - os.rmdir(tdir) - cmd = [CLIT, pathtolit, '%s'%(tdir+os.sep)] - logger.debug(repr(cmd)) - p = Popen(cmd, stderr=PIPE, stdout=PIPE) - stdout = p.stdout.read() - err = p.stderr.read() - logger.info(p.stdout.read()) - ret = p.wait() - if ret != 0: - if os.path.exists(tdir) and os.path.isdir(tdir): - shutil.rmtree(tdir) - if 'keys.txt' in unicode(err)+unicode(stdout): - raise ConversionError('This lit file is protected by DRM. You must first use the ConvertLIT program to remove the DRM. Doing so may be illegal, and so %s does not do this, nor does it provide instructions on how to do it.'%(__appname__,)) - raise ConversionError, err - return tdir - def process_file(path, options, logger=None): if logger is None: level = logging.DEBUG if options.verbose else logging.INFO logger = logging.getLogger('lit2lrf') setup_cli_handlers(logger, level) lit = os.path.abspath(os.path.expanduser(path)) - tdir = generate_html2(lit, logger) if getattr(options, 'lit2oeb', False) \ - else generate_html(lit, logger) + tdir = generate_html(lit, logger) try: opf = glob.glob(os.path.join(tdir, '*.opf')) if opf: diff --git a/src/calibre/trac/plugins/download.py b/src/calibre/trac/plugins/download.py index ed9a8483a0..15ee30b09a 100644 --- a/src/calibre/trac/plugins/download.py +++ b/src/calibre/trac/plugins/download.py @@ -35,7 +35,6 @@ class Distribution(object): ('ImageMagick', '6.3.5', 'imagemagick', 'imagemagick', 'ImageMagick'), ('xdg-utils', '1.0.2', 'xdg-utils', 'xdg-utils', 'xdg-utils'), ('dbus-python', '0.82.2', 'dbus-python', 'python-dbus', 'dbus-python'), - ('convertlit', '1.8', 'convertlit', None, None), ('lxml', '1.3.3', 'lxml', 'python-lxml', 'python-lxml'), ('help2man', '1.36.4', 'help2man', 'help2man', 'help2man'), ] @@ -49,10 +48,7 @@ class Distribution(object): 'fedora':'Fedora 8', 'debian':'Debian Sid', 'generic': 'Generic Unix'} MANUAL_MAP = { - 'ubuntu' : '
  • You will have to install convertlit manually to be able to convert LIT files.
  • ', - 'fedora' : '''
  • You have to upgrade Qt to at least 4.3.1 and PyQt to at least 4.3.1
  • '''\ - '''
  • You will have to install convertlit manually to be able to convert LIT files.
  • ''', - 'debian' : '
  • Add the following to /etc/apt/sources.list
    deb http://www.debian-multimedia.org sid main
    Then
    apt-get install clit
  • ', + 'fedora' : '''
  • You have to upgrade Qt to at least 4.4.0 and PyQt to at least 4.4.2
  • ''', } def __init__(self, os): diff --git a/upload.py b/upload.py index f6df21b484..0cc4d99e61 100644 --- a/upload.py +++ b/upload.py @@ -220,7 +220,7 @@ def stage_one(): os.mkdir('build') shutil.rmtree('docs') os.mkdir('docs') - subprocess.call('python setup.py develop', shell=True) + check_call('python setup.py build', shell=True) check_call('sudo python setup.py develop', shell=True) check_call('make', shell=True) tag_release()