ALT Linux Bugzilla
– Attachment 7515 Details for
Bug 34421
Функция "platform.linux_distribution()" из python3 возвращает "fedora" вместо "altlinux".
New bug
|
Search
|
[?]
|
Help
Register
|
Log In
[x]
|
Forgot Password
Login:
[x]
|
EN
|
RU
[patch]
platform os-release patch
python-2.7-platform-osrelease.patch (text/plain), 2.55 KB, created by
Andrey
on 2018-04-24 10:40:19 MSK
(
hide
)
Description:
platform os-release patch
Filename:
MIME Type:
Creator:
Andrey
Created:
2018-04-24 10:40:19 MSK
Size:
2.55 KB
patch
obsolete
>--- Python/Lib/platform.py 2018-04-24 09:42:21.995273508 +0300 >+++ Python/Lib/new_platform.py 2018-04-24 09:40:20.465284750 +0300 >@@ -314,35 +314,54 @@ > args given as parameters. > > """ >- try: >- etc = os.listdir('/etc') >- except os.error: >- # Probably not a Unix system >- return distname,version,id >- etc.sort() >- for file in etc: >- m = _release_filename.match(file) >- if m is not None: >- _distname,dummy = m.groups() >- if _distname in supported_dists: >- distname = _distname >- break >+ _os_release = '/etc/os-release' >+ if os.path.exists(_os_release) == True: >+ >+ try: >+ _os_release_file = open(_os_release) >+ _os_release_content = _os_release_file.read() >+ except IOError: >+ pass >+ >+ get_name = re.findall(r'NAME=.*', _os_release_content)[0] >+ distname = get_name.split('"')[1] >+ get_version = re.findall(r'VERSION=.*', _os_release_content)[0] >+ version = get_version.split('"')[1] >+ get_id = re.findall(r'ID=.*', _os_release_content)[0] >+ id = get_id.split('=')[1] >+ return distname, version, id >+ > else: >- return _dist_try_harder(distname,version,id) > >- # Read the first line >- f = open('/etc/'+file, 'r') >- firstline = f.readline() >- f.close() >- _distname, _version, _id = _parse_release_file(firstline) >- >- if _distname and full_distribution_name: >- distname = _distname >- if _version: >- version = _version >- if _id: >- id = _id >- return distname, version, id >+ try: >+ etc = os.listdir('/etc') >+ except os.error: >+ # Probably not a Unix system >+ return distname,version,id >+ etc.sort() >+ for file in etc: >+ m = _release_filename.match(file) >+ if m is not None: >+ _distname,dummy = m.groups() >+ if _distname in supported_dists: >+ distname = _distname >+ break >+ else: >+ return _dist_try_harder(distname,version,id) >+ >+ # Read the first line >+ f = open('/etc/'+file, 'r') >+ firstline = f.readline() >+ f.close() >+ _distname, _version, _id = _parse_release_file(firstline) >+ >+ if _distname and full_distribution_name: >+ distname = _distname >+ if _version: >+ version = _version >+ if _id: >+ id = _id >+ return distname, version, id > > # To maintain backwards compatibility: >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 34421
: 7515