From 598a511420e30d63d14ebce4fe3f1b401731b78e Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Tue, 27 Sep 2016 09:32:28 -0500 Subject: [PATCH] Keep the previous color if a status update fails --- i3pystatus/github.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/i3pystatus/github.py b/i3pystatus/github.py index 3a99e51..36a0f57 100644 --- a/i3pystatus/github.py +++ b/i3pystatus/github.py @@ -533,9 +533,19 @@ class Github(IntervalModule): return False def refresh_display(self): - color = self.colors.get( - self.current_status.get('status'), - self.unknown_color) + previous_color = self.output.get('color') + try: + if 'status' in self.current_status: + color = self.colors.get( + self.current_status['status'], + self.unknown_color) + else: + # Failed status update, keep the existing color + color = previous_color + except TypeError: + # Shouldn't get here, but this would happen if this function is + # called before we check the current status for the first time. + color = previous_color self.output = {'full_text': formatp(self.format, **self.data).strip(), 'color': color}