trunk/pardus-python/pardus - Method for getting address of boot directory

Bahadır Kandemir uludag-commits at pardus.org.tr
6 Ara 2010 Pzt 13:35:10 EET


Author: bahadir.kandemir
Date: Mon Dec  6 13:35:10 2010
New Revision: 33719

Modified:
   trunk/pardus-python/pardus/diskutils.py
Log:
Method for getting address of boot directory

---
 diskutils.py |   31 +++++++++++++++++++++++++++----
 1 file changed, 27 insertions(+), 4 deletions(-)

Modified: trunk/pardus-python/pardus/diskutils.py
=================================================================
--- trunk/pardus-python/pardus/diskutils.py	(original)
+++ trunk/pardus-python/pardus/diskutils.py	Mon Dec  6 13:35:10 2010
@@ -223,19 +223,42 @@
     else:
         return None
 
-def getRoot():
+def getDevice(path):
     """
-        Gives current root device address.
+        Gives device address of a path.
 
+        Arguments:
+            path: Directory path
         Returns:
             Device address (e.g. "/dev/sda1")
     """
-
     for mount in os.popen("/bin/mount").readlines():
         mount_items = mount.split()
-        if mount_items[2] == "/":
+        if mount_items[2] == path:
             if mount_items[0].startswith("/dev"):
                 return mount_items[0]
             elif mount_items[0].startswith("LABEL="):
                 return getDeviceByLabel(mount_items[0].split('=', 1)[1])
+            elif mount_items[0].startswith("UUID="):
+                return getDeviceByUUID(mount_items[0].split('=', 1)[1])
 
+def getRoot():
+    """
+        Gives current root device address.
+
+        Returns:
+            Device address (e.g. "/dev/sda1")
+    """
+    return getDevice("/")
+
+def getBoot():
+    """
+        Gives current boot device address.
+
+        Returns:
+            Device address (e.g. "/dev/sda1")
+    """
+    if os.path.ismount("/boot"):
+        return getDevice("/boot")
+    else:
+        return getRoot()


Uludag-commits mesaj listesiyle ilgili daha fazla bilgi