Some distros put to optional LSB vars n/a, so detect that and remove it.

SUSE uses lsb_release for quite a lot of versions I've been told so depend only on lsb for SuSE [the files things was untested in SUSE anyways]
This commit is contained in:
Nikos Kouremenos 2005-05-18 16:42:28 +00:00
parent 79c5b5d0e2
commit 9a70ab0218
1 changed files with 4 additions and 2 deletions

View File

@ -20,6 +20,7 @@
import sys
import os
import time
import sre
from calendar import timegm
import common.xmpp
@ -49,9 +50,7 @@ distro_info = {
'Slackware Linux': '/etc/slackware-version',
'Solaris/Sparc': '/etc/release',
'Sun JDS': '/etc/sun-release',
'Novell SUSE Linux': '/etc/SuSE-release',
'PLD Linux': '/etc/pld-release',
'SUSE Linux': '/etc/SuSE-release',
'Yellow Dog Linux': '/etc/yellowdog-release',
# many distros use the /etc/redhat-release for compatibility
# so Redhat is the last
@ -82,6 +81,9 @@ def get_os_info():
output = child_stdout.readline().strip()
child_stdout.close()
child_stdin.close()
# some distros put n/a in places so remove them
pattern = sre.compile(r' n/a', sre.IGNORE_CASE)
output = sre.sub(pattern, '', output)
return output
# lsb_release executable not available, so parse files
for distro_name in distro_info: