Skip to content
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

Closed
nkour mannequin opened this issue Apr 10, 2005 · 10 comments
Closed

expanding platform module and making it work as it should #41840

nkour mannequin opened this issue Apr 10, 2005 · 10 comments
Assignees
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@nkour
Copy link
Mannequin

nkour mannequin commented Apr 10, 2005

BPO 1180267
Nosy @malemburg, @tirkarthi

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:

assignee = 'https://github.com/malemburg'
closed_at = None
created_at = <Date 2005-04-10.16:44:28.000>
labels = ['type-feature', 'library']
title = 'expanding platform module and making it work as it should'
updated_at = <Date 2018-09-22.16:04:18.547>
user = 'https://bugs.python.org/nkour'

bugs.python.org fields:

activity = <Date 2018-09-22.16:04:18.547>
actor = 'BreamoreBoy'
assignee = 'lemburg'
closed = False
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2005-04-10.16:44:28.000>
creator = 'nkour'
dependencies = []
files = []
hgrepos = []
issue_num = 1180267
keywords = []
message_count = 9.0
messages = ['60720', '60721', '60722', '60723', '60724', '99567', '112438', '228038', '326094']
nosy_count = 3.0
nosy_names = ['lemburg', 'nkour', 'xtreak']
pr_nums = []
priority = 'normal'
resolution = None
stage = 'test needed'
status = 'open'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue1180267'
versions = ['Python 3.5']

@nkour
Copy link
Mannequin Author

nkour mannequin commented Apr 10, 2005

platform.release() (which is supposed to return the
Name of Windows) also does not work as it should in
some versions of windows I tried (xp pro sp1). Luckily
to print more than Windows (eg. print Windows XP or
Windows 2000 etc) you can have a look at this
http://www.brunningonline.net/simon/blog/archives/001168.html
of Simon Brunning

also only debian, mdk and redhat is scanned for
GNU/Linux ?? why even bother then?

I think that PSL is good but this module is has hell of
limitations. At least dont' make anyone write this:

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

@nkour nkour mannequin added stdlib Python modules in the Lib dir labels Apr 10, 2005
@nkour
Copy link
Mannequin Author

nkour mannequin commented Apr 10, 2005

Logged In: YES
user_id=865368

identation went to take a walk :(
I'm sorry
look here:
http://nkour.blogspot.com/2005/03/python-script-to-detect-gnulinux.html

@nkour
Copy link
Mannequin Author

nkour mannequin commented Apr 11, 2005

Logged In: YES
user_id=865368

ok nevermind the platform.release() part for windows name.
it seems to work now.. :$

@nkour
Copy link
Mannequin Author

nkour mannequin commented Apr 12, 2005

Logged In: YES
user_id=865368

ok I have it again in a friend of mine. he has win xp pro
sp1 French edition
and release() returns ""

the Simon's trick will return to him XP
which is correct!!

@nkour
Copy link
Mannequin Author

nkour mannequin commented Apr 13, 2005

Logged In: YES
user_id=865368

A friend of mine has a french win xp pro. your way says to
him WP

platform.release() returns "" to him
he has used antispam and such "tools" so he must have
accidentaly removed the place where release() seems to look.

So release() doesn't do for windows what you do. I also
noticed that On a windows exploer help --> about will give
Microsoft Windows
5.1 (more info)

it won't try the magic that release() [that fail]

simon's code still works there as charm. so if release()
returns "" I try to do that other code. I would like to see
that included though [or a better code for release() to
detect the correct stuff]
along with the more linux distros and the usage of lsb_release
Comments?

@devdanzin devdanzin mannequin added type-bug An unexpected behavior, bug, or error labels Feb 15, 2009
@arcon007 arcon007 mannequin changed the title expanding platform module and making it work as it should arcon007 Feb 19, 2010
@arcon007 arcon007 mannequin changed the title expanding platform module and making it work as it should arcon007 Feb 19, 2010
@arcon007 arcon007 mannequin added type-crash A hard crash of the interpreter, possibly with a core dump and removed type-bug An unexpected behavior, bug, or error labels Feb 19, 2010
@arcon007 arcon007 mannequin changed the title arcon007 just look this Feb 19, 2010
@arcon007 arcon007 mannequin added type-crash A hard crash of the interpreter, possibly with a core dump and removed type-bug An unexpected behavior, bug, or error labels Feb 19, 2010
@arcon007 arcon007 mannequin changed the title arcon007 just look this Feb 19, 2010
@florentx florentx mannequin added type-bug An unexpected behavior, bug, or error and removed type-crash A hard crash of the interpreter, possibly with a core dump labels Feb 19, 2010
@florentx
Copy link
Mannequin

florentx mannequin commented Feb 19, 2010

(removed spam)

@florentx florentx mannequin changed the title just look this expanding platform module and making it work as it should Feb 19, 2010
@florentx florentx mannequin changed the title just look this expanding platform module and making it work as it should Feb 19, 2010
@malemburg
Copy link
Member

You appear to be requesting two things:

  1. Determine the Windows version by looking at sys.getwindowsversion() rather than relying on the ver command line tool.

  2. Use lsb_release to fetch the release name on Linux systems that support it.

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.

@BreamoreBoy
Copy link
Mannequin

BreamoreBoy mannequin commented Sep 30, 2014

I think this should be an enhancement request. Regardless it goes nowhere without a patch, anybody?

@BreamoreBoy BreamoreBoy mannequin added type-feature A feature request or enhancement and removed type-bug An unexpected behavior, bug, or error labels Sep 30, 2014
@BreamoreBoy BreamoreBoy mannequin added type-feature A feature request or enhancement and removed type-bug An unexpected behavior, bug, or error labels Sep 30, 2014
@tirkarthi
Copy link
Member

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

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 9, 2022
@erlend-aasland erlend-aasland added the pending The issue will be closed if no feedback is provided label May 20, 2022
@hugovk
Copy link
Member

hugovk commented May 29, 2022

Closing as suggested by @tirkarthi four years ago, and there's been no objection since.

@hugovk hugovk closed this as not planned Won't fix, can't repro, duplicate, stale May 29, 2022
@hugovk hugovk removed the pending The issue will be closed if no feedback is provided label May 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

4 participants