New method for determining UA string

This commit is contained in:
Joona Hoikkala
2016-04-29 15:31:59 +03:00
parent c2a5fb7f21
commit ff30fb71d2
2 changed files with 19 additions and 1 deletions
+1 -1
View File
@@ -52,7 +52,7 @@ def _determine_user_agent(config):
if config.user_agent is None:
ua = "CertbotACMEClient/{0} ({1}) Authenticator/{2} Installer/{3}"
ua = ua.format(certbot.__version__, " ".join(le_util.get_os_info()),
ua = ua.format(certbot.__version__, le_util.get_os_info_ua(),
config.authenticator, config.installer)
else:
ua = config.user_agent
+18
View File
@@ -228,6 +228,24 @@ def get_os_info(filepath="/etc/os-release"):
return get_python_os_info()
def get_os_info_ua(filepath="/etc/os-release"):
"""
Get OS name and version string for User Agent
:param str filepath: File path of os-release file
:returns: os_ua
:rtype: `str`
"""
if os.path.isfile(filepath):
os_ua = _get_systemd_os_release_var("NAME", filepath=filepath)
if os_ua:
return os_ua
# Fallback
return " ".join(get_python_os_info())
def get_systemd_os_info(filepath="/etc/os-release"):
"""
Parse systemd /etc/os-release for distribution information