use is_in_path

This commit is contained in:
Nikos Kouremenos 2005-08-09 11:34:16 +00:00
parent 1f901c3183
commit 341e060a91
1 changed files with 12 additions and 13 deletions

View File

@ -27,7 +27,6 @@ import traceback
import threading import threading
import select import select
from calendar import timegm from calendar import timegm
import common.xmpp import common.xmpp
@ -84,9 +83,8 @@ def get_os_info():
elif os.name == 'posix': elif os.name == 'posix':
executable = 'lsb_release' executable = 'lsb_release'
params = ' --id --codename --release --short' params = ' --id --codename --release --short'
for path in os.environ['PATH'].split(':'): full_path_to_executable = helpers.is_in_path(executable, return_abs_path = True)
full_path_to_executable = os.path.join(path, executable) if full_path_to_executable:
if os.path.exists(full_path_to_executable):
command = executable + params command = executable + params
child_stdin, child_stdout = os.popen2(command) child_stdin, child_stdout = os.popen2(command)
output = child_stdout.readline().strip() output = child_stdout.readline().strip()
@ -96,6 +94,7 @@ def get_os_info():
pattern = sre.compile(r' n/a', sre.IGNORECASE) pattern = sre.compile(r' n/a', sre.IGNORECASE)
output = sre.sub(pattern, '', output) output = sre.sub(pattern, '', output)
return output return output
# lsb_release executable not available, so parse files # lsb_release executable not available, so parse files
for distro_name in distro_info: for distro_name in distro_info:
path_to_file = distro_info[distro_name] path_to_file = distro_info[distro_name]