added code in diezweite
This commit is contained in:
parent
6b39e15c87
commit
b0c1fc9011
|
@ -3,19 +3,36 @@
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
class partobj(object): #my first class :)
|
|
||||||
# def __init__(self):
|
|
||||||
# self.dev = ""
|
|
||||||
|
|
||||||
# getting all local partitions plus their uuids
|
def getmountpoint(device):
|
||||||
def getpartitions(self):
|
mtab = open("/etc/mtab", "r")
|
||||||
self.uuids = os.listdir("/dev/disk/by-uuid") #folder contains symlinks to the actual disk devices
|
for line in mtab.readlines():
|
||||||
self.parts = {} #initializing empty dictionary for partitions and uuids
|
if device in line:
|
||||||
for self.uuid in self.uuids: #write /dev/names as keys and uuids as values in the dictionary
|
return line.split()[1]
|
||||||
self.parts["/dev/" + os.readlink("/dev/disk/by-uuid/" + self.uuid)[6:]] = self.uuid
|
break
|
||||||
return self.parts #return the dictionary for further useage
|
mtab.close()
|
||||||
|
|
||||||
|
|
||||||
|
# getting all local partitions plus their uuids
|
||||||
|
def getpartitions():
|
||||||
|
uuids = os.listdir("/dev/disk/by-uuid") #folder contains symlinks to the actual disk devices
|
||||||
|
parts = {} #initializing empty dictionary for partitions and uuids
|
||||||
|
for uuid in uuids: #write /dev/names as keys and uuids as values in the dictionary
|
||||||
|
parts["/dev/" + os.readlink("/dev/disk/by-uuid/" + uuid)[6:]] = uuid
|
||||||
|
return parts #return the dictionary for further useage
|
||||||
|
|
||||||
|
|
||||||
|
test = getpartitions()
|
||||||
|
print test
|
||||||
|
|
||||||
|
print ""
|
||||||
|
|
||||||
|
for device in test.keys():
|
||||||
|
ismounted = getmountpoint(device)
|
||||||
|
if ismounted != None:
|
||||||
|
print str(device) + " is mounted at " + str(ismounted)
|
||||||
|
else:
|
||||||
|
print str(device) + " is not mounted"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
test = partobj()
|
|
||||||
bla = test.getpartitions()
|
|
||||||
print bla
|
|
||||||
|
|
Reference in New Issue