Skip to content

Commit

Permalink
Merge pull request #1154 from sphynx/better-plotting-error-message
Browse files Browse the repository at this point in the history
Make plot.py error message more helpful
  • Loading branch information
kbevers committed Oct 15, 2018
2 parents 249588a + 724e763 commit 85aab72
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions docs/plot/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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'],
Expand Down

0 comments on commit 85aab72

Please sign in to comment.