Skip to content

Commit

Permalink
Merge pull request #2911 from jsiirola/downloader-lsb-release
Browse files Browse the repository at this point in the history
Resolve `FileDownloader.get_os_version` exception for missing `lsb_release`
  • Loading branch information
mrmundt authored Jul 20, 2023
2 parents bc05ab3 + d844730 commit c70a41f
Showing 1 changed file with 5 additions and 10 deletions.
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

0 comments on commit c70a41f

Please sign in to comment.