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

Resolve FileDownloader.get_os_version exception for missing lsb_release #2911

Merged
merged 2 commits into from
Jul 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions pyomo/common/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import os
import platform
import re
import shutil
import sys
import subprocess

Expand Down Expand Up @@ -99,14 +100,15 @@ def _get_distver_from_redhat_release(cls):

@classmethod
def _get_distver_from_lsb_release(cls):
lsb_release = shutil.which('lsb_release')
dist = subprocess.run(
['lsb_release', '-si'],
[lsb_release, '-si'],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
universal_newlines=True,
)
ver = subprocess.run(
['lsb_release', '-sr'],
[lsb_release, '-sr'],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
universal_newlines=True,
Expand Down Expand Up @@ -152,14 +154,7 @@ def _get_os_version(cls):
dist, ver = cls._get_distver_from_distro()
elif os.path.exists('/etc/redhat-release'):
dist, ver = cls._get_distver_from_redhat_release()
elif (
subprocess.run(
['lsb_release'],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
).returncode
== 0
):
elif shutil.which('lsb_release'):
dist, ver = cls._get_distver_from_lsb_release()
elif os.path.exists('/etc/os-release'):
# Note that (at least on centos), os_release is an
Expand Down