]> git.ipfire.org Git - oddments/fireinfo.git/commitdiff
bogomips: Don't crash when no bogomips are available
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 28 Oct 2014 20:14:41 +0000 (21:14 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 28 Oct 2014 20:14:41 +0000 (21:14 +0100)
The RPi doesn't provide bogomips in /proc/cpuinfo any more
and fireinfo crashed when trying to read that file

src/fireinfo/cpu.py
src/fireinfo/system.py

index 32d885db8124f9f3690255e7f46a930ea8397bd7..541575af6bbb33e5e58cd0010d1b22662ffdd4ae 100644 (file)
@@ -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):
index 8e903e8e3449000d11d514aa3d46b8a07a650d1d..890f58c05027060b77e0deaffa0bf50f638a2ef6 100644 (file)
@@ -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(),