Use text mode streams for metadata logging

This commit is contained in:
Kovid Goyal 2019-12-19 08:17:42 +05:30
parent 1d33b3dc0c
commit 19145e4bd3
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 5 additions and 5 deletions

View File

@ -8,7 +8,7 @@ __docformat__ = 'restructuredtext en'
import time import time
from threading import Thread, Event from threading import Thread, Event
from io import BytesIO from io import StringIO
from calibre.customize.ui import metadata_plugins from calibre.customize.ui import metadata_plugins
from calibre.ebooks.metadata.sources.base import create_log from calibre.ebooks.metadata.sources.base import create_log
@ -27,7 +27,7 @@ class Worker(Thread):
self.plugin = plugin self.plugin = plugin
self.abort = abort self.abort = abort
self.get_best_cover = get_best_cover self.get_best_cover = get_best_cover
self.buf = BytesIO() self.buf = StringIO()
self.log = create_log(self.buf) self.log = create_log(self.buf)
self.title, self.authors, self.identifiers = (title, authors, self.title, self.authors, self.identifiers = (title, authors,
identifiers) identifiers)

View File

@ -9,7 +9,7 @@ __docformat__ = 'restructuredtext en'
import time, re import time, re
from datetime import datetime from datetime import datetime
from threading import Thread from threading import Thread
from io import BytesIO from io import StringIO
from operator import attrgetter from operator import attrgetter
from polyglot.urllib import urlparse, quote from polyglot.urllib import urlparse, quote
@ -38,7 +38,7 @@ class Worker(Thread):
self.plugin, self.kwargs, self.rq = plugin, kwargs, Queue() self.plugin, self.kwargs, self.rq = plugin, kwargs, Queue()
self.abort = abort self.abort = abort
self.buf = BytesIO() self.buf = StringIO()
self.log = create_log(self.buf) self.log = create_log(self.buf)
def run(self): def run(self):

View File

@ -126,7 +126,7 @@ def pubdate_test(year, month, day):
def init_test(tdir_name): def init_test(tdir_name):
tdir = tempfile.gettempdir() tdir = tempfile.gettempdir()
lf = os.path.join(tdir, tdir_name.replace(' ', '')+'_identify_test.txt') lf = os.path.join(tdir, tdir_name.replace(' ', '')+'_identify_test.txt')
log = create_log(open(lf, 'wb')) log = create_log(open(lf, 'w'))
abort = Event() abort = Event()
return tdir, lf, log, abort return tdir, lf, log, abort