diff --git a/IPython/nbconvert/postprocessors/pdf.py b/IPython/nbconvert/postprocessors/pdf.py index db00144..daba66c 100644 --- a/IPython/nbconvert/postprocessors/pdf.py +++ b/IPython/nbconvert/postprocessors/pdf.py @@ -31,10 +31,10 @@ class PDFPostProcessor(PostProcessorBase): How many times pdflatex will be called. """) - latex_command = List(["pdflatex", "{filename}"], config=True, help=""" + latex_command = List([u"pdflatex", u"{filename}"], config=True, help=""" Shell command used to compile PDF.""") - bib_command = List(["bibtex", "{filename}"], config=True, help=""" + bib_command = List([u"bibtex", u"{filename}"], config=True, help=""" Shell command used to run bibtex.""") verbose = Bool(False, config=True, help=""" @@ -69,6 +69,13 @@ class PDFPostProcessor(PostProcessorBase): or failed (False). """ command = [c.format(filename=filename) for c in command_list] + #In windows and python 2.x there is a bug in subprocess.Popen and + # unicode commands are not supported + if sys.platform == 'win32' and sys.version_info < (3,0): + #We must use cp1252 encoding for calling subprocess.Popen + #Note that sys.stdin.encoding and encoding.DEFAULT_ENCODING + # could be different (cp437 in case of dos console) + command = [c.encode('cp1252') for c in command] times = 'time' if count == 1 else 'times' self.log.info("Running %s %i %s: %s", command_list[0], count, times, command) with open(os.devnull, 'rb') as null: diff --git "a/IPython/nbconvert/tests/files/nb1_an\303\241lisis.ipynb" "b/IPython/nbconvert/tests/files/nb1_an\303\241lisis.ipynb" new file mode 100644 index 0000000..35524ef --- /dev/null +++ "b/IPython/nbconvert/tests/files/nb1_an\303\241lisis.ipynb" @@ -0,0 +1,22 @@ +{ + "metadata": { + "name": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/IPython/nbconvert/tests/test_nbconvertapp.py b/IPython/nbconvert/tests/test_nbconvertapp.py index 9a33a53..123a3a6 100644 --- a/IPython/nbconvert/tests/test_nbconvertapp.py +++ b/IPython/nbconvert/tests/test_nbconvertapp.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- """Test NbConvertApp""" #----------------------------------------------------------------------------- @@ -183,3 +184,24 @@ class TestNbConvertApp(TestsBase): self.call('nbconvert --log-level 0 --config="override.py"') assert not os.path.isfile('notebook1.py') assert os.path.isfile('notebook2.py') + + def test_accents_in_filename(self): + """ + Can notebook names include accents? + """ + with self.create_temp_cwd(['nb*.ipynb']): + self.call('nbconvert --log-level 0 --to python nb1_*') + assert os.path.isfile(u'nb1_análisis.py') + + @dec.onlyif_cmds_exist('pdflatex') + @dec.onlyif_cmds_exist('pandoc') + def test_filename_spaces(self): + """ + Generate PDFs if notebooks have an accent in their name? + """ + with self.create_temp_cwd(['nb*.ipynb']): + o,e = self.call('nbconvert --log-level 0 --to latex ' + '"nb1_*" --post PDF ' + '--PDFPostProcessor.verbose=True') + assert os.path.isfile(u'nb1_análisis.tex') + assert os.path.isfile(u'nb1_análisis.pdf')