This commit is contained in:
Kovid Goyal 2008-05-09 21:08:22 -07:00
parent 5063d77e78
commit 595e0af269
3 changed files with 19 additions and 6 deletions

View File

@ -7,7 +7,7 @@ __author__ = "Kovid Goyal <kovid at kovidgoyal.net>"
__appname__ = 'calibre' __appname__ = 'calibre'
import sys, os, logging, mechanize, locale, copy, cStringIO, re, subprocess, \ import sys, os, logging, mechanize, locale, copy, cStringIO, re, subprocess, \
textwrap, atexit, cPickle, codecs textwrap, atexit, cPickle, codecs, time
from gettext import GNUTranslations from gettext import GNUTranslations
from math import floor from math import floor
from optparse import OptionParser as _OptionParser from optparse import OptionParser as _OptionParser
@ -527,3 +527,14 @@ class LoggingInterface:
def log_exception(self, msg, *args): def log_exception(self, msg, *args):
self.___log(self.__logger.exception, 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')

View File

@ -10,7 +10,7 @@ __docformat__ = "restructuredtext en"
import logging, os, cStringIO, time, traceback, re, urlparse import logging, os, cStringIO, time, traceback, re, urlparse
from collections import defaultdict 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.BeautifulSoup import BeautifulSoup, NavigableString, CData, Tag
from calibre.ebooks.metadata.opf import OPFCreator from calibre.ebooks.metadata.opf import OPFCreator
from calibre.ebooks.lrf import entity_to_unicode 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. @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')) 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'): for attr in ('username', 'password', 'lrf', 'output_dir', 'verbose', 'debug', 'test'):
setattr(self, attr, getattr(options, attr)) setattr(self, attr, getattr(options, attr))
@ -661,7 +663,7 @@ class BasicNewsRecipe(object, LoggingInterface):
def create_opf(self, feeds, dir=None): def create_opf(self, feeds, dir=None):
if dir is None: if dir is None:
dir = self.output_dir 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.publisher = __appname__
mi.author_sort = __appname__ mi.author_sort = __appname__
opf_path = os.path.join(dir, 'index.opf') opf_path = os.path.join(dir, 'index.opf')
@ -837,7 +839,7 @@ class CustomIndexRecipe(BasicNewsRecipe):
raise NotImplementedError raise NotImplementedError
def create_opf(self): 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.publisher = __appname__
mi.author_sort = __appname__ mi.author_sort = __appname__
mi = OPFCreator(self.output_dir, mi) mi = OPFCreator(self.output_dir, mi)

View File

@ -87,8 +87,8 @@ def upload_installers():
if exe and os.path.exists(exe): if exe and os.path.exists(exe):
check_call('''ssh divok rm -f %s/calibre\*.exe'''%(DOWNLOADS,)) check_call('''ssh divok rm -f %s/calibre\*.exe'''%(DOWNLOADS,))
check_call('''scp %s divok:%s/'''%(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): 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('''scp %s divok:%s/'''%(dmg, DOWNLOADS))
check_call('''ssh divok chmod a+r %s/\*'''%(DOWNLOADS,)) check_call('''ssh divok chmod a+r %s/\*'''%(DOWNLOADS,))