From d73be0911ee6a0fc299a0877c9aef80702a5e95e Mon Sep 17 00:00:00 2001 From: Arvedui Date: Sun, 29 Mar 2015 12:21:51 +0200 Subject: [PATCH 1/4] improve default for critical_limit in the load module --- i3pystatus/load.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/i3pystatus/load.py b/i3pystatus/load.py index 0c657f7..609d25e 100644 --- a/i3pystatus/load.py +++ b/i3pystatus/load.py @@ -1,4 +1,5 @@ from i3pystatus import IntervalModule +from multiprocessing import cpu_count class Load(IntervalModule): @@ -17,7 +18,7 @@ class Load(IntervalModule): file = "/proc/loadavg" color = "#ffffff" - critical_limit = 1 + critical_limit = cpu_count() critical_color = "#ff0000" def run(self): From 21ce8db1203dfb22039dd829280b141f1b0e1190 Mon Sep 17 00:00:00 2001 From: Arvedui Date: Sun, 29 Mar 2015 12:24:09 +0200 Subject: [PATCH 2/4] adjusted docs --- i3pystatus/load.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i3pystatus/load.py b/i3pystatus/load.py index 609d25e..35a65df 100644 --- a/i3pystatus/load.py +++ b/i3pystatus/load.py @@ -12,7 +12,7 @@ class Load(IntervalModule): ("format", "format string used for output. {avg1}, {avg5} and {avg15} are the load average of the last one, five and fifteen minutes, respectively. {tasks} is the number of tasks (i.e. 1/285, which indiciates that one out of 285 total tasks is runnable)."), ("color", "The text color"), - ("critical_limit", "Limit above which the load is considered critical"), + ("critical_limit", "Limit above which the load is considered critical, defaults to amount of cores."), ("critical_color", "The critical color"), ) From b353b5adc9555348add682ca681d62bcac561afd Mon Sep 17 00:00:00 2001 From: Arvedui Date: Sun, 29 Mar 2015 12:36:10 +0200 Subject: [PATCH 3/4] use os.cpu_count instead of the multiprocessing one --- i3pystatus/load.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i3pystatus/load.py b/i3pystatus/load.py index 35a65df..9e13a48 100644 --- a/i3pystatus/load.py +++ b/i3pystatus/load.py @@ -1,5 +1,5 @@ from i3pystatus import IntervalModule -from multiprocessing import cpu_count +from os import cpu_count class Load(IntervalModule): From 04fa8b045844da6830ffcfc87f137eed3d25d465 Mon Sep 17 00:00:00 2001 From: Arvedui Date: Sun, 29 Mar 2015 12:40:21 +0200 Subject: [PATCH 4/4] add fallback to multiprocessing.cpu_count because os.cpu_count is not available before 3.4 --- i3pystatus/load.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/i3pystatus/load.py b/i3pystatus/load.py index 9e13a48..dc3f3d2 100644 --- a/i3pystatus/load.py +++ b/i3pystatus/load.py @@ -1,5 +1,8 @@ from i3pystatus import IntervalModule -from os import cpu_count +try: + from os import cpu_count +except ImportError: + from multiprocessing import cpu_count class Load(IntervalModule):