From d1c58e79a92db3aca326590fdb79b4c81ee8b2bc Mon Sep 17 00:00:00 2001 From: Peter Vlasveld Date: Fri, 14 Apr 2023 15:18:45 -0400 Subject: [PATCH] BUG-1: Dealt with small edge case for the uptime segment --- powerline_shell/segments/uptime.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/powerline_shell/segments/uptime.py b/powerline_shell/segments/uptime.py index 1c030611..49cc6ef0 100644 --- a/powerline_shell/segments/uptime.py +++ b/powerline_shell/segments/uptime.py @@ -8,7 +8,8 @@ def add_to_powerline(self): powerline = self.powerline try: output = decode(subprocess.check_output(['uptime'], stderr=subprocess.STDOUT)) - raw_uptime = re.search('(?<=up).+(?=,\s+\d+\s+user)', output).group(0) + raw_uptime = re.search('(?<=up).+(?=,\s+\d+\s+user)', output) + raw_uptime = '' if not raw_uptime else raw_uptime.group(0) day_search = re.search('\d+(?=\s+day)', output) days = '' if not day_search else '%sd ' % day_search.group(0) hour_search = re.search('\d{1,2}(?=\:)', raw_uptime)