From: Michael Tremer Date: Tue, 28 Oct 2014 20:14:41 +0000 (+0100) Subject: bogomips: Don't crash when no bogomips are available X-Git-Tag: v2.1.11~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a9401d9542fae575d9ce2bb534cd4e598e9c7b8e;p=oddments%2Ffireinfo.git bogomips: Don't crash when no bogomips are available The RPi doesn't provide bogomips in /proc/cpuinfo any more and fireinfo crashed when trying to read that file --- diff --git a/src/fireinfo/cpu.py b/src/fireinfo/cpu.py index 32d885d..541575a 100644 --- a/src/fireinfo/cpu.py +++ b/src/fireinfo/cpu.py @@ -80,12 +80,16 @@ class CPU(object): """ Return the bogomips of this CPU. """ - try: - bogomips = self.__cpuinfo["bogomips"] - except KeyError: - bogomips = self.__cpuinfo["BogoMIPS"] + bogomips = None + + for key in ("bogomips", "BogoMIPS"): + try: + bogomips = self.__cpuinfo[key] + except KeyError: + continue - return float(bogomips) + if bogomips: + return float(bogomips) @property def model(self): diff --git a/src/fireinfo/system.py b/src/fireinfo/system.py index 8e903e8..890f58c 100644 --- a/src/fireinfo/system.py +++ b/src/fireinfo/system.py @@ -144,12 +144,14 @@ class System(object): "model_string" : self.cpu.model_string, "stepping" : self.cpu.stepping, "flags" : self.cpu.flags, - "bogomips" : self.cpu.bogomips, "speed" : self.cpu.speed, "family" : self.cpu.family, "count" : self.cpu.count } + if self.cpu.bogomips: + p["bogomips"] = self.cpu.bogomips + p["network"] = { "green" : self.network.has_green(), "blue" : self.network.has_blue(),