Merge lp:~john-peterson/calibre/log into lp:calibre

Proposed by John Peterson
Status: Needs review
Proposed branch: lp:~john-peterson/calibre/log
Merge into: lp:calibre
Diff against target: 246 lines (+19/-43)
11 files modified
src/calibre/ebooks/metadata/pdf.py (+0/-4)
src/calibre/ebooks/metadata/sources/identify.py (+2/-1)
src/calibre/ebooks/metadata/sources/worker.py (+2/-2)
src/calibre/ebooks/mobi/tweak.py (+3/-4)
src/calibre/ebooks/oeb/polish/container.py (+1/-1)
src/calibre/gui2/auto_add.py (+1/-1)
src/calibre/gui2/metadata/bulk_download.py (+1/-1)
src/calibre/gui2/metadata/single_download.py (+2/-3)
src/calibre/utils/ipc/launch.py (+5/-13)
src/calibre/utils/ipc/simple_worker.py (+1/-12)
src/calibre/utils/serve_coffee.py (+1/-1)
To merge this branch: bzr merge lp:~john-peterson/calibre/log
Reviewer Review Type Date Requested Status
Kovid Goyal Pending
Review via email: mp+147657@code.launchpad.net

Description of the change

To post a comment you must log in.

Unmerged revisions

14270. By John Peterson

Adding missing exception message

14269. By John Peterson

