mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Merge from trunk
This commit is contained in:
commit
ad6af10670
@ -1,6 +1,6 @@
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2009, Darko Miletic <darko.miletic at gmail.com>'
|
||||
__copyright__ = '2009-2011, Darko Miletic <darko.miletic at gmail.com>'
|
||||
'''
|
||||
elmundo.es
|
||||
'''
|
||||
@ -10,15 +10,24 @@ from calibre.web.feeds.news import BasicNewsRecipe
|
||||
class ElMundo(BasicNewsRecipe):
|
||||
title = 'El Mundo'
|
||||
__author__ = 'Darko Miletic'
|
||||
description = 'News from Spain'
|
||||
publisher = 'El Mundo'
|
||||
description = 'Lider de informacion en espaniol'
|
||||
publisher = 'Unidad Editorial Informacion General S.L.U.'
|
||||
category = 'news, politics, Spain'
|
||||
oldest_article = 2
|
||||
max_articles_per_feed = 100
|
||||
no_stylesheets = True
|
||||
use_embedded_content = False
|
||||
encoding = 'iso8859_15'
|
||||
language = 'es'
|
||||
language = 'es_ES'
|
||||
masthead_url = 'http://estaticos03.elmundo.es/elmundo/iconos/v4.x/v4.01/bg_h1.png'
|
||||
publication_type = 'newspaper'
|
||||
extra_css = """
|
||||
body{font-family: Arial,Helvetica,sans-serif}
|
||||
.metadata_noticia{font-size: small}
|
||||
h1,h2,h3,h4,h5,h6,.subtitulo {color: #3F5974}
|
||||
.hora{color: red}
|
||||
.update{color: gray}
|
||||
"""
|
||||
|
||||
conversion_options = {
|
||||
'comments' : description
|
||||
@ -30,22 +39,31 @@ class ElMundo(BasicNewsRecipe):
|
||||
keep_only_tags = [dict(name='div', attrs={'class':'noticia'})]
|
||||
remove_tags_before = dict(attrs={'class':['titular','antetitulo'] })
|
||||
remove_tags_after = dict(name='div' , attrs={'id':['desarrollo_noticia','tamano']})
|
||||
|
||||
remove_attributes = ['lang','border']
|
||||
remove_tags = [
|
||||
dict(name='div', attrs={'class':['herramientas','publicidad_google']})
|
||||
,dict(name='div', attrs={'id':'modulo_multimedia' })
|
||||
,dict(name='ul', attrs={'class':'herramientas' })
|
||||
,dict(name=['object','link'])
|
||||
,dict(name=['object','link','embed','iframe','base','meta'])
|
||||
]
|
||||
|
||||
feeds = [
|
||||
(u'Portada' , u'http://rss.elmundo.es/rss/descarga.htm?data2=4' )
|
||||
,(u'Deportes' , u'http://rss.elmundo.es/rss/descarga.htm?data2=14')
|
||||
,(u'Economia' , u'http://rss.elmundo.es/rss/descarga.htm?data2=7' )
|
||||
,(u'Espana' , u'http://rss.elmundo.es/rss/descarga.htm?data2=8' )
|
||||
,(u'Internacional' , u'http://rss.elmundo.es/rss/descarga.htm?data2=9' )
|
||||
,(u'Cultura' , u'http://rss.elmundo.es/rss/descarga.htm?data2=6' )
|
||||
,(u'Ciencia/Ecologia', u'http://rss.elmundo.es/rss/descarga.htm?data2=5' )
|
||||
,(u'Comunicacion' , u'http://rss.elmundo.es/rss/descarga.htm?data2=26')
|
||||
,(u'Television' , u'http://rss.elmundo.es/rss/descarga.htm?data2=76')
|
||||
(u'Portada' , u'http://estaticos.elmundo.es/elmundo/rss/portada.xml' )
|
||||
,(u'Deportes' , u'http://estaticos.elmundo.es/elmundodeporte/rss/portada.xml')
|
||||
,(u'Economia' , u'http://estaticos.elmundo.es/elmundo/rss/economia.xml' )
|
||||
,(u'Espana' , u'http://estaticos.elmundo.es/elmundo/rss/espana.xml' )
|
||||
,(u'Internacional' , u'http://estaticos.elmundo.es/elmundo/rss/internacional.xml' )
|
||||
,(u'Cultura' , u'http://estaticos.elmundo.es/elmundo/rss/cultura.xml' )
|
||||
,(u'Ciencia/Ecologia', u'http://estaticos.elmundo.es/elmundo/rss/ciencia.xml' )
|
||||
,(u'Comunicacion' , u'http://estaticos.elmundo.es/elmundo/rss/comunicacion.xml' )
|
||||
,(u'Television' , u'http://estaticos.elmundo.es/elmundo/rss/television.xml' )
|
||||
]
|
||||
|
||||
def preprocess_html(self, soup):
|
||||
for item in soup.findAll(style=True):
|
||||
del item['style']
|
||||
return soup
|
||||
|
||||
def get_article_url(self, article):
|
||||
return article.get('guid', None)
|
||||
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 550 B After Width: | Height: | Size: 1.1 KiB |
BIN
recipes/icons/marca.png
Normal file
BIN
recipes/icons/marca.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 293 B |
BIN
recipes/icons/the_nation.png
Normal file
BIN
recipes/icons/the_nation.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 925 B |
@ -1,14 +1,11 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2009, Darko Miletic <darko.miletic at gmail.com>'
|
||||
__copyright__ = '2009-2011, Darko Miletic <darko.miletic at gmail.com>'
|
||||
'''
|
||||
www.marca.com
|
||||
'''
|
||||
|
||||
from calibre.web.feeds.news import BasicNewsRecipe
|
||||
from calibre.ebooks.BeautifulSoup import Tag
|
||||
|
||||
class Marca(BasicNewsRecipe):
|
||||
title = 'Marca'
|
||||
@ -22,35 +19,30 @@ class Marca(BasicNewsRecipe):
|
||||
use_embedded_content = False
|
||||
delay = 1
|
||||
encoding = 'iso-8859-15'
|
||||
language = 'es'
|
||||
language = 'es_ES'
|
||||
publication_type = 'newsportal'
|
||||
masthead_url = 'http://estaticos.marca.com/deporte/img/v3.0/img_marca-com.png'
|
||||
extra_css = """
|
||||
body{font-family: Tahoma,Geneva,sans-serif}
|
||||
h1,h2,h3,h4,h5,h6{font-family: 'LatoBlack',Tahoma,Geneva,sans-serif}
|
||||
.cab_articulo h4 {font-family: Georgia,"Times New Roman",Times,serif}
|
||||
.antetitulo{text-transform: uppercase}
|
||||
"""
|
||||
|
||||
direction = 'ltr'
|
||||
|
||||
html2lrf_options = [
|
||||
'--comment' , description
|
||||
, '--category' , category
|
||||
, '--publisher', publisher
|
||||
]
|
||||
|
||||
html2epub_options = 'publisher="' + publisher + '"\ncomments="' + description + '"\ntags="' + category + '"'
|
||||
|
||||
feeds = [(u'Portada', u'http://rss.marca.com/rss/descarga.htm?data2=425')]
|
||||
|
||||
keep_only_tags = [dict(name='div', attrs={'class':['cab_articulo','col_izq']})]
|
||||
feeds = [(u'Portada', u'http://estaticos.marca.com/rss/portada.xml')]
|
||||
|
||||
keep_only_tags = [dict(name='div', attrs={'class':['cab_articulo','cuerpo_articulo']})]
|
||||
remove_attributes = ['lang']
|
||||
remove_tags = [
|
||||
dict(name=['object','link','script'])
|
||||
,dict(name='div', attrs={'class':['colC','peu']})
|
||||
,dict(name='div', attrs={'class':['utilidades estirar','bloque_int_corr estirar']})
|
||||
dict(name=['object','link','script','embed','iframe','meta','base'])
|
||||
,dict(name='div', attrs={'class':'tabs'})
|
||||
]
|
||||
|
||||
remove_tags_after = [dict(name='div', attrs={'class':'bloque_int_corr estirar'})]
|
||||
|
||||
def preprocess_html(self, soup):
|
||||
soup.html['dir' ] = self.direction
|
||||
mcharset = Tag(soup,'meta',[("http-equiv","Content-Type"),("content","text/html; charset=utf-8")])
|
||||
soup.head.insert(0,mcharset)
|
||||
for item in soup.findAll(style=True):
|
||||
del item['style']
|
||||
return soup
|
||||
|
||||
def get_article_url(self, article):
|
||||
return article.get('guid', None)
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2008 - 2010, Darko Miletic <darko.miletic at gmail.com>'
|
||||
__copyright__ = '2008 - 2011, Darko Miletic <darko.miletic at gmail.com>'
|
||||
'''
|
||||
thenation.com
|
||||
'''
|
||||
@ -19,7 +19,14 @@ class Thenation(BasicNewsRecipe):
|
||||
use_embedded_content = False
|
||||
delay = 1
|
||||
masthead_url = 'http://www.thenation.com/sites/default/themes/thenation/images/logo-main.gif'
|
||||
exra_css = ' body{font-family: Arial,Helvetica,sans-serif;} .print-created{font-size: small;} .caption{display: block; font-size: x-small;} '
|
||||
login_url = 'http://www.thenation.com/user?destination=%3Cfront%3E'
|
||||
publication_type = 'magazine'
|
||||
needs_subscription = 'optional'
|
||||
exra_css = """
|
||||
body{font-family: Arial,Helvetica,sans-serif;}
|
||||
.print-created{font-size: small;}
|
||||
.caption{display: block; font-size: x-small;}
|
||||
"""
|
||||
|
||||
conversion_options = {
|
||||
'comment' : description
|
||||
@ -28,13 +35,30 @@ class Thenation(BasicNewsRecipe):
|
||||
, 'language' : language
|
||||
}
|
||||
|
||||
keep_only_tags = [ dict(attrs={'class':['print-title','print-created','print-content','print-links']}) ]
|
||||
remove_tags = [dict(name='link')]
|
||||
keep_only_tags = [dict(attrs={'class':['print-title','print-created','print-content','print-links']})]
|
||||
remove_tags = [dict(name=['link','iframe','base','meta','object','embed'])]
|
||||
remove_attributes = ['lang']
|
||||
|
||||
feeds = [(u"Editor's Picks", u'http://www.thenation.com/rss/editors_picks')]
|
||||
feeds = [(u"Articles", u'http://www.thenation.com/rss/articles')]
|
||||
|
||||
def print_version(self, url):
|
||||
return url.replace('.thenation.com/','.thenation.com/print/')
|
||||
|
||||
def preprocess_html(self, soup):
|
||||
return self.adeify_images(soup)
|
||||
def get_browser(self):
|
||||
br = BasicNewsRecipe.get_browser()
|
||||
br.open('http://www.thenation.com/')
|
||||
if self.username is not None and self.password is not None:
|
||||
br.open(self.login_url)
|
||||
br.select_form(nr=1)
|
||||
br['name'] = self.username
|
||||
br['pass'] = self.password
|
||||
br.submit()
|
||||
return br
|
||||
|
||||
def get_cover_url(self):
|
||||
soup = self.index_to_soup('http://www.thenation.com/issue/')
|
||||
item = soup.find('div',attrs={'id':'cover-wrapper'})
|
||||
if item:
|
||||
return item.img['src']
|
||||
return None
|
||||
|
@ -12,7 +12,9 @@ is64bit = platform.architecture()[0] == '64bit'
|
||||
iswindows = re.search('win(32|64)', sys.platform)
|
||||
isosx = 'darwin' in sys.platform
|
||||
isfreebsd = 'freebsd' in sys.platform
|
||||
islinux = not isosx and not iswindows and not isfreebsd
|
||||
isnetbsd = 'netbsd' in sys.platform
|
||||
isbsd = isnetbsd or isfreebsd
|
||||
islinux = not isosx and not iswindows and not isbsd
|
||||
SRC = os.path.abspath('src')
|
||||
sys.path.insert(0, SRC)
|
||||
sys.resources_location = os.path.join(os.path.dirname(SRC), 'resources')
|
||||
|
@ -11,7 +11,7 @@ from distutils import sysconfig
|
||||
|
||||
from PyQt4.pyqtconfig import QtGuiModuleMakefile
|
||||
|
||||
from setup import Command, islinux, isfreebsd, isosx, SRC, iswindows
|
||||
from setup import Command, islinux, isfreebsd, isbsd, isosx, SRC, iswindows
|
||||
from setup.build_environment import fc_inc, fc_lib, chmlib_inc_dirs, \
|
||||
fc_error, poppler_libs, poppler_lib_dirs, poppler_inc_dirs, podofo_inc, \
|
||||
podofo_lib, podofo_error, poppler_error, pyqt, OSX_SDK, NMAKE, \
|
||||
@ -21,7 +21,7 @@ from setup.build_environment import fc_inc, fc_lib, chmlib_inc_dirs, \
|
||||
jpg_lib_dirs, chmlib_lib_dirs, sqlite_inc_dirs, icu_inc_dirs, \
|
||||
icu_lib_dirs
|
||||
MT
|
||||
isunix = islinux or isosx or isfreebsd
|
||||
isunix = islinux or isosx or isbsd
|
||||
|
||||
make = 'make' if isunix else NMAKE
|
||||
|
||||
@ -205,7 +205,7 @@ if islinux:
|
||||
ldflags.append('-lpython'+sysconfig.get_python_version())
|
||||
|
||||
|
||||
if isfreebsd:
|
||||
if isbsd:
|
||||
cflags.append('-pthread')
|
||||
ldflags.append('-shared')
|
||||
cflags.append('-I'+sysconfig.get_python_inc())
|
||||
|
@ -8,7 +8,7 @@ __docformat__ = 'restructuredtext en'
|
||||
|
||||
import sys, os, textwrap, subprocess, shutil, tempfile, atexit, stat, shlex
|
||||
|
||||
from setup import Command, islinux, isfreebsd, basenames, modules, functions, \
|
||||
from setup import Command, islinux, isfreebsd, isbsd, basenames, modules, functions, \
|
||||
__appname__, __version__
|
||||
|
||||
HEADER = '''\
|
||||
@ -116,7 +116,7 @@ class Develop(Command):
|
||||
|
||||
|
||||
def pre_sub_commands(self, opts):
|
||||
if not (islinux or isfreebsd):
|
||||
if not (islinux or isbsd):
|
||||
self.info('\nSetting up a source based development environment is only '
|
||||
'supported on linux. On other platforms, see the User Manual'
|
||||
' for help with setting up a development environment.')
|
||||
@ -156,7 +156,7 @@ class Develop(Command):
|
||||
self.warn('Failed to compile mount helper. Auto mounting of',
|
||||
' devices will not work')
|
||||
|
||||
if not isfreebsd and os.geteuid() != 0:
|
||||
if not isbsd and os.geteuid() != 0:
|
||||
return self.warn('Must be run as root to compile mount helper. Auto '
|
||||
'mounting of devices will not work.')
|
||||
src = os.path.join(self.SRC, 'calibre', 'devices', 'linux_mount_helper.c')
|
||||
@ -168,7 +168,7 @@ class Develop(Command):
|
||||
ret = p.wait()
|
||||
if ret != 0:
|
||||
return warn()
|
||||
if not isfreebsd:
|
||||
if not isbsd:
|
||||
os.chown(dest, 0, 0)
|
||||
os.chmod(dest, stat.S_ISUID|stat.S_ISGID|stat.S_IRUSR|stat.S_IWUSR|\
|
||||
stat.S_IXUSR|stat.S_IXGRP|stat.S_IXOTH)
|
||||
|
@ -26,6 +26,11 @@
|
||||
</Upgrade>
|
||||
<CustomAction Id="PreventDowngrading" Error="Newer version already installed."/>
|
||||
|
||||
<Property Id="APPLICATIONFOLDER">
|
||||
<RegistrySearch Id='calibreInstDir' Type='raw'
|
||||
Root='HKLM' Key="Software\{app}\Installer" Name="InstallPath" />
|
||||
</Property>
|
||||
|
||||
<Directory Id='TARGETDIR' Name='SourceDir'>
|
||||
<Merge Id="VCRedist" SourceFile="{crt_msm}" DiskId="1" Language="0"/>
|
||||
<Directory Id='ProgramFilesFolder' Name='PFiles'>
|
||||
@ -43,6 +48,9 @@
|
||||
<Environment Id='UpdatePath' Name='PATH' Action='set' System='yes' Part='last' Value='[APPLICATIONFOLDER]' />
|
||||
<RegistryValue Root="HKCU" Key="Software\Microsoft\{app}" Name="system_path_updated" Type="integer" Value="1" KeyPath="yes"/>
|
||||
</Component>
|
||||
<Component Id="RememberInstallDir" Guid="*">
|
||||
<RegistryValue Root="HKLM" Key="Software\{app}\Installer" Name="InstallPath" Type="string" Value="[APPLICATIONFOLDER]" KeyPath="yes"/>
|
||||
</Component>
|
||||
</DirectoryRef>
|
||||
|
||||
<DirectoryRef Id="ApplicationProgramsFolder">
|
||||
@ -87,7 +95,8 @@
|
||||
ConfigurableDirectory="APPLICATIONFOLDER">
|
||||
|
||||
<Feature Id="MainApplication" Title="Program Files" Level="1"
|
||||
Description="All the files need to run {app}" Absent="disallow">
|
||||
Description="All the files needed to run {app}" Absent="disallow">
|
||||
<ComponentRef Id="RememberInstallDir"/>
|
||||
</Feature>
|
||||
|
||||
<Feature Id="VCRedist" Title="Visual C++ 8.0 Runtime" AllowAdvertise="no" Display="hidden" Level="1">
|
||||
@ -115,7 +124,7 @@
|
||||
<Property Id="ARPPRODUCTICON" Value="main_icon" />
|
||||
|
||||
<Condition
|
||||
Message="This application is only supported on Windows XP SP2, or higher.">
|
||||
Message="This application is only supported on Windows XP SP3, or higher.">
|
||||
<![CDATA[Installed OR (VersionNT >= 501)]]>
|
||||
</Condition>
|
||||
<InstallExecuteSequence>
|
||||
|
@ -12,8 +12,8 @@ from functools import partial
|
||||
warnings.simplefilter('ignore', DeprecationWarning)
|
||||
|
||||
|
||||
from calibre.constants import (iswindows, isosx, islinux, isfreebsd, isfrozen,
|
||||
preferred_encoding, __appname__, __version__, __author__,
|
||||
from calibre.constants import (iswindows, isosx, islinux, isfrozen,
|
||||
isbsd, preferred_encoding, __appname__, __version__, __author__,
|
||||
win32event, win32api, winerror, fcntl,
|
||||
filesystem_encoding, plugins, config_dir)
|
||||
from calibre.startup import winutil, winutilerror
|
||||
@ -31,7 +31,7 @@ if False:
|
||||
# Prevent pyflakes from complaining
|
||||
winutil, winutilerror, __appname__, islinux, __version__
|
||||
fcntl, win32event, isfrozen, __author__
|
||||
winerror, win32api, isfreebsd
|
||||
winerror, win32api, isbsd
|
||||
|
||||
_mt_inited = False
|
||||
def _init_mimetypes():
|
||||
|
@ -27,7 +27,9 @@ iswindows = 'win32' in _plat or 'win64' in _plat
|
||||
isosx = 'darwin' in _plat
|
||||
isnewosx = isosx and getattr(sys, 'new_app_bundle', False)
|
||||
isfreebsd = 'freebsd' in _plat
|
||||
islinux = not(iswindows or isosx or isfreebsd)
|
||||
isnetbsd = 'netbsd' in _plat
|
||||
isbsd = isfreebsd or isnetbsd
|
||||
islinux = not(iswindows or isosx or isbsd)
|
||||
isfrozen = hasattr(sys, 'frozen')
|
||||
isunix = isosx or islinux
|
||||
|
||||
|
@ -8,10 +8,10 @@ from ctypes import cdll, POINTER, byref, pointer, Structure as _Structure, \
|
||||
c_ubyte, c_ushort, c_int, c_char, c_void_p, c_byte, c_uint
|
||||
from errno import EBUSY, ENOMEM
|
||||
|
||||
from calibre import iswindows, isosx, isfreebsd, load_library
|
||||
from calibre import iswindows, isosx, isbsd, load_library
|
||||
|
||||
_libusb_name = 'libusb'
|
||||
PATH_MAX = 511 if iswindows else 1024 if (isosx or isfreebsd) else 4096
|
||||
PATH_MAX = 511 if iswindows else 1024 if (isosx or isbsd) else 4096
|
||||
if iswindows:
|
||||
class Structure(_Structure):
|
||||
_pack_ = 1
|
||||
|
@ -20,7 +20,7 @@ from itertools import izip
|
||||
from calibre.customize.conversion import InputFormatPlugin
|
||||
from calibre.ebooks.chardet import xml_to_unicode
|
||||
from calibre.customize.conversion import OptionRecommendation
|
||||
from calibre.constants import islinux, isfreebsd, iswindows
|
||||
from calibre.constants import islinux, isbsd, iswindows
|
||||
from calibre import unicode_path, as_unicode
|
||||
from calibre.utils.localization import get_lang
|
||||
from calibre.utils.filenames import ascii_filename
|
||||
@ -302,7 +302,7 @@ class HTMLInput(InputFormatPlugin):
|
||||
if getattr(self, '_is_case_sensitive', None) is not None:
|
||||
return self._is_case_sensitive
|
||||
if not path or not os.path.exists(path):
|
||||
return islinux or isfreebsd
|
||||
return islinux or isbsd
|
||||
self._is_case_sensitive = not (os.path.exists(path.lower()) \
|
||||
and os.path.exists(path.upper()))
|
||||
return self._is_case_sensitive
|
||||
|
@ -13,7 +13,7 @@ from functools import partial
|
||||
|
||||
from calibre.ebooks import ConversionError, DRMError
|
||||
from calibre.ptempfile import PersistentTemporaryFile
|
||||
from calibre.constants import isosx, iswindows, islinux, isfreebsd
|
||||
from calibre.constants import isosx, iswindows, islinux, isbsd
|
||||
from calibre import CurrentDir
|
||||
|
||||
PDFTOHTML = 'pdftohtml'
|
||||
@ -23,7 +23,7 @@ if isosx and hasattr(sys, 'frameworks_dir'):
|
||||
if iswindows and hasattr(sys, 'frozen'):
|
||||
PDFTOHTML = os.path.join(os.path.dirname(sys.executable), 'pdftohtml.exe')
|
||||
popen = partial(subprocess.Popen, creationflags=0x08) # CREATE_NO_WINDOW=0x08 so that no ugly console is popped up
|
||||
if (islinux or isfreebsd) and getattr(sys, 'frozen', False):
|
||||
if (islinux or isbsd) and getattr(sys, 'frozen', False):
|
||||
PDFTOHTML = os.path.join(sys.executables_location, 'bin', 'pdftohtml')
|
||||
|
||||
def pdftohtml(output_dir, pdf_path, no_images):
|
||||
@ -43,7 +43,7 @@ def pdftohtml(output_dir, pdf_path, no_images):
|
||||
# This is neccessary as pdftohtml doesn't always (linux) respect absolute paths
|
||||
pdf_path = os.path.abspath(pdf_path)
|
||||
cmd = [PDFTOHTML, '-enc', 'UTF-8', '-noframes', '-p', '-nomerge', '-nodrm', '-q', pdf_path, os.path.basename(index)]
|
||||
if isfreebsd:
|
||||
if isbsd:
|
||||
cmd.remove('-nodrm')
|
||||
if no_images:
|
||||
cmd.append('-i')
|
||||
|
@ -12,7 +12,7 @@ from PyQt4.Qt import (QVariant, QFileInfo, QObject, SIGNAL, QBuffer, Qt,
|
||||
|
||||
ORG_NAME = 'KovidsBrain'
|
||||
APP_UID = 'libprs500'
|
||||
from calibre.constants import islinux, iswindows, isfreebsd, isfrozen, isosx
|
||||
from calibre.constants import islinux, iswindows, isbsd, isfrozen, isosx
|
||||
from calibre.utils.config import Config, ConfigProxy, dynamic, JSONConfig
|
||||
from calibre.utils.localization import set_qt_translator
|
||||
from calibre.ebooks.metadata import MetaInformation
|
||||
@ -628,7 +628,7 @@ class Application(QApplication):
|
||||
st = self.style()
|
||||
if st is not None:
|
||||
st = unicode(st.objectName()).lower()
|
||||
if (islinux or isfreebsd) and st in ('windows', 'motif', 'cde'):
|
||||
if (islinux or isbsd) and st in ('windows', 'motif', 'cde'):
|
||||
from PyQt4.Qt import QStyleFactory
|
||||
styles = set(map(unicode, QStyleFactory.keys()))
|
||||
if 'Plastique' in styles and os.environ.get('KDE_FULL_SESSION',
|
||||
@ -697,7 +697,7 @@ def open_local_file(path):
|
||||
|
||||
def is_ok_to_use_qt():
|
||||
global gui_thread, _store_app
|
||||
if (islinux or isfreebsd) and ':' not in os.environ.get('DISPLAY', ''):
|
||||
if (islinux or isbsd) and ':' not in os.environ.get('DISPLAY', ''):
|
||||
return False
|
||||
if _store_app is None and QApplication.instance() is None:
|
||||
_store_app = QApplication([])
|
||||
|
@ -5,7 +5,7 @@ import sys, logging, os, traceback, time
|
||||
from PyQt4.QtGui import QKeySequence, QPainter, QDialog, QSpinBox, QSlider, QIcon
|
||||
from PyQt4.QtCore import Qt, QObject, SIGNAL, QCoreApplication, QThread
|
||||
|
||||
from calibre import __appname__, setup_cli_handlers, islinux, isfreebsd
|
||||
from calibre import __appname__, setup_cli_handlers, islinux, isbsd
|
||||
from calibre.ebooks.lrf.lrfparser import LRFDocument
|
||||
|
||||
from calibre.gui2 import ORG_NAME, APP_UID, error_dialog, \
|
||||
@ -258,7 +258,7 @@ def file_renderer(stream, opts, parent=None, logger=None):
|
||||
level = logging.DEBUG if opts.verbose else logging.INFO
|
||||
logger = logging.getLogger('lrfviewer')
|
||||
setup_cli_handlers(logger, level)
|
||||
if islinux or isfreebsd:
|
||||
if islinux or isbsd:
|
||||
try: # Set lrfviewer as the default for LRF files for this user
|
||||
from subprocess import call
|
||||
call('xdg-mime default calibre-lrfviewer.desktop application/lrf', shell=True)
|
||||
@ -307,7 +307,7 @@ def main(args=sys.argv, logger=None):
|
||||
if hasattr(opts, 'help'):
|
||||
parser.print_help()
|
||||
return 1
|
||||
pid = os.fork() if (islinux or isfreebsd) else -1
|
||||
pid = os.fork() if (islinux or isbsd) else -1
|
||||
if pid <= 0:
|
||||
app = Application(args)
|
||||
app.setWindowIcon(QIcon(I('viewer.png')))
|
||||
|
@ -20,7 +20,7 @@ from calibre.gui2 import Application, ORG_NAME, APP_UID, choose_files, \
|
||||
info_dialog, error_dialog, open_url, available_height
|
||||
from calibre.ebooks.oeb.iterator import EbookIterator
|
||||
from calibre.ebooks import DRMError
|
||||
from calibre.constants import islinux, isfreebsd, isosx, filesystem_encoding
|
||||
from calibre.constants import islinux, isbsd, isosx, filesystem_encoding
|
||||
from calibre.utils.config import Config, StringConfig, JSONConfig
|
||||
from calibre.gui2.search_box import SearchBox2
|
||||
from calibre.ebooks.metadata import MetaInformation
|
||||
@ -801,7 +801,7 @@ def main(args=sys.argv):
|
||||
|
||||
parser = option_parser()
|
||||
opts, args = parser.parse_args(args)
|
||||
pid = os.fork() if False and (islinux or isfreebsd) else -1
|
||||
pid = os.fork() if False and (islinux or isbsd) else -1
|
||||
if pid <= 0:
|
||||
app = Application(args)
|
||||
app.setWindowIcon(QIcon(I('viewer.png')))
|
||||
|
@ -218,7 +218,7 @@ class LibraryServer(ContentServer, MobileServer, XMLServer, OPDSServer, Cache,
|
||||
cherrypy.engine.start()
|
||||
except:
|
||||
ip = get_external_ip()
|
||||
if not ip or ip == '127.0.0.1':
|
||||
if not ip or ip.startswith('127.'):
|
||||
raise
|
||||
cherrypy.log('Trying to bind to single interface: '+ip)
|
||||
cherrypy.config.update({'server.socket_host' : ip})
|
||||
|
@ -7,7 +7,7 @@ import sys, os, cPickle, textwrap, stat, importlib
|
||||
from subprocess import check_call
|
||||
|
||||
from calibre import __appname__, prints, guess_type
|
||||
from calibre.constants import islinux, isfreebsd
|
||||
from calibre.constants import islinux, isnetbsd, isbsd
|
||||
from calibre.customize.ui import all_input_formats
|
||||
from calibre.ptempfile import TemporaryDirectory
|
||||
from calibre import CurrentDir
|
||||
@ -136,17 +136,17 @@ class PostInstall:
|
||||
self.icon_resources = []
|
||||
self.menu_resources = []
|
||||
self.mime_resources = []
|
||||
if islinux or isfreebsd:
|
||||
if islinux or isbsd:
|
||||
self.setup_completion()
|
||||
self.install_man_pages()
|
||||
if islinux or isfreebsd:
|
||||
if islinux or isbsd:
|
||||
self.setup_desktop_integration()
|
||||
self.create_uninstaller()
|
||||
|
||||
from calibre.utils.config import config_dir
|
||||
if os.path.exists(config_dir):
|
||||
os.chdir(config_dir)
|
||||
if islinux or isfreebsd:
|
||||
if islinux or isbsd:
|
||||
for f in os.listdir('.'):
|
||||
if os.stat(f).st_uid == 0:
|
||||
import shutil
|
||||
@ -195,6 +195,9 @@ class PostInstall:
|
||||
'bash-completion')
|
||||
if os.path.exists(bc):
|
||||
f = os.path.join(bc, 'calibre')
|
||||
else:
|
||||
if isnetbsd:
|
||||
f = os.path.join(self.opts.staging_root, 'share/bash_completion.d/calibre')
|
||||
else:
|
||||
f = os.path.join(self.opts.staging_etc, 'bash_completion.d/calibre')
|
||||
if not os.path.exists(os.path.dirname(f)):
|
||||
@ -300,7 +303,7 @@ class PostInstall:
|
||||
def install_man_pages(self): # {{{
|
||||
try:
|
||||
from calibre.utils.help2man import create_man_page
|
||||
if isfreebsd:
|
||||
if isbsd:
|
||||
manpath = os.path.join(self.opts.staging_root, 'man/man1')
|
||||
else:
|
||||
manpath = os.path.join(self.opts.staging_sharedir, 'man/man1')
|
||||
@ -316,7 +319,7 @@ class PostInstall:
|
||||
continue
|
||||
parser = parser()
|
||||
raw = create_man_page(prog, parser)
|
||||
if isfreebsd:
|
||||
if isbsd:
|
||||
manfile = os.path.join(manpath, prog+'.1')
|
||||
else:
|
||||
manfile = os.path.join(manpath, prog+'.1'+__appname__+'.bz2')
|
||||
|
@ -8,14 +8,14 @@ __docformat__ = 'restructuredtext en'
|
||||
|
||||
import os, sys
|
||||
|
||||
from calibre.constants import plugins, iswindows, islinux, isfreebsd
|
||||
from calibre.constants import plugins, iswindows, islinux, isbsd
|
||||
|
||||
_fc, _fc_err = plugins['fontconfig']
|
||||
|
||||
if _fc is None:
|
||||
raise RuntimeError('Failed to load fontconfig with error:'+_fc_err)
|
||||
|
||||
if islinux or isfreebsd:
|
||||
if islinux or isbsd:
|
||||
Thread = object
|
||||
else:
|
||||
from threading import Thread
|
||||
@ -49,7 +49,7 @@ class FontConfig(Thread):
|
||||
self.failed = True
|
||||
|
||||
def wait(self):
|
||||
if not (islinux or isfreebsd):
|
||||
if not (islinux or isbsd):
|
||||
self.join()
|
||||
if self.failed:
|
||||
raise RuntimeError('Failed to initialize fontconfig')
|
||||
@ -149,7 +149,7 @@ class FontConfig(Thread):
|
||||
return fonts if all else (fonts[0] if fonts else None)
|
||||
|
||||
fontconfig = FontConfig()
|
||||
if islinux or isfreebsd:
|
||||
if islinux or isbsd:
|
||||
# On X11 Qt also uses fontconfig, so initialization must happen in the
|
||||
# main thread. In any case on X11 initializing fontconfig should be very
|
||||
# fast
|
||||
|
@ -4,7 +4,7 @@ __copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import time, bz2
|
||||
from calibre.constants import isfreebsd
|
||||
from calibre.constants import isbsd
|
||||
|
||||
from calibre.constants import __version__, __appname__, __author__
|
||||
|
||||
@ -58,7 +58,7 @@ def create_man_page(prog, parser):
|
||||
lines = [x if isinstance(x, unicode) else unicode(x, 'utf-8', 'replace') for
|
||||
x in lines]
|
||||
|
||||
if not isfreebsd:
|
||||
if not isbsd:
|
||||
return bz2.compress((u'\n'.join(lines)).encode('utf-8'))
|
||||
else:
|
||||
return (u'\n'.join(lines)).encode('utf-8')
|
||||
|
@ -13,16 +13,17 @@ def _get_external_ip():
|
||||
ipaddr = socket.gethostbyname(socket.gethostname())
|
||||
except:
|
||||
ipaddr = '127.0.0.1'
|
||||
if ipaddr == '127.0.0.1':
|
||||
if ipaddr.startswith('127.'):
|
||||
for addr in ('192.0.2.0', '198.51.100.0', 'google.com'):
|
||||
try:
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
s.connect((addr, 0))
|
||||
ipaddr = s.getsockname()[0]
|
||||
if ipaddr != '127.0.0.1':
|
||||
return ipaddr
|
||||
if not ipaddr.startswith('127.'):
|
||||
break
|
||||
except:
|
||||
time.sleep(0.3)
|
||||
#print 'ipaddr: %s' % ipaddr
|
||||
return ipaddr
|
||||
|
||||
_ext_ip = None
|
||||
|
@ -6,7 +6,7 @@ __license__ = 'GPL v3'
|
||||
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
from calibre.constants import iswindows, islinux, isfreebsd
|
||||
from calibre.constants import iswindows, islinux, isbsd
|
||||
|
||||
class LinuxNetworkStatus(object):
|
||||
|
||||
@ -47,7 +47,7 @@ class DummyNetworkStatus(object):
|
||||
return True
|
||||
|
||||
_network_status = WindowsNetworkStatus() if iswindows else \
|
||||
LinuxNetworkStatus() if (islinux or isfreebsd) else \
|
||||
LinuxNetworkStatus() if (islinux or isbsd) else \
|
||||
DummyNetworkStatus()
|
||||
|
||||
def internet_connected():
|
||||
|
Loading…
x
Reference in New Issue
Block a user