Getting information from OS
Christopher T King
squirrel at WPI.EDU
Thu Jul 22 10:02:38 EDT 2004
On Wed, 21 Jul 2004 Skulled2003 at netscape.net wrote:
> What i need to accomplish is a list of languages that are installed
> or can be viewed on the system. I am not sure if i am making it clear,
> but the list should contain information on the languages that a system
> can recognize and use in applications etc.
Is this on Unix or Windows? On Unix, something like the following would
work:
-----
import os
from os.path import join
from glob import glob
binpath = os.environ['PATH'].split(':')
def installed(bins):
for bin in bins:
for path in binpath:
if glob(join(path,bin)):
return True
progs = {
'Python':['python','python2.?'],
'Perl':['perl','perl5.?.?'],
'Java':['java','javac','gcj'],
'C':['cc','gcc','bcc','icc']
}
installed_progs = [prog for prog,bins in progs.items() if installed(bins)]
for prog in installed_progs:
print prog,'is installed!'
-----
On Windows, something similar could be employed, but more places will have
to be checked (or perhaps directories instead of binaries).
More information about the Python-list
mailing list