how to test for a dependency

Dennis Benzinger Dennis.Benzinger at gmx.net
Mon Jan 9 16:30:39 EST 2006


Darren Dale schrieb:
> Hello,
> 
> 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?
> 
> Thanks,
> Darren


I didn't try it, but you could use the subprocess module 
<http://python.org/doc/2.4.2/lib/module-subprocess.html>.
Create a Popen object with stdout = PIPE so that a pipe to the child 
process is created and connected to the client's stdout.


Bye,
Dennis



More information about the Python-list mailing list