hopefully fixed out of index bug
This commit is contained in:
parent
bc9d4951d1
commit
6c527f7f4f
26
disk_mon.py
26
disk_mon.py
|
@ -31,30 +31,32 @@ class diskmon(object):
|
|||
if self.part[0] in self.line:
|
||||
self.part.append(self.line.split()[1])
|
||||
self.part.append(self.line.split()[2])
|
||||
break
|
||||
self.mtab.close()
|
||||
#getting block infos
|
||||
if os.path.ismount(self.part[2]):
|
||||
self.fs = os.statvfs(self.part[2])
|
||||
self.part.append(self.fs.f_bsize) #blocksize
|
||||
self.part.append(self.fs.f_blocks) #total blocks
|
||||
self.part.append(self.fs.f_bavail) #free blocks
|
||||
|
||||
#getting block infos
|
||||
if os.path.ismount(self.part[2]):
|
||||
self.fs = os.statvfs(self.part[2])
|
||||
self.part.append(self.fs.f_bsize) #blocksize
|
||||
self.part.append(self.fs.f_blocks) #total blocks
|
||||
self.part.append(self.fs.f_bavail) #free blocks
|
||||
try: self.part[2]
|
||||
except IndexError:
|
||||
self.part.append("not mounted")
|
||||
|
||||
self.mtab.close()
|
||||
|
||||
#adding partition to list
|
||||
self.partitions.append(self.part)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#output
|
||||
if __name__ == "__main__":
|
||||
diskmoninstance = diskmon()
|
||||
diskmoninstance.gather()
|
||||
#print diskmoninstance.partitions
|
||||
for partition in diskmoninstance.partitions:
|
||||
print "device: " + str(partition[0]) + "\nuuid: " + str(partition[1]) + "\nmountpoint: " + str(partition[2]) + "\nfilesystem: " + str(partition[3]) + "\nblocksize: " + str(partition[4]) + "\ntotal blocks: " + str(partition[5]) + "\nfree blocks: " + str(partition[6]) + "\n\n"
|
||||
print "device:\t\t" + str(partition[0]) + "\nuuid:\t\t" + str(partition[1]) + "\nmountpoint:\t" + str(partition[2]) + "\nfilesystem:\t" + str(partition[3]) + "\nblocksize:\t" + str(partition[4]) + "\ntotal blocks:\t" + str(partition[5]) + "\nfree blocks:\t" + str(partition[6])
|
||||
|
||||
|
||||
|
||||
|
||||
#end of file
|
||||
|
|
Reference in New Issue