Eclectic Media Git pingstats / 402c5b3
HOTFIX: Fixes keyerror crash on asciiplotlib missing! - Also adds more verbose output to pingstats.plot_pings Outputs message to notify user of fallback use of hipsterplotlib, with additional information about why the package used hipsterplotlib. - Extends asciiplotlib/gnuplot availability checks in pingstats.plot_pings - Using distutils.spawn.find_executable to locate the gnuplot binary allows for a system portable unix where command. - Extends fallback scenarios when check for asciiplotlib fails. Ariana Giroux 7 months ago
1 changed file(s) with 9 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
1212 # STANDARD LIBRARY PACKAGES
1313 from subprocess import Popen, PIPE
1414 from argparse import ArgumentParser
15 from distutils.spawn import find_executable
1516 from os import name
1617 from shutil import which
1718 import sys
204205 :columns: The number of columns to draw for the plot
205206 :rows: The number of rows to draw for the plot
206207 """
207 if sys.modules['asciiplotlib']:
208 __asciiplotlib_render(pings, columns=columns, rows=rows)
209 else:
208 try:
209 if sys.modules['asciiplotlib'] and find_executable('gnuplot'): # throws keyerror on module not found
210 __asciiplotlib_render(pings, columns=columns, rows=rows)
211 else:
212 print('Failed to find gnuplot on path! Using hipsterplot!')
213 __hipsterplot_render(pings, columns=columns, rows=rows)
214 except KeyError:
215 print('asciiplotlib not found in python modules! Using hipsterplot!')
210216 __hipsterplot_render(pings, columns=columns, rows=rows)