From fc9053e90743aa5faed8b0cd067c0b1ebf8a21f0 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 28 Aug 2009 10:53:07 -0600 Subject: [PATCH] IGN:Switch back to old windows builder. Also fix some dependencies so the calibre binary runs again in Ubuntu --- installer/linux/freeze.py | 1 - installer/windows/calibre/calibre.mpi | 19 +++--- installer/windows/freeze.py | 41 +++++++----- setup.py | 17 +++-- src/calibre/gui2/convert/debug.py | 2 + .../recipes/recipe_scientific_american.py | 64 +++++++++++-------- upload.py | 20 +++--- 7 files changed, 95 insertions(+), 69 deletions(-) diff --git a/installer/linux/freeze.py b/installer/linux/freeze.py index c43c3f0ec5..ff58f07dfc 100644 --- a/installer/linux/freeze.py +++ b/installer/linux/freeze.py @@ -45,7 +45,6 @@ def freeze(): '/usr/lib/libpoppler.so.4', '/usr/lib/libpoppler-qt4.so.3', '/usr/lib/libxml2.so.2', - '/usr/lib/libdbus-1.so.3', '/usr/lib/libopenjpeg.so.2', '/usr/lib/libxslt.so.1', '/usr/lib64/libjpeg.so.7'.replace('64', '64' if is64bit diff --git a/installer/windows/calibre/calibre.mpi b/installer/windows/calibre/calibre.mpi index 42f30224b0..a371bb9587 100644 --- a/installer/windows/calibre/calibre.mpi +++ b/installer/windows/calibre/calibre.mpi @@ -232,10 +232,12 @@ test } FileGroup ::BEF8D398-58BA-1F66-39D6-D4A63D5BEEF9 -setup Install -active Yes -platforms {AIX-ppc FreeBSD-4-x86 FreeBSD-x86 HPUX-hppa Linux-x86 Solaris-sparc Windows TarArchive ZipArchive FreeBSD-5-x86 FreeBSD-6-x86 FreeBSD-7-x86 Linux-x86_64 Solaris-x86} -name {Program Files} -parent FileGroups File ::8E5D85A4-7608-47A1-CF7C-309060D5FF40 -filemethod {Always overwrite files} -type dir -directory <%InstallDir%> -name /home/kovid/work/calibre/build/py2exe -parent BEF8D398-58BA-1F66-39D6-D4A63D5BEEF9 +File ::FC870EE7-667B-481F-113B-B4504DFCCFA5 -type dir -name bin -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 File ::377C588B-B324-CA09-ED49-4DB5F82A15ED -type dir -name etc -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 File ::55DE4B9F-0881-FF51-E2BA-EC72B5D3425C -type dir -name fonts -parent 377C588B-B324-CA09-ED49-4DB5F82A15ED File ::A27B68D9-43A6-B994-3091-E829AFBA340D -type dir -name conf.d -parent 55DE4B9F-0881-FF51-E2BA-EC72B5D3425C File ::974ADD48-88E5-BC7A-1963-928A245F133A -type dir -name conf.avail -parent 55DE4B9F-0881-FF51-E2BA-EC72B5D3425C +File ::5E5273D8-3423-8DC8-83C4-BE000069A803 -name fonts.dtd -parent 55DE4B9F-0881-FF51-E2BA-EC72B5D3425C File ::32D7DBE0-E0B1-5BDD-66C5-2A13D8BC8F90 -name fonts.conf -parent 55DE4B9F-0881-FF51-E2BA-EC72B5D3425C File ::B95D03D4-EA59-F00E-59E1-BA05758879DA -type dir -name imageformats -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 File ::A624029D-AE0F-49A5-4DAC-7720CDCAB271 -name qmng4.dll -parent B95D03D4-EA59-F00E-59E1-BA05758879DA @@ -335,6 +337,7 @@ File ::2F90282D-B59F-B6BA-090B-45858AF7F3B2 -name IM_MOD_RL_clipboard_.dll -pare File ::B512D139-B295-D7C3-F0B4-43775849CF58 -name numpy.core._sort.pyd -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 File ::A2C063AC-2F12-9260-501A-0E8BD0B8A932 -name calibre.exe.local -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 File ::439B6D05-7DE6-061D-4BCC-3F04F4FA2FA2 -name IM_MOD_RL_png_.dll -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 +File ::BA464D11-BBCE-DEDA-C354-0C7BE60FAA05 -name IM_MOD_RL_braille_.dll -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 File ::8F9FF823-AF6D-A288-8AE6-7D74F55DCE29 -name CORE_RL_bzlib_.dll -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 File ::57A3F5D5-BFC8-CB38-5A57-548EE0DB033B -name QtNetwork4.dll -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 File ::4DB7E8DE-905A-822A-AF14-17BD5ACEF915 -name IM_MOD_RL_wmf_.dll -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 @@ -358,6 +361,7 @@ File ::A6419A84-6C22-784E-6D84-D09972770770 -name unicodedata.pyd -parent 8E5D85 File ::E658FBE0-5860-D041-12D3-76ADD18F804B -name servicemanager.pyd -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 File ::C98A6FC4-E341-7FD4-005C-DA2B384E11D8 -name win32api.pyd -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 File ::ADA36EEA-7DE1-447C-B1AB-A4908E65E2CD -name IM_MOD_RL_ipl_.dll -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 +File ::53C2EC15-850F-8F49-6425-C228FB6E6D0E -name libfontconfig-1.dll -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 File ::EDE6F457-C83F-C5FA-9AF4-38FDFF17D929 -name PIL._imagingtk.pyd -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 File ::09D0906E-3611-3DB7-32CF-A140585694A7 -name win32pdh.pyd -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 File ::4C84F0DC-7157-0C90-2062-180139B03E25 -name IM_MOD_RL_rgb_.dll -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 @@ -380,14 +384,17 @@ File ::404A98F1-84FD-B6D0-B130-354EECD9253C -name IM_MOD_RL_emf_.dll -parent 8E5 File ::17034C34-403E-B405-99C1-F80B7F00E27C -name log.xml -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 File ::34E63A2C-65C5-0A84-ACF1-BD6A844D4579 -name pythoncom26.dll -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 File ::2F20484B-53B8-B08E-B691-C5B2D49A9CB4 -name QtWebKit4.dll -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 +File ::8AF134C8-9189-3F9A-A081-9143FFD44C45 -name freetype6.dll -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 File ::E8A4442D-D0D3-31CD-997A-3CEB641CF5B7 -name IM_MOD_RL_mtv_.dll -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 File ::0CA87D0B-5A04-1439-AEE8-C97072D47BA7 -name CORE_RL_tiff_.dll -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 File ::AC24F520-88D4-D1CF-5797-27C715CE8ACA -name pyexpat.pyd -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 File ::16848F38-71CD-55B8-4D96-1537F6773744 -name IM_MOD_RL_dps_.dll -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 +File ::33A46CC5-BAC4-5863-C83D-303DCCA0CAA1 -name tk85.dll -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 File ::81116DD3-1715-AA87-472F-544FC616EDAF -name IM_MOD_RL_dcm_.dll -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 File ::335A4CFB-5C2D-44E4-C438-7018E8244C3D -name ebook-viewer.exe -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 File ::62A16C3B-ED9C-5187-2807-58857DF3A990 -name calibre-debug.exe -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 File ::55ECA7B7-279A-F51D-81C2-C8DC44CF0E22 -name select.pyd -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 +File ::A6AF5ECC-A981-4CBD-DBEE-303A9340C603 -name IM_MOD_RL_xps_.dll -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 File ::5BCBF71F-18E7-5C52-E3F5-7D7F3028AD46 -name locale.xml -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 File ::5C9FA94C-B8B0-A94B-548D-1D24FDEA5770 -name CORE_RL_wand_.dll -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 File ::E39E60BE-DE77-AB8C-42C6-5A7D7DC073E3 -name IM_MOD_RL_ttf_.dll -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 @@ -436,10 +443,12 @@ File ::396B4F78-FB45-C0B2-ACB3-97769CF5CD5D -name msvcr90.dll -parent 8E5D85A4-7 File ::1DE767EE-4891-4E54-422D-67A4DFF8C3B5 -name lrfviewer.exe -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 File ::AFFEC28A-615C-E3E6-0026-CCE2594A6D25 -name calibre-server.exe.local -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 File ::2C64F86B-9366-B52D-F7B2-5BBD51F6982A -name IM_MOD_RL_pwp_.dll -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 +File ::F4B2EF9C-EB18-B865-6E99-75CFB9B60D87 -name IM_MOD_RL_dds_.dll -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 File ::38770D87-6CA9-9E3E-FBA1-A8CCFCD88FB5 -name IM_MOD_RL_fpx_.dll -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 File ::BE2D7BC3-D294-AF3F-65E7-3B372DEFDE36 -name PIL._imaging.pyd -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 File ::200B9AEC-809F-75B7-DC12-A51BFC2A6F93 -name PyQt4.QtSvg.pyd -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 File ::52132A31-D3AE-C617-7568-BF2AF46B5D74 -name IM_MOD_RL_pcl_.dll -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 +File ::F94472C3-C8D0-950F-5ED9-1611D1CE30E5 -name IM_MOD_RL_inline_.dll -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 File ::055ADB4B-20C5-E071-442F-4DA0A8D6F3C5 -name english.xml -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 File ::B10B6B91-0C03-642D-90D8-37B607B164AD -name IM_MOD_RL_wpg_.dll -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 File ::BFBB144B-1794-8304-9772-F103A42F2CA4 -name IM_MOD_RL_pdb_.dll -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 @@ -494,6 +503,7 @@ File ::9BA85EE5-1754-67AF-736D-481CDCC72DD2 -name _imagingft.pyd -parent 8E5D85A File ::6254DD0C-8F2C-D4AE-2107-2597D542C181 -name IM_MOD_RL_matte_.dll -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 File ::F159D566-88D6-C347-3E3C-55C2DDFC5FD0 -name IM_MOD_RL_mono_.dll -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 File ::B873CAA2-011F-94C3-7977-FF344E53C44F -name CORE_RL_jbig_.dll -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 +File ::7004FCB8-C6F4-C7AF-08E4-B6151B2F7050 -name tcl85.dll -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 File ::6921F62A-4015-4C9F-98A6-BCBBC43B698E -name msvcm90.dll -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 File ::7276E0CA-C205-4B18-19A3-157F1B8523FB -name IM_MOD_RL_xtrn_.dll -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 File ::7B9624A9-88B4-C61E-6771-9A34FB6CA3B5 -name PyQt4.QtGui.pyd -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 @@ -557,15 +567,6 @@ File ::9E4E5E8F-30C0-E631-9516-2AE01A5CA0E9 -name ebook-device.exe.local -parent File ::7BE6B538-70D5-A7EB-5F91-E14CE57B394B -name calibre-complete.exe.local -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 File ::C4E40030-3EE0-8B05-E6B9-89E81433EE1F -name phonon4.dll -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 File ::9E84342F-36ED-7ED3-8F90-1EC55267BCFC -name poppler-qt4.dll -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 -File ::86BA442C-90C9-A4E6-1D3E-D144E5F326C1 -name msvcp71.dll -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 -File ::11FBAD0B-A2DB-C28A-85B8-D6A22706864F -name mfc71.dll -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 -File ::4B9FB3E6-B807-65CC-826D-A398E964D00C -name IM_MOD_RL_hdf_.dll -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 -File ::3E201C0C-C7CC-5785-74F6-A6CC7F50A15A -name msvcr71.dll -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 -File ::2EE42149-1C12-CCA9-9089-AE1809098D0A -name jpeg62.dll -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 -File ::B1FD37B4-E91B-DC1C-1C69-FB2E10EB93AE -name libtiff3.dll -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 -File ::15E09D95-97D6-92A9-CC4D-120885E4DDAD -name freetype.dll -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 -File ::D954BC75-8166-EC1B-D91B-C9779248AA14 -name fontconfig.dll -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 -File ::1F3C052A-A5E0-5C65-8D42-EBF44FBE138D -name podofo.dll.manifest -parent 8E5D85A4-7608-47A1-CF7C-309060D5FF40 Component ::F6829AB7-9F66-4CEE-CA0E-21F54C6D3609 -setup Install -active Yes -platforms {AIX-ppc FreeBSD-4-x86 FreeBSD-x86 HPUX-hppa Linux-x86 Solaris-sparc Windows FreeBSD-5-x86 FreeBSD-6-x86 FreeBSD-7-x86 Linux-x86_64 Solaris-x86} -name Main -parent Components SetupType ::D9ADE41C-B744-690C-2CED-CF826BF03D2E -setup Install -active Yes -platforms {AIX-ppc FreeBSD-4-x86 FreeBSD-x86 HPUX-hppa Linux-x86 Solaris-sparc Windows FreeBSD-5-x86 FreeBSD-6-x86 FreeBSD-7-x86 Linux-x86_64 Solaris-x86} -name Typical -parent SetupTypes diff --git a/installer/windows/freeze.py b/installer/windows/freeze.py index 0b4f18ff4a..bbac05d30e 100644 --- a/installer/windows/freeze.py +++ b/installer/windows/freeze.py @@ -7,12 +7,15 @@ __docformat__ = 'restructuredtext en' Freeze app into executable using py2exe. ''' QT_DIR = 'C:\\Qt\\4.5.2' -LIBUSB_DIR = r'C:\cygwin\home\kovid\win32\libusb' +LIBUSB_DIR = 'C:\\libusb' LIBUNRAR = 'C:\\Program Files\\UnrarDLL\\unrar.dll' -BINARIES = r'C:\cygwin\home\kovid\win32\bin' -IMAGEMAGICK_DIR = r'C:\cygwin\home\kovid\win32\imagemagick' -FONTCONFIG_DIR = r'C:\cygwin\home\kovid\win32\etc' -VC90 = r'C:\Program Files\Microsoft Visual Studio 9.0\VC\redist\x86\Microsoft.VC90.CRT' +PDFTOHTML = 'C:\\cygwin\\home\\kovid\\poppler-0.10.6\\rel\\pdftohtml.exe' +POPPLER = 'C:\\cygwin\\home\\kovid\\poppler' +IMAGEMAGICK_DIR = 'C:\\ImageMagick' +PDFTK = 'C:\\pdftk.exe' +PODOFO = 'C:\\podofo' +FONTCONFIG_DIR = 'C:\\fontconfig' +VC90 = r'C:\VC90.CRT' # ModuleFinder can't handle runtime changes to __path__, but win32com uses them import sys @@ -95,17 +98,25 @@ class BuildEXE(py2exe.build_exe.py2exe): shutil.copyfile(f, os.path.join(tdir, os.path.basename(f))) print '\tAdding unrar' shutil.copyfile(LIBUNRAR, os.path.join(PY2EXE_DIR, os.path.basename(LIBUNRAR))) - print '\tAdding Binaries' - for x in glob.glob(os.path.join(BINARIES, '*.dll')) + \ - [os.path.join(BINARIES, 'pdftohtml.exe')] + \ - glob.glob(os.path.join(BINARIES, '*.manifest')): - shutil.copyfile(x, os.path.join(PY2EXE_DIR, os.path.basename(x))) + print '\tAdding poppler' + for x in ('bin\\pdftohtml.exe', 'bin\\poppler-qt4.dll', + 'bin\\freetype.dll', 'bin\\jpeg62.dll'): + shutil.copyfile(os.path.join(POPPLER, x), + os.path.join(PY2EXE_DIR, os.path.basename(x))) + print '\tAdding podofo' + for f in glob.glob(os.path.join(PODOFO, '*.dll')): + shutil.copyfile(f, os.path.join(PY2EXE_DIR, os.path.basename(f))) + print '\tAdding ImageMagick' for f in os.listdir(IMAGEMAGICK_DIR): shutil.copyfile(os.path.join(IMAGEMAGICK_DIR, f), os.path.join(PY2EXE_DIR, f)) print '\tCopying fontconfig' - tgt = os.path.join(PY2EXE_DIR, 'etc') - shutil.copytree(FONTCONFIG_DIR, tgt) + for f in glob.glob(os.path.join(FONTCONFIG_DIR, '*')): + tgt = os.path.join(PY2EXE_DIR, os.path.basename(f)) + if os.path.isdir(f): + shutil.copytree(f, tgt) + else: + shutil.copyfile(f, tgt) print print 'Doing DLL redirection' # See http://msdn.microsoft.com/en-us/library/ms682600(VS.85).aspx @@ -158,7 +169,8 @@ def main(args=sys.argv): 'email.iterators', 'email.generator', 'win32process', 'win32api', 'msvcrt', - 'win32event', 'sqlite3.dump', + 'win32event', 'calibre.ebooks.lrf.any.*', + 'sqlite3.dump', 'BeautifulSoup', 'pyreadline', 'pydoc', 'IPython.Extensions.*', 'calibre.web.feeds.recipes.*', @@ -171,8 +183,7 @@ def main(args=sys.argv): 'excludes' : ["Tkconstants", "Tkinter", "tcl", "_imagingtk", "ImageTk", "FixTk" ], - 'dll_excludes' : ['mswsock.dll', 'tcl85.dll', - 'MSVCP90.dll', 'tk85.dll'], + 'dll_excludes' : ['mswsock.dll'], }, }, diff --git a/setup.py b/setup.py index a7d5b009ab..ed372920de 100644 --- a/setup.py +++ b/setup.py @@ -94,8 +94,8 @@ if __name__ == '__main__': sources=['src/calibre/utils/windows/winutil.c'], libraries=['shell32', 'setupapi'], include_dirs=os.environ.get('INCLUDE', - 'C:/WinDDK/7600.16385.0/inc/api/;' - 'C:/WinDDK/7600.16385.0/inc/crt/').split(';'), + 'C:/WinDDK/6001.18001/inc/api/;' + 'C:/WinDDK/6001.18001/inc/crt/').split(';'), extra_compile_args=['/X'] )) @@ -103,8 +103,8 @@ if __name__ == '__main__': poppler_lib = '/usr/lib' poppler_libs = [] if iswindows: - poppler_inc = r'C:\cygwin\home\kovid\win32\include\poppler\qt4' - poppler_lib = r'C:\cygwin\home\kovid\win32\lib' + poppler_inc = r'C:\cygwin\home\kovid\poppler\include\poppler\qt4' + poppler_lib = r'C:\cygwin\home\kovid\poppler\lib' poppler_libs = ['QtCore4', 'QtGui4'] if isosx: poppler_inc = '/Volumes/sw/build/poppler-0.10.7/qt4/src' @@ -124,10 +124,9 @@ if __name__ == '__main__': print 'POPPLER_LIB_DIR environment variables.' podofo_inc = '/usr/include/podofo' if islinux else \ - r'C:\cygwin\home\kovid\win32\include\podofo' if iswindows else \ + 'C:\\podofo\\include\\podofo' if iswindows else \ '/usr/local/include/podofo' - podofo_lib = '/usr/lib' if islinux else \ - r'C:\cygwin\home\kovid\win32\lib' if iswindows else \ + podofo_lib = '/usr/lib' if islinux else r'C:\podofo' if iswindows else \ '/usr/local/lib' podofo_inc = os.environ.get('PODOFO_INC_DIR', podofo_inc) if os.path.exists(os.path.join(podofo_inc, 'podofo.h')): @@ -142,10 +141,10 @@ if __name__ == '__main__': print 'PODOFO_LIB_DIR environment variables.' fc_inc = '/usr/include/fontconfig' if islinux else \ - r'C:\cygwin\home\kovid\win32\include\fontconfig' if iswindows else \ + r'C:\cygwin\home\kovid\fontconfig\include\fontconfig' if iswindows else \ '/Users/kovid/fontconfig/include/fontconfig' fc_lib = '/usr/lib' if islinux else \ - r'C:\cygwin\home\kovid\win32\lib' if iswindows else \ + r'C:\cygwin\home\kovid\fontconfig\lib' if iswindows else \ '/Users/kovid/fontconfig/lib' diff --git a/src/calibre/gui2/convert/debug.py b/src/calibre/gui2/convert/debug.py index fbf5372aa9..55ac37d6ca 100644 --- a/src/calibre/gui2/convert/debug.py +++ b/src/calibre/gui2/convert/debug.py @@ -42,6 +42,8 @@ class DebugWidget(Widget, Ui_Form): def pre_commit_check(self): try: x = unicode(self.opt_debug_pipeline.text()).strip() + if not x: + return True x = os.path.abspath(x) if x: if not os.path.exists(x): diff --git a/src/calibre/web/feeds/recipes/recipe_scientific_american.py b/src/calibre/web/feeds/recipes/recipe_scientific_american.py index 8d706e8416..1a03591672 100644 --- a/src/calibre/web/feeds/recipes/recipe_scientific_american.py +++ b/src/calibre/web/feeds/recipes/recipe_scientific_american.py @@ -12,44 +12,57 @@ from calibre.web.feeds.news import BasicNewsRecipe class ScientificAmerican(BasicNewsRecipe): title = u'Scientific American' description = u'Popular science. Monthly magazine.' - __author__ = 'Kovid Goyal' + __author__ = 'Kovid Goyal and Sujata Raman' language = _('English') oldest_article = 30 max_articles_per_feed = 100 no_stylesheets = True use_embedded_content = False + extra_css = ''' + p{font-weight: normal; font-size:small} + li{font-weight: normal; font-size:small} + .headline p{font-size:x-small; font-family:Arial,Helvetica,sans-serif;} + h2{font-size:x-small;} + h3{font-size:x-small;font-family:Arial,Helvetica,sans-serif;} + ''' remove_tags_before = dict(name='div', attrs={'class':'headline'}) + remove_tags_after = dict(id=['article']) remove_tags = [ dict(id=['sharetools', 'reddit']), dict(name='script'), {'class':['float_left', 'atools']}, - {"class": re.compile(r'also-in-this')} + {"class": re.compile(r'also-in-this')}, + dict(name='a',title = ["Get the Rest of the Article","Subscribe","Buy this Issue"]), + dict(name = 'img',alt = ["Graphic - Get the Rest of the Article"]), ] + html2lrf_options = ['--base-font-size', '8'] recursions = 1 match_regexps = [r'article.cfm.id=\S+page=(2|3|4|5|6|7|8|9|10|11|12|13|14|15)'] def parse_index(self): soup = self.index_to_soup('http://www.scientificamerican.com/sciammag/') - month = soup.find(id='magazine-month') + monthtag = soup.find('div',attrs={'id':'magazine-main_col2'}) + month = self.tag_to_string(monthtag.contents[1]) + + self.timefmt = ' [%s]'%(self.tag_to_string(month)) img = soup.find('img', alt='Scientific American Magazine', src=True) if img is not None: self.cover_url = img['src'] features, feeds = [], [] - for p in soup.find(id='magazine-info').findAll('p') + \ - soup.find(id='magazine-info-more').findAll('p'): - all_as = p.findAll('a', href=True) - a = all_as[0] + for p in soup.find(id='magazine-main_col2').findAll('p') : + a = p.find('a', href=True) + if a is None: continue desc = '' - for s in p.find('span', attrs={'class':'sub'}): - desc += self.tag_to_string(s) + s = p.find('span', attrs={'class':"sub"}) + desc = self.tag_to_string(s) article = { - 'url' : a.get('href'), - 'title' : self.tag_to_string(all_as[-1]), + 'url' : a['href'], + 'title' : self.tag_to_string(a), 'date' : '', 'description' : desc, } @@ -59,31 +72,31 @@ class ScientificAmerican(BasicNewsRecipe): section = [] found = [] title = None + for x in soup.find(id='magazine-main_col1').findAll(['div', 'a']): + if x.name == 'div': + if section: feeds.append((title, section)) + title = self.tag_to_string(x) section = [] else: - if title is None or not a.get('href', False) or a.get('href', None) in found: - continue - article = { - 'url' : x['href'], - 'title' : self.tag_to_string(x), - 'date': '', - 'description': '', + + if 'article.cfm' in x['href']: + article = { + 'url' : x['href'], + 'title' : self.tag_to_string(x), + 'date': '', + 'description': '', } - section.append(article) + + section.append(article) + if section: feeds.append((title, section)) - articles = [] - for a in soup.find(id='opinion').findAll('a', href=True): - articles.append({'url':a['href'], 'title':self.tag_to_string(a), - 'description':'', 'date':''}) - feeds.append(('Opinion', articles)) - return feeds @@ -95,4 +108,5 @@ class ScientificAmerican(BasicNewsRecipe): div = soup.find('div', attrs={'class':'headline'}) if div: div.extract() + return soup diff --git a/upload.py b/upload.py index ffd702ca5d..29d277191f 100644 --- a/upload.py +++ b/upload.py @@ -36,7 +36,7 @@ def get_ip_address(ifname): )[20:24]) try: - HOST=get_ip_address('br0') + HOST=get_ip_address('eth0') except: try: HOST=get_ip_address('wlan0') @@ -506,6 +506,7 @@ class VMInstaller(OptionlessCommand): user_options = [('dont-shutdown', 'd', 'Dont shutdown VM after build')] boolean_options = ['dont-shutdown'] + EXTRA_SLEEP = 5 def initialize_options(self): self.dont_shutdown = False @@ -546,12 +547,10 @@ class VMInstaller(OptionlessCommand): pass while 'vmblock' in open('/proc/modules').read(): check_call('sudo rmmod -f vmblock') - check_call('sudo modprobe kvm-intel', shell=True) def run_vm(self): - vmware = ('vmware', '-q', '-x', '-n', self.VM) - self.__p = Popen(vmware) + self.__p = Popen(self.VM) def start_vm(self, ssh_host, build_script, sleep=75): self.run_vm() @@ -563,7 +562,7 @@ class VMInstaller(OptionlessCommand): while call('ping -q -c1 '+ssh_host, shell=True, stdout=open('/dev/null', 'w')) != 0: time.sleep(5) - time.sleep(20) + time.sleep(self.EXTRA_SLEEP) print 'Trying to SSH into VM' check_call(('scp', t.name, ssh_host+':build-calibre')) check_call('ssh -t %s bash build-calibre'%ssh_host, shell=True) @@ -572,6 +571,7 @@ class KVMInstaller(VMInstaller): def run_vm(self): self.stop_vmware() + check_call('sudo modprobe kvm-intel', shell=True) self.__p = Popen(self.VM) @@ -599,24 +599,24 @@ class build_linux32(KVMInstaller): return _build_linux() -class build_windows(KVMInstaller): +class build_windows(VMInstaller): description = 'Build windows installer' - VM = '/vmware/bin/win_build' + VM = '/vmware/bin/xp_build' def run(self): installer = installer_name('exe') - self.start_vm('win_build', ('python setup.py develop', + self.start_vm('xp_build', ('python setup.py develop', 'python', r'installer\\windows\\freeze.py')) if os.path.exists('build/py2exe'): shutil.rmtree('build/py2exe') - check_call(('scp', '-rp', 'win_build:build/%s/build/py2exe'%__appname__, + check_call(('scp', '-rp', 'xp_build:build/%s/build/py2exe'%__appname__, 'build')) if not os.path.exists('build/py2exe'): raise Exception('Failed to run py2exe') self.run_windows_install_jammer(installer) if not self.dont_shutdown: - Popen(('ssh', 'win_build', 'shutdown', '-s', '-t', '0')) + Popen(('ssh', 'xp_build', 'shutdown', '-s', '-t', '0')) return os.path.basename(installer) @classmethod