how to test for a dependency
Steven Bethard
steven.bethard at gmail.com
Mon Jan 9 19:57:22 EST 2006
Darren Dale wrote:
> I would like to test that latex is installed on a windows, mac or linux
> machine. What is the best way to do this? This should work:
>
> if os.system('latex -v'):
> print 'please install latex'
>
> but I dont actually want the latex version information to print to screen. I
> tried redirecting sys.stdout to a file, but that doesnt help. Is there a
> better way to do this in a cross-platform friendly way?
I've been using Trent's which package[1] for this kind of thing:
import which
try:
latex = which.which('latex')
except which.WhichError:
print 'please install latex'
STeVe
[1] http://starship.python.net/crew/tmick/#which
More information about the Python-list
mailing list