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 5 1032
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
Darren Dale enlightened us with: 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'
The downside is that you can only use this to test by executing.
Perhaps it would be better to make a function that can search the PATH
environment variable in a cross-platform way. Also make sure you
include any platform-specific executable postfixes like Window's
".exe".
Sybren
--
The problem with the world is stupidity. Not saying there should be a
capital punishment for stupidity, but why don't we just take the
safety labels off of everything and let the problem solve itself?
Frank Zappa
Dennis Benzinger wrote: 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.
Thanks for the suggestion, that would probably work. Unfortunately, I need
to support Python 2.3 for some time to come.
I wonder, will this work across platforms?
if os.system('latex -v > temp.log'): print 'install latex'
Sybren Stuvel wrote: Darren Dale enlightened us with: 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'
The downside is that you can only use this to test by executing. Perhaps it would be better to make a function that can search the PATH environment variable in a cross-platform way. Also make sure you include any platform-specific executable postfixes like Window's ".exe".
I guess that would work. I was hoping there was a more elegant, batteries
included way to do it.
By the way, great Zappa quote.
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Tim Haughton |
last post by:
I've just released an article on using Test Driven Development with C# and
Windows Forms. GUI's are often difficult to test, so I thought it might be
of interest.
The article along with the...
|
by: Tim Haughton |
last post by:
I've just released an article on using Test Driven Development with C# and
Windows Forms. GUI's are often difficult to test, so I thought it might be
of interest.
The article along with the...
|
by: Jay A. Moritz |
last post by:
Error: The dependency '<my dll>' in project '<my project>' cannot be copied
to the run directory because it would conflict with dependency '<my dll>'.
I am getting a dependency error building...
|
by: DJTN |
last post by:
I'm getting the following error when I try to compile my setup project in VS
2002. I have re-installed the .net framework 1.1 and it didnt solve the
problem.
WARNING: Unable to find dependency...
|
by: Tim Haughton |
last post by:
I've just released an article on using Test Driven Development with C# and
Windows Forms. GUI's are often difficult to test, so I thought it might be
of interest.
The article along with the...
|
by: Brett Romero |
last post by:
I have two projects in one solution - a library and executable. Each
have a namespace such as:
ROOT.myapp.Functional
ROOT.myapp.UI
However, each cannot reference the other. myapp.UI is...
|
by: deanhiller |
last post by:
In C++ or Java, or whatever OO, I am used to using the Dependency
Injection Pattern(or I believe formerly called Inversion of Control
Pattern) to accomplish test first in a large system. ie. I...
|
by: =?Utf-8?B?SmFzb24gUmljaG1laWVy?= |
last post by:
I came across a code sample in a book that I am reading that uses a
dependency property. I looked at some of the documentation for dependency
properties but, for some reason, the concept is not...
|
by: vincentt |
last post by:
Hi,
We code DLL's and so far it was done using VS6.0. We are planning to migrate the VS.NET 2005 and use the VS6 VC++ code which generated the DLL to VS 2005 VC++.NET.
However we donot plan to...
|
by: DeveloperX |
last post by:
Hi, I'm struggling to work out how to unit test threading. Is there
any advice out there? I'll take books, blogs and especially your
experience.
I can't be more specific, I just don't know how...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |