mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #644
This commit is contained in:
parent
5063d77e78
commit
595e0af269
@ -7,7 +7,7 @@ __author__ = "Kovid Goyal <kovid at kovidgoyal.net>"
|
||||
__appname__ = 'calibre'
|
||||
|
||||
import sys, os, logging, mechanize, locale, copy, cStringIO, re, subprocess, \
|
||||
textwrap, atexit, cPickle, codecs
|
||||
textwrap, atexit, cPickle, codecs, time
|
||||
from gettext import GNUTranslations
|
||||
from math import floor
|
||||
from optparse import OptionParser as _OptionParser
|
||||
@ -527,3 +527,14 @@ class LoggingInterface:
|
||||
|
||||
def log_exception(self, msg, *args):
|
||||
self.___log(self.__logger.exception, msg, args, {})
|
||||
|
||||
|
||||
def strftime(fmt, t=time.localtime()):
|
||||
'''
|
||||
A version of strtime that returns unicode strings.
|
||||
'''
|
||||
result = time.strftime(fmt, t)
|
||||
try:
|
||||
return unicode(result, locale.getpreferredencoding(), 'replace')
|
||||
except:
|
||||
return unicode(result, 'utf-8', 'replace')
|
||||
|
@ -10,7 +10,7 @@ __docformat__ = "restructuredtext en"
|
||||
import logging, os, cStringIO, time, traceback, re, urlparse
|
||||
from collections import defaultdict
|
||||
|
||||
from calibre import browser, __appname__, iswindows, LoggingInterface
|
||||
from calibre import browser, __appname__, iswindows, LoggingInterface, strftime
|
||||
from calibre.ebooks.BeautifulSoup import BeautifulSoup, NavigableString, CData, Tag
|
||||
from calibre.ebooks.metadata.opf import OPFCreator
|
||||
from calibre.ebooks.lrf import entity_to_unicode
|
||||
@ -364,6 +364,8 @@ class BasicNewsRecipe(object, LoggingInterface):
|
||||
@param progress_reporter: A Callable that takes two arguments: progress (a number between 0 and 1) and a string message. The message should be optional.
|
||||
'''
|
||||
LoggingInterface.__init__(self, logging.getLogger('feeds2disk'))
|
||||
if not isinstance(self.title, unicode):
|
||||
self.title = unicode(self.title, 'utf-8', 'replace')
|
||||
|
||||
for attr in ('username', 'password', 'lrf', 'output_dir', 'verbose', 'debug', 'test'):
|
||||
setattr(self, attr, getattr(options, attr))
|
||||
@ -661,7 +663,7 @@ class BasicNewsRecipe(object, LoggingInterface):
|
||||
def create_opf(self, feeds, dir=None):
|
||||
if dir is None:
|
||||
dir = self.output_dir
|
||||
mi = MetaInformation(self.title + time.strftime(self.timefmt), [__appname__])
|
||||
mi = MetaInformation(self.title + strftime(self.timefmt), [__appname__])
|
||||
mi.publisher = __appname__
|
||||
mi.author_sort = __appname__
|
||||
opf_path = os.path.join(dir, 'index.opf')
|
||||
@ -837,7 +839,7 @@ class CustomIndexRecipe(BasicNewsRecipe):
|
||||
raise NotImplementedError
|
||||
|
||||
def create_opf(self):
|
||||
mi = MetaInformation(self.title + time.strftime(self.timefmt), [__appname__])
|
||||
mi = MetaInformation(self.title + strftime(self.timefmt), [__appname__])
|
||||
mi.publisher = __appname__
|
||||
mi.author_sort = __appname__
|
||||
mi = OPFCreator(self.output_dir, mi)
|
||||
|
@ -87,10 +87,10 @@ def upload_installers():
|
||||
if exe and os.path.exists(exe):
|
||||
check_call('''ssh divok rm -f %s/calibre\*.exe'''%(DOWNLOADS,))
|
||||
check_call('''scp %s divok:%s/'''%(exe, DOWNLOADS))
|
||||
check_call('''ssh divok rm -f %s/calibre\*.dmg'''%(DOWNLOADS,))
|
||||
if dmg and os.path.exists(dmg):
|
||||
check_call('''ssh divok rm -f %s/calibre\*.dmg'''%(DOWNLOADS,))
|
||||
check_call('''scp %s divok:%s/'''%(dmg, DOWNLOADS))
|
||||
check_call('''ssh divok chmod a+r %s/\*'''%(DOWNLOADS,))
|
||||
check_call('''ssh divok chmod a+r %s/\*'''%(DOWNLOADS,))
|
||||
|
||||
def upload_docs():
|
||||
check_call('''epydoc --config epydoc.conf''')
|
||||
|
Loading…
x
Reference in New Issue
Block a user