]> arthur.barton.de Git - bup.git/commitdiff
cmd/memtest: don't die if /proc/self/status is the wrong format.
authorAvery Pennarun <apenwarr@gmail.com>
Sat, 5 Feb 2011 01:30:11 +0000 (17:30 -0800)
committerAvery Pennarun <apenwarr@gmail.com>
Sat, 5 Feb 2011 01:32:25 +0000 (17:32 -0800)
Apparently Solaris has /proc/self/status, but it's binary and so our
Linux-centric parser couldn't handle it.  The data we're getting from it is
non-critical, so just ignore the parse error and let the high-level code in
report() deal with it.

Reported by henning mueller, diagnosed by Gabriel Filion.  Thanks guys!

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
cmd/memtest-cmd.py

index 19c33931b6557c1a90010dda14cf5f294963f603..4ed7c4742d4433d7631444239444624ebd1fea8a 100755 (executable)
@@ -18,8 +18,14 @@ def linux_memstat():
             _linux_warned = 1
         return {}
     for line in f:
-        k,v = re.split(r':\s*', line.strip(), 1)
-        d[k] = v
+        # Note that on Solaris, this file exists but is binary.  If that
+        # happens, this split() might not return two elements.  We don't
+        # really need to care about the binary format since this output
+        # isn't used for much and report() can deal with missing entries.
+        t = re.split(r':\s*', line.strip(), 1)
+        if len(t) == 2:
+            k,v = t
+            d[k] = v
     return d