[issue1322] platform.dist() has unpredictable result under Linux

2007-10-24 Thread Yann Cointepas

New submission from Yann Cointepas:

The distribution name returned by platform.dist() depends on the order
of os.path.listdir( '/etc' ). It selects the first file matching the
regex r'(\w+)[-_](release|version)' and takes part of the file name
(i.e. matchResult.groups()[0]) as distribution name. But there are often
several files matching this pattern (at least on Fedora and Mandriva).
For instance, on a Mandriva 2007.1 official, I can see the following files:

[EMAIL PROTECTED] ~]$ ls -l /etc/*-release
-rw-r--r-- 1 root root 137 jan 18  2007 /etc/lsb-release
lrwxrwxrwx 1 root root  16 oct  7 17:32 /etc/mandrakelinux-release ->
mandriva-r 
  elease
lrwxrwxrwx 1 root root  16 oct  7 17:32 /etc/mandrake-release ->
mandriva-releas
   e
-rw-r--r-- 1 root root  50 avr  2  2007 /etc/mandriva-release
lrwxrwxrwx 1 root root  16 oct  7 17:32 /etc/redhat-release ->
mandriva-release

Therefore, the result for platform.distrib()[0] could be mandriva,
mandrake, redhat or even lsb. The first match wins !

Ignoring symlinks could remove part of the problem. On Mandriva, it
would leave only lsb-release and mandriva-release. It is possible to
select the good one by ignoring lsb-release or by verifying the file's
content (mandriva-release has one line and lsb-release has several
lines). I do not know if the second method is portable.

--
messages: 56710
nosy: sapetnioc
severity: major
status: open
title: platform.dist() has unpredictable result under Linux
type: behavior
versions: Python 2.5

__
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue1322>
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1322] platform.dist() has unpredictable result under Linux

2007-10-25 Thread Yann Cointepas

Yann Cointepas added the comment:

I can easily do the patch to ignore symlinks and /etc/lsb-release but I am
not sure of the appropriate way to look for lsb_update command, is
distutils.spawn.find_executable( 'lsb_release' ) ok ?
If you need the patch earlier than begining of next week, you should do it.
Otherwise I can make it.

On Mandriva 2007.1, the command exists if the package "lsb-release" is
installed. I do not know if it is always installed (I selected a checkbox
"LSB" during install, this checkbox is unchecked by default).
The output is:

[EMAIL PROTECTED] ~]$ lsb_release -a
LSB Version:
lsb-3.1-ia32:lsb-3.1-noarch:core-3.0-ia32:core-3.0-noarch:core-3.1-ia32:core-3.1-noarch:cxx-3.0-ia32:cxx-3.0-noarch:graphics-3.0-ia32:graphics-3.0-noarch:lsb-3.0-ia32:lsb-3.0-noarch:qt4-3.1-ia32:qt4-3.1-noarch
Distributor ID: MandrivaLinux
Description:Mandriva Linux
Release:2007.1
Codename:   Official

[EMAIL PROTECTED] ~]$ lsb_release -i
Distributor ID: MandrivaLinux

[EMAIL PROTECTED] ~]$ lsb_release -d
Description:Mandriva Linux

[EMAIL PROTECTED] ~]$ lsb_release -r
Release:2007.1

On Fedora 4 (rather old) , the command is in the package "redhat-lsb".

yc176684:src$ lsb_release -a
LSB Version:1.3
Distributor ID: FedoraCore
Description:Fedora Core release 4 (Stentz)
Release:4
Codename:   Stentz

yc176684:src$ lsb_release -i
Distributor ID: FedoraCore

yc176684:src$ lsb_release -d
Description:Fedora Core release 4 (Stentz)

yc176684:src$ lsb_release -r
Release:4

On Fedora 7, the command is in the package "redhat-lsb" and seem to be
installed by default.

gargamel:riviere% lsb_release -a
LSB
Version::core-3.1-ia32:core-3.1-noarch:
graphics-3.1-ia32:graphics-3.1-noarch
Distributor ID: Fedora
Description:Fedora release 7 (Moonshine)
Release:7
Codename:   Moonshine

gargamel:riviere% lsb_release -i
Distributor ID: Fedora

gargamel:riviere% lsb_release -d
Description:Fedora release 7 (Moonshine)

gargamel:riviere% lsb_release -r
Release:7

On 10/25/07, Raghuram Devarakonda < [EMAIL PROTECTED]> wrote:
>
>
> Raghuram Devarakonda added the comment:
>
> I think it is safe to ignore lsb-release. In fact, there seems to be a
> command "lsb_release" that gives information about distribution. On my
> SuSE box, this is what I get:
>
> marvin:~# lsb_release -i
> Distributor ID: SUSE LINUX
> marvin:~# lsb_release -d
> Description:SUSE LINUX 10.1 (i586)
> marvin:~# lsb_release -r
> Release:10.1
>
> sapetnioc, can you check if this command exists on your system and if
> so, it's output? platform.dist() can check for this command's existence
> and if present, can perhaps use it to glean distro information. Please
> let me know if you want to write the patch. I will do it otherwise.
>
> --
> nosy: +draghuram
>
> __
> Tracker <[EMAIL PROTECTED] >
> <http://bugs.python.org/issue1322 >
> __
>

Added file: http://bugs.python.org/file8609/unnamed

__
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue1322>
__I can easily do the patch to ignore symlinks and /etc/lsb-release but I am not 
sure of the appropriate way to look for lsb_update command, is 
distutils.spawn.find_executable( 'lsb_release' ) ok ?If you need 
the patch earlier than begining of next week, you should do it. Otherwise I can 
make it.
On Mandriva 2007.1, the command exists if the package 
"lsb-release" is installed. I do not know if it is always installed 
(I selected a checkbox "LSB" during install, this checkbox is 
unchecked by default).
The output is:[EMAIL PROTECTED] ~]$ lsb_release -aLSB 
Version:    
lsb-3.1-ia32:lsb-3.1-noarch:core-3.0-ia32:core-3.0-noarch:core-3.1-ia32:core-3.1-noarch:cxx-3.0-ia32:cxx-3.0-noarch:graphics-3.0-ia32:graphics-3.0-noarch:lsb-3.0-ia32:lsb-3.0-noarch:qt4-3.1-ia32:qt4-3.1-noarch

Distributor ID: MandrivaLinuxDescription:    Mandriva 
LinuxRelease:    
2007.1Codename:   Official[EMAIL 
PROTECTED] ~]$ lsb_release -iDistributor ID: MandrivaLinux[EMAIL 
PROTECTED] ~]$ lsb_release -d
Description:    Mandriva Linux[EMAIL PROTECTED] ~]$ 
lsb_release -rRelease:    
2007.1On Fedora 4 (rather old) , the command is in the package 
"redhat-lsb".yc176684:src$ lsb_release -a


LSB Version:    1.3
Distributor ID: FedoraCore
Description:    Fedora Core release 4 (Stentz)
Release:    4
Codename:   Stentzyc176684:src$ 
lsb_release -i
Distributor ID: FedoraCoreyc176684:src$ lsb_release -d
Description:    Fedora Core release 4 
(Stentz)yc176684:src$ lsb_release -r
Release:    4
On Fedora 7, the command is in the package "redhat-lsb" and 
seem to 

[issue1322] platform.dist() has unpredictable result under Linux

2007-10-26 Thread Yann Cointepas

Yann Cointepas added the comment:

I am writing a patch but I have a few questions:

1) There are at most three places where the distribution name can be
found. What is the priority order to select only one name ?
The three places are:
  a) Inside the /etc/lsb-release file
  b) In the name of the /etc/-release file
  c) In the content of the /etc/-release file
For instance, on Mandriva 2007.1 the possible names are:
  a) 'MandrivaLinux'
  b) 'mandriva'
  c) 'Mandriva Linux'
I would suggest to put a) first to be compatible with LSB
but on most systems it would change the value returned by
platform.dist after the patch (is it a problem ?).
I would have liked to use c) as second choice but this space
in the name set by Mandriva could be a problem (It's possible
to suppress spaces in the result though).

2) Can I remove supported_dists parameter of platform.dist ?
There could be a list of supported distributions but why
as a parameter of this function ?

__
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue1322>
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com