New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
expanding platform module and making it work as it should #41840
Comments
platform.release() (which is supposed to return the also only debian, mdk and redhat is scanned for I think that PSL is good but this module is has hell of import os
distro_info = {
'Arch Linux': '/etc/arch-release',\
'Aurox Linux': '/etc/aurox-release',\
'Conectiva Linux': '/etc/conectiva-release',\
'Debian GNU/Linux': '/etc/debian_release',\
'Debian GNU/Linux': '/etc/debian_version',\
'Fedora Linux': '/etc/fedora-release',\
'Gentoo Linux': '/etc/gentoo-release',\
'Mandrake Linux': '/etc/mandrake-release',\
'Slackware Linux': '/etc/slackware-release',\
'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
'Redhat Linux': '/etc/redhat-release'\
}
def get_os_info():
if os.name =='nt':
win_version = {
(1, 4, 0): "95",\
(1, 4, 10): "98",\
(1, 4, 90): "ME",\
(2, 4, 0): "NT",\
(2, 5, 0): "2000",\
(2, 5, 1): "XP"
}[os.sys.getwindowsversion()[3],
os.sys.getwindowsversion()[0],
os.sys.getwindowsversion()[1]]
return 'Windows' + ' ' + win_version
elif os.name =='posix':
executable = 'lsb_release'
params = ' --id --codename --release --short'
for path in os.environ['PATH'].split(':'):
full_path_to_executable = os.path.join(path,
executable)
if os.path.exists(full_path_to_executable):
command = executable + params
child_stdin, child_stdout = os.popen2(command)
output = child_stdout.readline().strip()
child_stdout.close()
child_stdin.close()
return output
# lsb_release executable not available, so parse files
for distro in distro_info:
path_to_file = distro_info[distro]
if os.path.exists(path_to_file):
file = open(path_to_file)
text = file.read().strip()
file.close()
if path_to_file.endswith('version'):
text = distro + ' ' + text
return text print get_os_info() Thank you |
Logged In: YES identation went to take a walk :( |
Logged In: YES ok nevermind the platform.release() part for windows name. |
Logged In: YES ok I have it again in a friend of mine. he has win xp pro the Simon's trick will return to him XP |
Logged In: YES A friend of mine has a french win xp pro. your way says to platform.release() returns "" to him So release() doesn't do for windows what you do. I also it won't try the magic that release() [that fail] simon's code still works there as charm. so if release() |
(removed spam) |
You appear to be requesting two things:
The first is possible, if that API is available. It would still have to fall back to the ver command line tool, since it's not future-proof, i.e. future versions of Windows will not automatically be supported. The second is wrong, since platform.release() is only a short-cut to the uname() function and this refers to the underlying system rather than the Linux distrubtion. However, I could add support for lsb_release to the linux_distribution() function. |
I think this should be an enhancement request. Regardless it goes nowhere without a patch, anybody? |
Can this be closed as since platform.linx_distribution() was removed with https://bugs.python.org/issue28167 and distro is the recommended package which can be frequently updated. Thanks |
Closing as suggested by @tirkarthi four years ago, and there's been no objection since. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: