From 296d26f432a6ca1c97979cb6926ee876e0586c67 Mon Sep 17 00:00:00 2001 From: facetoe Date: Sun, 12 Oct 2014 11:58:52 +0800 Subject: [PATCH] Prevent division by zero errors. --- i3pystatus/cpu_usage.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/i3pystatus/cpu_usage.py b/i3pystatus/cpu_usage.py index a1f8e82..57e2083 100644 --- a/i3pystatus/cpu_usage.py +++ b/i3pystatus/cpu_usage.py @@ -67,7 +67,10 @@ class CpuUsage(IntervalModule): self.prev_total[cpu] = total self.prev_busy[cpu] = busy - return int(diff_busy / diff_total * 100) + if diff_total == 0: + return 0 + else: + return int(diff_busy / diff_total * 100) def gen_format_all(self, usage): """