mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Replace use of pickle for sending data to viewer print worker
This commit is contained in:
parent
74e316e20b
commit
6ad782cb29
@ -6,7 +6,7 @@ from __future__ import (unicode_literals, division, absolute_import,
|
|||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2015, Kovid Goyal <kovid at kovidgoyal.net>'
|
__copyright__ = '2015, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||||
|
|
||||||
import os, subprocess, cPickle, sys
|
import os, subprocess, sys
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
|
|
||||||
from PyQt5.Qt import (
|
from PyQt5.Qt import (
|
||||||
@ -22,6 +22,7 @@ from calibre.gui2.viewer.main import vprefs
|
|||||||
from calibre.utils.icu import numeric_sort_key
|
from calibre.utils.icu import numeric_sort_key
|
||||||
from calibre.utils.ipc.simple_worker import start_pipe_worker
|
from calibre.utils.ipc.simple_worker import start_pipe_worker
|
||||||
from calibre.utils.filenames import expanduser
|
from calibre.utils.filenames import expanduser
|
||||||
|
from calibre.utils.serialize import msgpack_dumps, msgpack_loads
|
||||||
|
|
||||||
|
|
||||||
class PrintDialog(Dialog):
|
class PrintDialog(Dialog):
|
||||||
@ -143,7 +144,7 @@ class DoPrint(Thread):
|
|||||||
try:
|
try:
|
||||||
with PersistentTemporaryFile('print-to-pdf-log.txt') as f:
|
with PersistentTemporaryFile('print-to-pdf-log.txt') as f:
|
||||||
p = self.worker = start_pipe_worker('from calibre.gui2.viewer.printing import do_print; do_print()', stdout=f, stderr=subprocess.STDOUT)
|
p = self.worker = start_pipe_worker('from calibre.gui2.viewer.printing import do_print; do_print()', stdout=f, stderr=subprocess.STDOUT)
|
||||||
p.stdin.write(cPickle.dumps(self.data, -1)), p.stdin.flush(), p.stdin.close()
|
p.stdin.write(msgpack_dumps(self.data)), p.stdin.flush(), p.stdin.close()
|
||||||
rc = p.wait()
|
rc = p.wait()
|
||||||
if rc != 0:
|
if rc != 0:
|
||||||
f.seek(0)
|
f.seek(0)
|
||||||
@ -159,7 +160,8 @@ class DoPrint(Thread):
|
|||||||
|
|
||||||
def do_print():
|
def do_print():
|
||||||
from calibre.customize.ui import plugin_for_input_format
|
from calibre.customize.ui import plugin_for_input_format
|
||||||
data = cPickle.loads(sys.stdin.read())
|
stdin = getattr(sys.stdin, 'buffer', sys.stdin)
|
||||||
|
data = msgpack_loads(stdin.read())
|
||||||
ext = data['input'].lower().rpartition('.')[-1]
|
ext = data['input'].lower().rpartition('.')[-1]
|
||||||
input_plugin = plugin_for_input_format(ext)
|
input_plugin = plugin_for_input_format(ext)
|
||||||
args = ['ebook-convert', data['input'], data['output'], '--paper-size', data['paper_size'], '--pdf-add-toc',
|
args = ['ebook-convert', data['input'], data['output'], '--paper-size', data['paper_size'], '--pdf-add-toc',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user