Skip to content

Commit

Permalink
Bug 1595220 - streamline and sanitize output of distro/platform linux…
Browse files Browse the repository at this point in the history
…_distribution call in mozinfo r=jmaher

Differential Revision: https://phabricator.services.mozilla.com/D52440

--HG--
extra : moz-landing-system : lando
  • Loading branch information
Edwin Takahashi committed Nov 13, 2019
1 parent 28e518c commit c43a1bb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
23 changes: 11 additions & 12 deletions testing/mozbase/mozinfo/mozinfo/mozinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,20 +99,19 @@ class OSVERSIONINFOEXW(ctypes.Structure):
info['os'] = 'win'
os_version = version = unknown
elif system == "Linux":
# Only attempt to import distro for Linux.
# https://github.com/nir0s/distro/issues/177
# Attempt to use distro package to determine Linux distribution first.
# Failing that, fall back to use the platform method.
# Note that platform.linux_distribution() will be deprecated as of 3.8
# and this block will be removed once support for 2.7/3.5 is dropped.
try:
import distro
from distro import linux_distribution
except ImportError:
pass
# First use distro package, then fall back to platform.
# This will only until Mozilla upgrades python to 3.8.
if hasattr(distro, "linux_distribution"):
(distribution, os_version, codename) = distro.linux_distribution()
elif hasattr(platform, "linux_distribution"):
(distribution, os_version, codename) = platform.linux_distribution()
else:
(distribution, os_version, codename) = platform.dist()
from platform import linux_distribution

output = linux_distribution()
(distribution, os_version, codename) = tuple(
str(item.title()) for item in output)

if not processor:
processor = machine
version = "%s %s" % (distribution, os_version)
Expand Down
2 changes: 1 addition & 1 deletion testing/mozbase/mozinfo/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from setuptools import setup

PACKAGE_VERSION = "1.2.0"
PACKAGE_VERSION = "1.2.1"

# dependencies
deps = [
Expand Down

0 comments on commit c43a1bb

Please sign in to comment.