mirror of
https://github.com/certbot/certbot.git
synced 2026-07-27 00:58:08 +02:00
New method for determining UA string
This commit is contained in:
+1
-1
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user