add harddisk stuff
authorRonny Strutz <ronny.strutz@multimedia-labs.de>
Mon, 29 Aug 2005 22:00:47 +0000 (22:00 +0000)
committerRonny Strutz <ronny.strutz@multimedia-labs.de>
Mon, 29 Aug 2005 22:00:47 +0000 (22:00 +0000)
lib/python/Components/Harddisk.py [new file with mode: 0644]

diff --git a/lib/python/Components/Harddisk.py b/lib/python/Components/Harddisk.py
new file mode 100644 (file)
index 0000000..a09073b
--- /dev/null
@@ -0,0 +1,44 @@
+
+
+def tryOpen(filename):
+       try:
+               procFile = open(filename)
+       except IOError:
+               return ""
+       return procFile
+
+class Harddisk:
+       def __init__(self, index):
+               self.index = index
+               #perhaps this is easier?
+               self.prochdx = "/proc/ide/hd" + ("a","b","c","d","e","f","g","h")[index] + "/"
+               
+       def capacity(self):
+               procfile = tryOpen(self.prochdx + "capacity")
+               
+               if procfile == "":
+                       return -1
+
+               line = procfile.readline()
+               procfile.close()
+               
+               if line == "":
+                       return -1
+
+               return int(line)
+                                               
+       def model(self):
+               procfile = tryOpen(self.prochdx + "model")
+               
+               if procfile == "":
+                       return ""
+
+               line = procfile.readline()
+               procfile.close()
+
+               return line
+
+       def free(self):
+               pass
+               
+       
\ No newline at end of file