From 724e763db5309861aa4cc61d8e965af3f3c63f51 Mon Sep 17 00:00:00 2001 From: Ivan Veselov Date: Sun, 14 Oct 2018 16:53:07 +0100 Subject: Make plot.py error message more helpful --- docs/plot/plot.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'docs/plot') diff --git a/docs/plot/plot.py b/docs/plot/plot.py index 139281bf..a4f330f6 100644 --- a/docs/plot/plot.py +++ b/docs/plot/plot.py @@ -157,8 +157,14 @@ def project(coordinates, proj_string, in_radians=False): args = [PROJ, '-b'] args.extend(proj_string.split(' ')) - proc = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, - env={'PROJ_LIB': os.path.abspath(PROJ_LIB)}) + try: + proc = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, + env={'PROJ_LIB': os.path.abspath(PROJ_LIB)}) + except FileNotFoundError: + print("'proj' binary not found, please update PROJ constant in plot.py " + "to point to your local 'proj' binary") + exit(1) + stdout, _ = proc.communicate(coordinates.tobytes(order='C')) out = np.frombuffer(stdout, dtype=np.double) @@ -304,7 +310,7 @@ def plotproj(plotdef, data, outdir): # Make sure the plot is not stretched axes.set_aspect('equal') - + if not os.path.exists(outdir): os.makedirs(outdir) plt.savefig(outdir + '/' + plotdef['filename'], -- cgit v1.2.3