blob: c5ba1344bb3859904de46fb3b2757c506ee667f9 (
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
45
46
|
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()
try:
cap = int(line)
except:
return -1
return cap
def model(self):
procfile = tryOpen(self.prochdx + "model")
if procfile == "":
return ""
line = procfile.readline()
procfile.close()
return line
def free(self):
pass
|