From 4e2780c4b3fce7d20206d307054115c8bfb381e1 Mon Sep 17 00:00:00 2001 From: nwin Date: Wed, 21 Jan 2015 10:28:17 +0100 Subject: [PATCH 1/3] More helpful error message Makes the error message more helpful if subprocess fails with a file-not-found-error. --- lib/matplotlib/backends/backend_pgf.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/backends/backend_pgf.py b/lib/matplotlib/backends/backend_pgf.py index c246bf978c1f..56d9a1d36600 100644 --- a/lib/matplotlib/backends/backend_pgf.py +++ b/lib/matplotlib/backends/backend_pgf.py @@ -6,6 +6,7 @@ import math import os import sys +import errno import re import shutil import tempfile @@ -316,8 +317,14 @@ def __init__(self): stdin=subprocess.PIPE, stdout=subprocess.PIPE, cwd=self.tmpdir) - except OSError: - raise RuntimeError("Error starting process '%s'" % self.texcommand) + except OSError, e: + if e.errno == errno.ENOENT: + raise OSError(errno.ENOENT, "Latex command not found. " + "Install '%s' or change pgf.texsystem to the desired command." + % self.texcommand + ) + else: + raise RuntimeError("Error starting process '%s'" % self.texcommand) test_input = self.latex_header + latex_end stdout, stderr = latex.communicate(test_input.encode("utf-8")) if latex.returncode != 0: From 4cdd4bd7d2ade9084a860b809f4b32e27ec6a2dd Mon Sep 17 00:00:00 2001 From: nwin Date: Wed, 21 Jan 2015 11:09:24 +0100 Subject: [PATCH 2/3] Make travis pass --- lib/matplotlib/backends/backend_pgf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/backends/backend_pgf.py b/lib/matplotlib/backends/backend_pgf.py index 56d9a1d36600..ad3184bd4cb8 100644 --- a/lib/matplotlib/backends/backend_pgf.py +++ b/lib/matplotlib/backends/backend_pgf.py @@ -317,7 +317,7 @@ def __init__(self): stdin=subprocess.PIPE, stdout=subprocess.PIPE, cwd=self.tmpdir) - except OSError, e: + except OSError as e: if e.errno == errno.ENOENT: raise OSError(errno.ENOENT, "Latex command not found. " "Install '%s' or change pgf.texsystem to the desired command." From 2cea2560ac49be3c6641d6e99a8beba43a6e2d99 Mon Sep 17 00:00:00 2001 From: nwin Date: Thu, 22 Jan 2015 08:13:45 +0100 Subject: [PATCH 3/3] Raise RuntimeError instead of OSError --- lib/matplotlib/backends/backend_pgf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/backends/backend_pgf.py b/lib/matplotlib/backends/backend_pgf.py index ad3184bd4cb8..60a47dc6126b 100644 --- a/lib/matplotlib/backends/backend_pgf.py +++ b/lib/matplotlib/backends/backend_pgf.py @@ -319,7 +319,7 @@ def __init__(self): cwd=self.tmpdir) except OSError as e: if e.errno == errno.ENOENT: - raise OSError(errno.ENOENT, "Latex command not found. " + raise RuntimeError("Latex command not found. " "Install '%s' or change pgf.texsystem to the desired command." % self.texcommand )