Show More
@@ -18,9 +18,11 b' import os' | |||||
18 | import sys |
|
18 | import sys | |
19 |
|
19 | |||
20 | from IPython.utils.traitlets import Integer, List, Bool |
|
20 | from IPython.utils.traitlets import Integer, List, Bool | |
|
21 | from IPython.utils.encoding import DEFAULT_ENCODING | |||
21 |
|
22 | |||
22 | from .base import PostProcessorBase |
|
23 | from .base import PostProcessorBase | |
23 |
|
24 | |||
|
25 | ||||
24 | #----------------------------------------------------------------------------- |
|
26 | #----------------------------------------------------------------------------- | |
25 | # Classes |
|
27 | # Classes | |
26 | #----------------------------------------------------------------------------- |
|
28 | #----------------------------------------------------------------------------- | |
@@ -68,13 +70,22 b' class PDFPostProcessor(PostProcessorBase):' | |||||
68 | A boolean indicating if the command was successful (True) |
|
70 | A boolean indicating if the command was successful (True) | |
69 | or failed (False). |
|
71 | or failed (False). | |
70 | """ |
|
72 | """ | |
|
73 | #HACK: Encode file name with the correct encoding | |||
|
74 | # For Windows must be cp1252 (win application) and we cannot use | |||
|
75 | # encoding.DEFAULT_ENCODING or sys.stdin.encoding because input | |||
|
76 | # encoding could be different (cp437 in case of dos console) | |||
|
77 | if sys.platform == 'win32': | |||
|
78 | filename = filename.encode('cp1252') | |||
|
79 | else: | |||
|
80 | filename = filename.encode('utf-8') | |||
|
81 | #END_HACK | |||
71 | command = [c.format(filename=filename) for c in command_list] |
|
82 | command = [c.format(filename=filename) for c in command_list] | |
72 | times = 'time' if count == 1 else 'times' |
|
83 | times = 'time' if count == 1 else 'times' | |
73 | self.log.info("Running %s %i %s: %s", command_list[0], count, times, command) |
|
84 | self.log.info("Running %s %i %s: %s", command_list[0], count, times, command) | |
74 | with open(os.devnull, 'rb') as null: |
|
85 | with open(os.devnull, 'rb') as null: | |
75 | stdout = subprocess.PIPE if not self.verbose else None |
|
86 | stdout = subprocess.PIPE if not self.verbose else None | |
76 | for index in range(count): |
|
87 | for index in range(count): | |
77 | p = subprocess.Popen(command, stdout=stdout, stdin=null) |
|
88 | p = subprocess.Popen(command, stdout=stdout, stdin=null, shell=True) | |
78 | out, err = p.communicate() |
|
89 | out, err = p.communicate() | |
79 | if p.returncode: |
|
90 | if p.returncode: | |
80 | if self.verbose: |
|
91 | if self.verbose: |
@@ -213,6 +213,5 b' class TestNbConvertApp(TestsBase):' | |||||
213 | o,e = self.call('nbconvert --log-level 0 --to latex ' |
|
213 | o,e = self.call('nbconvert --log-level 0 --to latex ' | |
214 | '"nb1_*" --post PDF ' |
|
214 | '"nb1_*" --post PDF ' | |
215 | '--PDFPostProcessor.verbose=True') |
|
215 | '--PDFPostProcessor.verbose=True') | |
216 | assert os.path.isfile('nb1_análisis.tex') |
|
216 | assert os.path.isfile(u'nb1_análisis.tex') | |
217 |
assert os.path.is |
|
217 | assert os.path.isfile(u'nb1_análisis.pdf') | |
218 | assert os.path.isfile('nb1_análisis.pdf') |
|
General Comments 0
You need to be logged in to leave comments.
Login now