##// END OF EJS Templates
solved pdf postprocess issue for nb with accented names
marcmolla -
Show More
@@ -18,9 +18,11 b' import os'
18 18 import sys
19 19
20 20 from IPython.utils.traitlets import Integer, List, Bool
21 from IPython.utils.encoding import DEFAULT_ENCODING
21 22
22 23 from .base import PostProcessorBase
23 24
25
24 26 #-----------------------------------------------------------------------------
25 27 # Classes
26 28 #-----------------------------------------------------------------------------
@@ -68,13 +70,22 b' class PDFPostProcessor(PostProcessorBase):'
68 70 A boolean indicating if the command was successful (True)
69 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 82 command = [c.format(filename=filename) for c in command_list]
72 83 times = 'time' if count == 1 else 'times'
73 84 self.log.info("Running %s %i %s: %s", command_list[0], count, times, command)
74 85 with open(os.devnull, 'rb') as null:
75 86 stdout = subprocess.PIPE if not self.verbose else None
76 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 89 out, err = p.communicate()
79 90 if p.returncode:
80 91 if self.verbose:
@@ -213,6 +213,5 b' class TestNbConvertApp(TestsBase):'
213 213 o,e = self.call('nbconvert --log-level 0 --to latex '
214 214 '"nb1_*" --post PDF '
215 215 '--PDFPostProcessor.verbose=True')
216 assert os.path.isfile('nb1_análisis.tex')
217 assert os.path.isdir('nb1_análisis_files')
218 assert os.path.isfile('nb1_análisis.pdf')
216 assert os.path.isfile(u'nb1_análisis.tex')
217 assert os.path.isfile(u'nb1_análisis.pdf')
General Comments 0
You need to be logged in to leave comments. Login now