playground/mehmet - do not send labels to disk-manager from mudur
paketler-commits at pardus.org.tr
paketler-commits at pardus.org.tr
Mon Nov 1 14:10:54 EET 2010
Author: mehmet.ozdemir
Date: Mon Nov 1 14:10:54 2010
New Revision: 104115
Modified:
playground/mehmet/comar/comar/models/Disk.Manager.xml
playground/mehmet/disk-manager/src/disk-manager.py
playground/mehmet/mudur/comar/disk.py
Log:
do not send labels to disk-manager from mudur
---
comar/comar/models/Disk.Manager.xml | 4 ---
disk-manager/src/disk-manager.py | 20 +--------------
mudur/comar/disk.py | 47 ++++++++++++++++++++++++------------
3 files changed, 34 insertions(+), 37 deletions(-)
Modified: playground/mehmet/comar/comar/models/Disk.Manager.xml
=================================================================
--- playground/mehmet/comar/comar/models/Disk.Manager.xml (original)
+++ playground/mehmet/comar/comar/models/Disk.Manager.xml Mon Nov 1 14:10:54 2010
@@ -3,10 +3,6 @@
<method name="getDevices" access_label="get">
<arg name="devices" type="as" direction="out"/>
</method>
- <method name="getDeviceByLabel" access_label="get">
- <arg name="label" type="s" direction="in"/>
- <arg name="device" type="s" direction="out"/>
- </method>
<method name="isMounted" access_label="get">
<arg name="device" type="s" direction="in"/>
<arg name="path" type="s" direction="out"/>
Modified: playground/mehmet/disk-manager/src/disk-manager.py
=================================================================
--- playground/mehmet/disk-manager/src/disk-manager.py (original)
+++ playground/mehmet/disk-manager/src/disk-manager.py Mon Nov 1 14:10:54 2010
@@ -150,8 +150,6 @@
self.entries = {}
# Devices on entry list
self.devices = []
- # Labels
- self.labels = {}
# Items
self.items = {}
# Get entries
@@ -185,9 +183,8 @@
else:
return
if not exception:
- for entry in result[0]:
- device = self.getRealDevice(entry)
- self.entries[device] = self.link.Disk.Manager[self.package].getEntry(entry)
+ for device in result[0]:
+ self.entries[device] = self.link.Disk.Manager[self.package].getEntry(device)
# Get devices
self.link.Disk.Manager[self.package].getDevices(async=self.asyncGetDevices)
@@ -222,17 +219,6 @@
info = self.entries[device]
return "%s" % (info[0])
- def getDeviceByLabel(self, label):
- return self.link.Disk.Manager[self.package].getDeviceByLabel(label)
-
- def getRealDevice(self, device):
- if device.startswith("LABEL="):
- label = device.split("=", 1)[1]
- device = self.getDeviceByLabel(label)
- self.labels[device] = label
- return device
- return device
-
def slotToggle(self, checked):
if checked:
self.slotFS()
@@ -313,8 +299,6 @@
self.frame_detail.setEnabled(False)
return
device = str(self.items[item])
- if device in self.labels:
- device = "LABEL=%s" % self.labels[device]
if self.frame_entry.isChecked():
# Path
path = str(self.line_mountpoint.text())
Modified: playground/mehmet/mudur/comar/disk.py
=================================================================
--- playground/mehmet/mudur/comar/disk.py (original)
+++ playground/mehmet/mudur/comar/disk.py Mon Nov 1 14:10:54 2010
@@ -94,7 +94,10 @@
# Replace UUID value with device name after reading it from fstab
if line[0].startswith('UUID='):
line[0] = getPartitionNameByUUID(line[0])
- entries.append(line)
+ entries.append(line)
+ elif line[0].startswith('LABEL='):
+ line[0] = getDeviceByLabel(line[0].replace('LABEL=', ''))
+ entries.append(line)
return entries
def createPath(device, path):
@@ -209,6 +212,14 @@
parts.append(part)
return parts
+def getLabel(device):
+ """
+ Finds label for the given partition.
+ """
+ cmd = "/sbin/blkid -s LABEL -o value %s" % device
+ proc = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE)
+ return proc.communicate()[0].strip()
+
def getPath(device):
"""
Gets partition name and determine a path for that partition.
@@ -219,9 +230,7 @@
path_, fsType_, options_ = getEntry(device)
return path_
path = '/media/'
- cmd = "/sbin/blkid -s LABEL -o value %s" % device
- proc = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE)
- label = proc.communicate()[0].strip()
+ label = getLabel(device)
# There may be partitions without a label
if not label:
if not os.path.exists(path+'disk'):
@@ -253,10 +262,6 @@
return path
def mount(device, path):
- if device.startswith("LABEL="):
- device = getDeviceByLabel(device.split("LABEL=")[1])
- elif device.startswith("UUID="):
- device = getPartitionNameByUUID(device)
if not path:
path = getPath(device)
if not createPath(device, path):
@@ -268,10 +273,6 @@
runCommand(['/bin/mount', device, path])
def umount(device):
- if device.startswith("LABEL="):
- device = getDeviceByLabel(device.split("LABEL=")[1])
- elif device.startswith("UUID="):
- device = getPartitionNameByUUID(device)
for dev, path in getMounted():
if dev == device and path == "/":
fail(_(FAIL_ROOT) % device)
@@ -285,14 +286,24 @@
return []
def listPaths():
+ """
+ Return paths of the entries in fstab.
+ """
try:
paths = [x[1] for x in parseFstab(FSTAB)]
return paths
except DMException:
return []
+def isLabelRecord(device):
+ for line in open(FSTAB):
+ line = line.strip()
+ if line.replace('\t', ' ').split()[0] == 'LABEL='+getLabel(device):
+ return True
+
def addEntry(device, path, fsType, options):
path_own = False
+ # If the path value already exist in fstab, cut the operation
if path in listPaths():
fail(_(FAIL_PATH_ALREADY_EXIST) % path)
if device in listEntries():
@@ -311,8 +322,14 @@
#elif device in [x[0] for x in getMounted()]:
# Device is mounted
#fail(_(FAIL_MOUNTED) % device)
+ partText = ''
+ # Before removing the entry check if it is a label record or uuid record
# Remove previous one to prevent duplicates
if old_path:
+ if isLabelRecord(device):
+ partText = 'LABEL='+getLabel(device)
+ else:
+ partText = 'UUID='+getUUID(device)
removeEntry(device, silent=True)
# Add new entry
_options = []
@@ -325,9 +342,9 @@
file(FSTAB, 'a').write('\n')
_options = ','.join(_options)
if _options:
- file(FSTAB, 'a').write('%s %s %s %s 0 0\n' % ('UUID='+getUUID(device), path, fsType, _options))
+ file(FSTAB, 'a').write('%s %s %s %s 0 0\n' % (partText, path, fsType, _options))
else:
- file(FSTAB, 'a').write('%s %s %s defaults 0 0\n' % ('UUID='+getUUID(device), path, fsType))
+ file(FSTAB, 'a').write('%s %s %s defaults 0 0\n' % (partText, path, fsType))
# Notify clients
notify("Disk.Manager", "changed", ())
# If the partition is not already mounted the given path and,
@@ -363,7 +380,7 @@
newlines = []
for line in open(FSTAB):
line = line.strip()
- if not len(line) == 0 and not line.replace('\t', ' ').split()[0] == 'UUID='+getUUID(device):
+ if not len(line) == 0 and not (line.replace('\t', ' ').split()[0] == 'UUID='+getUUID(device) or line.replace('\t', ' ').split()[0] == 'LABEL='+getLabel(device)):
newlines.append(line)
file(FSTAB, 'w').write('\n'.join(newlines))
if not file(FSTAB).read()[-1] == '\n':
More information about the paketler-commits
mailing list