Fix module platform has no attribute linux_distribution (#224)
This commit is contained in:
parent
be770a947a
commit
0cff7d3477
1 changed files with 8 additions and 3 deletions
|
@ -32,12 +32,17 @@ def get_device_type(type):
|
||||||
def get_device_platform(device_platform):
|
def get_device_platform(device_platform):
|
||||||
if device_platform is None:
|
if device_platform is None:
|
||||||
try:
|
try:
|
||||||
import platform
|
# Python 3.8+ moved linux_distribution() to distro
|
||||||
|
try:
|
||||||
|
import distro
|
||||||
|
linux_distribution = " ".join(distro.linux_distribution())
|
||||||
|
except ImportError:
|
||||||
|
import platform
|
||||||
|
linux_distribution = " ".join(platform.linux_distribution())
|
||||||
|
|
||||||
linux_distribution = " ".join(platform.linux_distribution())
|
|
||||||
if not linux_distribution:
|
if not linux_distribution:
|
||||||
return None
|
return None
|
||||||
except (ModuleNotFoundError, NameError):
|
except (ModuleNotFoundError, NameError, AttributeError):
|
||||||
return None
|
return None
|
||||||
else:
|
else:
|
||||||
linux_distribution = device_platform
|
linux_distribution = device_platform
|
||||||
|
|
Loading…
Reference in a new issue