From 0a72ebb37965e01e9d59559fac3f2dc1406a989a Mon Sep 17 00:00:00 2001 From: Peter Eckersley Date: Tue, 10 Nov 2015 20:00:12 -0800 Subject: [PATCH] get_os_info review fixes - handle broken platform.linux_distribution() - document return type --- letsencrypt/le_util.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/letsencrypt/le_util.py b/letsencrypt/le_util.py index a5c1a26a1..a0540a723 100644 --- a/letsencrypt/le_util.py +++ b/letsencrypt/le_util.py @@ -206,6 +206,7 @@ def safely_remove(path): def get_os_info(): """ Get Operating System type/distribution and major version + :returns: (`str` os_name, `str` os_version) """ info = platform.system_alias( platform.system(), @@ -216,7 +217,12 @@ def get_os_info(): os_type = os_type.lower() if os_type.startswith('linux'): info = platform.linux_distribution() - os_type, os_ver, _ = info + # On arch, platform.linux_distribution() is reportedly ('','',''), + # so handle it defensively + if info[0]: + os_type = info[0] + if info[1]: + os_ver = info[1] elif os_type.startswith('darwin'): os_ver = subprocess.Popen( ["sw_vers", "-productVersion"],