add harddisk stuff
[enigma2.git] / lib / python / Components / Harddisk.py
1
2
3 def tryOpen(filename):
4         try:
5                 procFile = open(filename)
6         except IOError:
7                 return ""
8         return procFile
9
10 class Harddisk:
11         def __init__(self, index):
12                 self.index = index
13                 #perhaps this is easier?
14                 self.prochdx = "/proc/ide/hd" + ("a","b","c","d","e","f","g","h")[index] + "/"
15                 
16         def capacity(self):
17                 procfile = tryOpen(self.prochdx + "capacity")
18                 
19                 if procfile == "":
20                         return -1
21
22                 line = procfile.readline()
23                 procfile.close()
24                 
25                 if line == "":
26                         return -1
27
28                 return int(line)
29                                                 
30         def model(self):
31                 procfile = tryOpen(self.prochdx + "model")
32                 
33                 if procfile == "":
34                         return ""
35
36                 line = procfile.readline()
37                 procfile.close()
38
39                 return line
40
41         def free(self):
42                 pass
43                 
44