diff --git a/egret/viz/generate_graphs.py b/egret/viz/generate_graphs.py index ad5fc416..4a0c9587 100644 --- a/egret/viz/generate_graphs.py +++ b/egret/viz/generate_graphs.py @@ -1,12 +1,17 @@ import os +import sys from collections import namedtuple, defaultdict import datetime import textwrap import matplotlib as mpl -## catch when we're running linux without X -if os.name == 'posix' and 'DISPLAY' not in os.environ: - mpl.use('Agg') +if not hasattr(sys, 'ps1'): + # Not in interactive mode, so use the AGG backend for + # systems without GUIs (which probably will not be run + # in interactive mode). See the discussion on + # https://stackoverflow.com/questions/2356399/tell-if-python-is-in-interactive-mode + # and the definition https://docs.python.org/3/library/sys.html#sys.ps1 + mpl.use('AGG') import matplotlib.pyplot as plt import matplotlib.ticker as ticker