Finalized parsing and fixed test case

This commit is contained in:
Joona Hoikkala
2016-04-12 14:27:00 +03:00
parent c82a551e77
commit bbb300eb22
2 changed files with 17 additions and 1 deletions
+16
View File
@@ -217,6 +217,15 @@ def get_os_info():
:rtype: `tuple` of `str`
"""
if os.path.isfile('/etc/os-release'):
# Systemd os-release parsing might be viable
os_name, os_version = get_systemd_os_info()
if os_name:
return (os_name, os_version)
# Fallback to platform module
return get_python_os_info()
def get_systemd_os_info():
"""
@@ -233,6 +242,13 @@ def get_systemd_os_info():
def _get_systemd_os_release_var(varname):
"""
Get single value from systemd /etc/os-release
:param str varname: Name of variable to fetch
:returns: requested value
:rtype: `str`
"""
OS_RELEASE_FILEPATH = "/etc/os-release"
var_string = varname+"="
+1 -1
View File
@@ -169,7 +169,7 @@ class CLITest(unittest.TestCase): # pylint: disable=too-many-public-methods
import platform
plat = platform.platform()
if "linux" in plat.lower():
self.assertTrue(platform.linux_distribution()[0] in ua)
self.assertTrue(le_util.get_os_info()[0] in ua)
with mock.patch('letsencrypt.main.client.acme_client.ClientNetwork') as acme_net:
ua = "bandersnatch"