[Uludag-commits] r17597 - branches/yali4/yali4

uludag-commits at pardus.org.tr uludag-commits at pardus.org.tr
8 Nis 2008 Sal 12:29:47 EEST


Author: gokmen.goksel
Date: Tue Apr  8 12:29:47 2008
New Revision: 17597

Modified:
   branches/yali4/yali4/filesystem.py
   branches/yali4/yali4/storage.py
Log:
 * Fix for Medium Not Found error
 * Fix for corrupted Fat Partition Labels (thanks to Gökçen and his laptop)



Modified: branches/yali4/yali4/filesystem.py
=================================================================
--- branches/yali4/yali4/filesystem.py	(original)
+++ branches/yali4/yali4/filesystem.py	Tue Apr  8 12:29:47 2008
@@ -86,6 +86,11 @@
 
     def getLabel(self, partition):
         """ Read filesystem label and return """
+        base = os.walk("/dev/disk/by-label/").next()
+        path = partition.getPath()
+        for part in base[2]:
+            if os.path.realpath("%s%s" % (base[0],part)) == path:
+                return part
         return None
 
     def setLabel(self, partition, label):
@@ -506,20 +511,6 @@
         if p.close():
             raise YaliException, "fat32 format failed: %s" % partition.getPath()
 
-    def getLabel(self, partition):
-        cmd_path = sysutils.find_executable("dosfslabel")
-        if not cmd_path:
-            e = "Command not found to get label for %s filesystem" %(self.name())
-            raise FSError, e 
-
-        cmd = "%s %s" % (cmd_path, partition.getPath())
-        p = os.popen(cmd)
-        label = p.read()
-        p.close()
-        if not label == '':
-            return label.strip(' \n')
-        return False
-
     def setLabel(self, partition, label):
         label = self.availableLabel(label)
         cmd_path = sysutils.find_executable("dosfslabel")

Modified: branches/yali4/yali4/storage.py
=================================================================
--- branches/yali4/yali4/storage.py	(original)
+++ branches/yali4/yali4/storage.py	Tue Apr  8 12:29:47 2008
@@ -495,12 +495,14 @@
         return sig
 
     def get_mbr_sig(self, _f):
-        f = file(_f)
-        f.seek(self.edd_offset)
-        a = f.read(self.edd_len)
-        f.close()
-
-        sig = self.match_sys(binascii.b2a_hex(a))
+        try:
+            f = file(_f)
+            f.seek(self.edd_offset)
+            a = f.read(self.edd_len)
+            f.close()
+            sig = self.match_sys(binascii.b2a_hex(a))
+        except:
+            return False
         return sig
 
     def list_edd_signatures(self):
@@ -521,7 +523,9 @@
     def list_mbr_signatures(self):
         sigs = {}
         for d in self.blockDevices():
-            sigs[self.get_mbr_sig(d)] = d
+            sig = self.get_mbr_sig(d)
+            if sig:
+                sigs[sig] = d
         return sigs
 
 def getOrderedDiskList():


Uludag-commits mesaj listesiyle ilgili daha fazla bilgi