From 3bf04735c137bbe32cbced746cbc3e560724ccf9 Mon Sep 17 00:00:00 2001 From: Javi Merino Date: Thu, 16 Apr 2015 19:17:51 +0100 Subject: [PATCH] Factor out ipython nbconvert in ipynb_exporter results processor ipython nbconvert CLI changes between ipython 2 and 3, so keep the string separate so that we can update when we add ipython version 3 support. --- wlauto/utils/ipython.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/wlauto/utils/ipython.py b/wlauto/utils/ipython.py index 52a34513..6ac4d323 100644 --- a/wlauto/utils/ipython.py +++ b/wlauto/utils/ipython.py @@ -40,6 +40,8 @@ if IPython and (IPython.version_info[0] == 2): NotebookNode = IPython.nbformat.v3.NotebookNode + IPYTHON_NBCONVERT = ['ipython', 'nbconvert', '--to=latex', '--post=PDF'] + elif IPython: # Unsupported IPython version IPython_ver_str = ".".join([str(n) for n in IPython.version_info]) @@ -120,11 +122,8 @@ def generate_pdf(nbbasename, output_directory): prev_dir = os.getcwd() os.chdir(output_directory) - ipython_nbconvert = ['ipython', 'nbconvert', '--to=latex', '--post=PDF', - nbbasename] - with open(os.devnull, 'w') as devnull: - subprocess.check_call(ipython_nbconvert, stderr=devnull) + subprocess.check_call(IPYTHON_NBCONVERT + [nbbasename], stderr=devnull) os.chdir(prev_dir)