Package: pydf
Version: 0.9.9
Followup-For: Bug #119992

Hi,

pydf should not use red color if read-only media (eg. cdrom) is
mounted and 100% full. Instead of trying to read the filetype,
parse the mount options and avoid red color for read-only devices.

Attached is a patch, tested on my box with several read-only devices.

Regards,
  Bastian

-- System Information:
Debian Release: testing/unstable
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.17-treasure1
Locale: [EMAIL PROTECTED], [EMAIL PROTECTED] (charmap=ISO-8859-15)

Versions of packages pydf depends on:
ii  python                        2.3.5-11   An interactive high-level object-o

pydf recommends no packages.

-- no debconf information
--- pydf.orig   2006-07-14 23:17:12.746602278 +0200
+++ pydf        2006-07-14 23:27:24.110090932 +0200
@@ -225,8 +225,11 @@
                     continue
                 device, on = line.split(' on ', 1)
                 device = device.split()[0]
-                on = on.split()[0]
-                r[on] = (device, '')
+                onparts = on.split()
+                on = onparts[0]
+                # option format: (a,b,..)
+                opts = onparts[-1][1:-1].split(",")
+                r[on] = (device, '', opts)
             if r:
                 return r
             else:
@@ -237,18 +240,18 @@
     r = {}
     for l in mountlines:
         spl = l.split()
-        if len(spl)<3:
+        if len(spl)<4:
             print "Error in", mountfile
             print `l`
             continue
-        device, mp, typ = spl[0:3]
-        r[mp] = (device, typ)
+        device, mp, typ, opts = spl[0:4]
+        r[mp] = (device, typ, opts.split(","))
     return r
     
 def display_mp(mp):
     "display line for mountpoint mp, if mp==None display just the header"
     if mp:
-        device, fstype = mountpoints[mp]
+        device, fstype, opts = mountpoints[mp]
 
         try:
             status = os.statvfs(mp)
@@ -301,7 +304,8 @@
                 width = int(width*terminal_width)-1
             out( makecolour(current_colour) )
             if mp:
-                if j[0] in ['perc', 'avail', 'bar'] and fstype not in  
("iso9660", "udf"):
+                if j[0] in ['perc', 'avail', 'bar'] and \
+                   fstype not in  ("iso9660", "udf") and "ro" not in opts:
                     if perc > FILL_THRESH:
                         out( makecolour(filled_fs_colour) )
                     if perc> FULL_THRESH:

Reply via email to