##// END OF EJS Templates
wait for subprocess to finish
Paul Ivanov -
Show More
@@ -1,52 +1,51 b''
1 """
1 """
2 Contains writer for writing nbconvert output to PDF.
2 Contains writer for writing nbconvert output to PDF.
3 """
3 """
4 #-----------------------------------------------------------------------------
4 #-----------------------------------------------------------------------------
5 #Copyright (c) 2013, the IPython Development Team.
5 #Copyright (c) 2013, the IPython Development Team.
6 #
6 #
7 #Distributed under the terms of the Modified BSD License.
7 #Distributed under the terms of the Modified BSD License.
8 #
8 #
9 #The full license is in the file COPYING.txt, distributed with this software.
9 #The full license is in the file COPYING.txt, distributed with this software.
10 #-----------------------------------------------------------------------------
10 #-----------------------------------------------------------------------------
11
11
12 #-----------------------------------------------------------------------------
12 #-----------------------------------------------------------------------------
13 # Imports
13 # Imports
14 #-----------------------------------------------------------------------------
14 #-----------------------------------------------------------------------------
15
15
16 import subprocess
16 import subprocess
17 import os
17 import os
18
18
19 from IPython.utils.traitlets import Integer, List, Bool
19 from IPython.utils.traitlets import Integer, List, Bool
20
20
21 from .base import PostProcessorBase
21 from .base import PostProcessorBase
22
22
23 #-----------------------------------------------------------------------------
23 #-----------------------------------------------------------------------------
24 # Classes
24 # Classes
25 #-----------------------------------------------------------------------------
25 #-----------------------------------------------------------------------------
26 class PDFPostProcessor(PostProcessorBase):
26 class PDFPostProcessor(PostProcessorBase):
27 """Writer designed to write to PDF files"""
27 """Writer designed to write to PDF files"""
28
28
29 iteration_count = Integer(3, config=True, help="""
29 iteration_count = Integer(3, config=True, help="""
30 How many times pdflatex will be called.
30 How many times pdflatex will be called.
31 """)
31 """)
32
32
33 command = List(["pdflatex", "{filename}"], config=True, help="""
33 command = List(["pdflatex", "{filename}"], config=True, help="""
34 Shell command used to compile PDF.""")
34 Shell command used to compile PDF.""")
35
35
36 verbose = Bool(False, config=True, help="""
36 verbose = Bool(False, config=True, help="""
37 Whether or not to display the output of the compile call.
37 Whether or not to display the output of the compile call.
38 """)
38 """)
39
39
40 def call(self, input):
40 def call(self, input):
41 """
41 """
42 Consume and write Jinja output a PDF.
42 Consume and write Jinja output a PDF.
43 See files.py for more...
43 See files.py for more...
44 """
44 """
45 command = [c.format(filename=input) for c in self.command]
45 command = [c.format(filename=input) for c in self.command]
46 self.log.info("Building PDF: `%s`", ' '.join(command))
46 self.log.info("Building PDF: `%s`", ' '.join(command))
47 for index in range(self.iteration_count):
47 with open(os.devnull, 'wb') as null:
48 if self.verbose:
48 stdout = null if self.verbose else None
49 subprocess.Popen(command)
49 for index in range(self.iteration_count):
50 else:
50 p = subprocess.Popen(command, stdout=stdout)
51 with open(os.devnull, 'wb') as null:
51 p.wait()
52 subprocess.Popen(command, stdout=null)
General Comments 0
You need to be logged in to leave comments. Login now