Changing `calibre-parallel` output connection from file to pipe and always print its output

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/calibre/ebooks/metadata/pdf.py'
2--- src/calibre/ebooks/metadata/pdf.py 2013-01-30 08:54:26 +0000
3+++ src/calibre/ebooks/metadata/pdf.py 2013-02-11 13:30:31 +0000
4@@ -87,10 +87,6 @@
5 prints(e.orig_tb)
6 raise RuntimeError('Failed to run pdfinfo')
7 info = res['result']
8- with open(res['stdout_stderr'], 'rb') as f:
9- raw = f.read().strip()
10- if raw:
11- prints(raw)
12 if not info:
13 raise ValueError('Could not read info dict from PDF')
14 covpath = os.path.join(pdfpath, 'cover.jpg')
15
16=== modified file 'src/calibre/ebooks/metadata/sources/identify.py'
17--- src/calibre/ebooks/metadata/sources/identify.py 2012-12-15 18:54:14 +0000
18+++ src/calibre/ebooks/metadata/sources/identify.py 2013-02-11 13:30:31 +0000
19@@ -7,7 +7,7 @@
20 __copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>'
21 __docformat__ = 'restructuredtext en'
22
23-import time
24+import time, traceback
25 from datetime import datetime
26 from Queue import Queue, Empty
27 from threading import Thread
28@@ -41,6 +41,7 @@
29 try:
30 self.plugin.identify(self.log, self.rq, self.abort, **self.kwargs)
31 except:
32+ traceback.print_exc()
33 self.log.exception('Plugin', self.plugin.name, 'failed')
34 self.plugin.dl_time_spent = time.time() - start
35
36
37=== modified file 'src/calibre/ebooks/metadata/sources/worker.py'
38--- src/calibre/ebooks/metadata/sources/worker.py 2012-04-12 09:50:24 +0000
39+++ src/calibre/ebooks/metadata/sources/worker.py 2013-02-11 13:30:31 +0000
40@@ -7,7 +7,7 @@
41 __copyright__ = '2012, Kovid Goyal <kovid@kovidgoyal.net>'
42 __docformat__ = 'restructuredtext en'
43
44-import os
45+import os, traceback
46 from threading import Event, Thread
47 from Queue import Queue, Empty
48 from io import BytesIO
49@@ -68,7 +68,7 @@
50 results = identify(log, Event(), title=title, authors=authors,
51 identifiers=identifiers)
52 except:
53- pass
54+ traceback.print_exc()
55 if results:
56 all_failed = False
57 mi = merge_result(mi, results[0], ensure_fields=ensure_fields)
58
59=== modified file 'src/calibre/ebooks/mobi/tweak.py'
60--- src/calibre/ebooks/mobi/tweak.py 2012-05-21 07:58:25 +0000
61+++ src/calibre/ebooks/mobi/tweak.py 2013-02-11 13:30:31 +0000
62@@ -69,7 +69,7 @@
63 return None
64
65 return fork_job('calibre.ebooks.mobi.tweak', 'do_explode', args=(path,
66- dest), no_output=True)['result']
67+ dest))['result']
68
69 def set_cover(oeb):
70 if 'cover' not in oeb.guide or oeb.metadata['cover']: return
71@@ -96,7 +96,6 @@
72 raise ValueError('No OPF file found in %s'%src_dir)
73 opf = opf[0]
74 # For debugging, uncomment the following line
75- # def fork_job(a, b, args=None, no_output=True): do_rebuild(*args)
76- fork_job('calibre.ebooks.mobi.tweak', 'do_rebuild', args=(opf, dest_path),
77- no_output=True)
78+ # def fork_job(a, b, args=None): do_rebuild(*args)
79+ fork_job('calibre.ebooks.mobi.tweak', 'do_rebuild', args=(opf, dest_path))
80
81
82=== modified file 'src/calibre/ebooks/oeb/polish/container.py'
83--- src/calibre/ebooks/oeb/polish/container.py 2013-02-10 12:14:33 +0000
84+++ src/calibre/ebooks/oeb/polish/container.py 2013-02-11 13:30:31 +0000
85@@ -534,7 +534,7 @@
86 try:
87 opf_path, obfuscated_fonts = fork_job(
88 'calibre.ebooks.oeb.polish.container', 'do_explode',
89- args=(pathtoazw3, tdir), no_output=True)['result']
90+ args=(pathtoazw3, tdir))['result']
91 except WorkerError as e:
92 log(e.orig_tb)
93 raise InvalidMobi('Failed to explode MOBI')
94
95=== modified file 'src/calibre/gui2/auto_add.py'
96--- src/calibre/gui2/auto_add.py 2012-03-30 13:25:38 +0000
97+++ src/calibre/gui2/auto_add.py 2013-02-11 13:30:31 +0000
98@@ -78,7 +78,7 @@
99 tdir = tempfile.mkdtemp(dir=self.tdir)
100 try:
101 fork_job('calibre.ebooks.metadata.meta',
102- 'forked_read_metadata', (f, tdir), no_output=True)
103+ 'forked_read_metadata', (f, tdir))
104 except WorkerError as e:
105 prints('Failed to read metadata from:', fname)
106 prints(e.orig_tb)
107
108=== modified file 'src/calibre/gui2/metadata/bulk_download.py'
109--- src/calibre/gui2/metadata/bulk_download.py 2012-04-12 09:50:24 +0000
110+++ src/calibre/gui2/metadata/bulk_download.py 2013-02-11 13:30:31 +0000
111@@ -233,7 +233,7 @@
112 try:
113 ret = fork_job('calibre.ebooks.metadata.sources.worker', 'main',
114 (do_identify, covers, metadata, ensure_fields, tdir),
115- abort=abort, heartbeat=heartbeat, no_output=True)
116+ abort=abort, heartbeat=heartbeat)
117 except WorkerError as e:
118 if e.orig_tb:
119 raise Exception('Failed to download metadata. Original '
120
121=== modified file 'src/calibre/gui2/metadata/single_download.py'
122--- src/calibre/gui2/metadata/single_download.py 2013-02-06 03:46:24 +0000
123+++ src/calibre/gui2/metadata/single_download.py 2013-02-11 13:30:31 +0000
124@@ -424,7 +424,7 @@
125 res = fork_job(
126 'calibre.ebooks.metadata.sources.worker',
127 'single_identify', (self.title, self.authors,
128- self.identifiers), no_output=True, abort=self.abort)
129+ self.identifiers), abort=self.abort)
130 self.results, covers, caches, log_dump = res['result']
131 self.results = [OPF(BytesIO(r), basedir=os.getcwdu(),
132 populate_spine=False).to_book_metadata() for r in self.results]
133@@ -601,8 +601,7 @@
134 res = fork_job('calibre.ebooks.metadata.sources.worker',
135 'single_covers',
136 (self.title, self.authors, self.identifiers, self.caches,
137- tdir),
138- no_output=True, abort=self.abort)
139+ tdir), abort=self.abort)
140 self.log.append_dump(res['result'])
141 finally:
142 self.keep_going = False
143
144=== modified file 'src/calibre/utils/ipc/launch.py'
145--- src/calibre/utils/ipc/launch.py 2012-04-02 12:29:01 +0000
146+++ src/calibre/utils/ipc/launch.py 2013-02-11 13:30:31 +0000
147@@ -120,14 +120,12 @@
148 if not hasattr(self, 'child'): return None
149 return getattr(self.child, 'pid', None)
150
151- def close_log_file(self):
152- try:
153- self._file.close()
154- except:
155- pass
156+ def print_output(self):
157+ out, err = self.child.communicate()
158+ print out, '\n', err
159
160 def kill(self):
161- self.close_log_file()
162+ self.print_output()
163 try:
164 if self.is_alive:
165 if iswindows:
166@@ -192,12 +190,10 @@
167 args['preexec_fn'] = partial(renice, niceness)
168 ret = None
169 if redirect_output:
170- self._file = PersistentTemporaryFile('_worker_redirect.log')
171- args['stdout'] = self._file._fd
172+ args['stdout'] = subprocess.PIPE
173 args['stderr'] = subprocess.STDOUT
174 if iswindows:
175 args['stdin'] = subprocess.PIPE
176- ret = self._file.name
177
178 if iswindows and 'stdin' not in args:
179 # On windows when using the pythonw interpreter,
180@@ -216,8 +212,4 @@
181 if 'stdin' in args:
182 self.child.stdin.close()
183
184- self.log_path = ret
185- return ret
186-
187-
188
189
190=== modified file 'src/calibre/utils/ipc/simple_worker.py'
191--- src/calibre/utils/ipc/simple_worker.py 2012-12-07 10:17:49 +0000
192+++ src/calibre/utils/ipc/simple_worker.py 2013-02-11 13:30:31 +0000
193@@ -84,7 +84,7 @@
194 ans['result'] = cw.res['result']
195
196 def fork_job(mod_name, func_name, args=(), kwargs={}, timeout=300, # seconds
197- cwd=None, priority='normal', env={}, no_output=False, heartbeat=None,
198+ cwd=None, priority='normal', env={}, heartbeat=None,
199 abort=None, module_is_source_code=False):
200 '''
201 Run a job in a worker process. A job is simply a function that will be
202@@ -112,9 +112,6 @@
203
204 :param env: Extra environment variables to set for the worker process
205
206- :param no_output: If True, the stdout and stderr of the worker process are
207- discarded
208-
209 :param heartbeat: If not None, it is used to check if the worker has hung,
210 instead of a simple timeout. It must be a callable that takes no
211 arguments and returns True or False. The worker will be assumed to have
212@@ -132,7 +129,6 @@
213 :return: A dictionary with the keys result and stdout_stderr. result is the
214 return value of the function (it must be picklable). stdout_stderr is the
215 path to a file that contains the stdout and stderr of the worker process.
216- If you set no_output=True, then this will not be present.
217 '''
218
219 ans = {'result':None, 'stdout_stderr':None}
220@@ -162,13 +158,6 @@
221 t = Thread(target=w.kill)
222 t.daemon=True
223 t.start()
224- if no_output:
225- try:
226- os.remove(w.log_path)
227- except:
228- pass
229- if not no_output:
230- ans['stdout_stderr'] = w.log_path
231 return ans
232
233 def compile_code(src):
234
235=== modified file 'src/calibre/utils/serve_coffee.py'
236--- src/calibre/utils/serve_coffee.py 2012-06-20 08:56:05 +0000
237+++ src/calibre/utils/serve_coffee.py 2013-02-11 13:30:31 +0000
238@@ -98,7 +98,7 @@
239 except NameError:
240 from calibre.utils.ipc.simple_worker import fork_job
241 return fork_job('calibre.utils.serve_coffee', 'do_compile',
242- args=(raw,), no_output=True)['result']
243+ args=(raw,))['result']
244
245 class HTTPRequestHandler(SimpleHTTPRequestHandler): # {{{
246 '''

Subscribers

People subscribed via source and target branches