my first class :)
This commit is contained in:
parent
f92974c8b0
commit
6b39e15c87
|
@ -3,17 +3,19 @@
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
class partobj(object): #my first class :)
|
||||||
|
# def __init__(self):
|
||||||
|
# self.dev = ""
|
||||||
|
|
||||||
# getting all local partitions plus their uuids
|
# getting all local partitions plus their uuids
|
||||||
def getpartitions():
|
def getpartitions(self):
|
||||||
uuids = os.listdir("/dev/disk/by-uuid") #folder contains symlinks to the actual disk devices
|
self.uuids = os.listdir("/dev/disk/by-uuid") #folder contains symlinks to the actual disk devices
|
||||||
parts = {} #initializing empty dictionary for partitions and uuids
|
self.parts = {} #initializing empty dictionary for partitions and uuids
|
||||||
for uuid in uuids: #write /dev/names as keys and uuids as values in the dictionary
|
for self.uuid in self.uuids: #write /dev/names as keys and uuids as values in the dictionary
|
||||||
parts["/dev/" + os.readlink("/dev/disk/by-uuid/" + uuid)[6:]] = uuid
|
self.parts["/dev/" + os.readlink("/dev/disk/by-uuid/" + self.uuid)[6:]] = self.uuid
|
||||||
return parts #return the dictionary for further useage
|
return self.parts #return the dictionary for further useage
|
||||||
|
|
||||||
|
|
||||||
|
test = partobj()
|
||||||
partitions = getpartitions()
|
bla = test.getpartitions()
|
||||||
print partitions
|
print bla
|
||||||
|
|
||||||
|
|
Reference in New Issue