blob: a09073baa355b107f6d9191cc27dc7ab2547f9ad (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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
|