improve /sys/block/*/stat parsing
authorFelix Domke <tmbinc@elitedvb.net>
Mon, 23 Mar 2009 12:25:00 +0000 (13:25 +0100)
committerFelix Domke <tmbinc@elitedvb.net>
Mon, 23 Mar 2009 12:25:06 +0000 (13:25 +0100)
lib/python/Components/Harddisk.py

index 8664f79a48b7cc6a980122d4a04faf3a1699f5ff..37905b7d70ee03f5af70dfc5d9babc3a82010cb5 100755 (executable)
@@ -230,9 +230,8 @@ class Harddisk:
        # we set the hdd into standby.
        def readStats(self):
                l = open("/sys/block/%s/stat" % self.device).read()
-               nr_read = int(l[:8].strip())
-               nr_write = int(l[4*9:4*9+8].strip())
-               return nr_read, nr_write
+               (nr_read, _, _, _, nr_write) = l.split()[:5]
+               return int(nr_read), int(nr_write)
 
        def startIdle(self):
                self.last_access = time.time()