Package: pydf
Version: 9
Severity: normal

Hi,

While using pydf from a script, pydf fails like this:

# pydf > /dev/null
Traceback (most recent call last):
  File "/usr/bin/pydf", line 630, in <module>
    terminal_width = get_terminal_width()
  File "/usr/bin/pydf", line 82, in get_terminal_width
    width = handler()
  File "/usr/bin/pydf", line 64, in get_terminal_width_resize
    c = subprocess.getoutput('resize').split('\n')
AttributeError: 'module' object has no attribute 'getoutput'


pydf uses getoutput() and getstatusoutput() methods from subprocess
module but these methods only exists into subprocess module with
Python >= 3.x

Attached is a patch which fixes this issue.

Regards,

--
Emmanuel Bouthenot

-- System Information:
Debian Release: squeeze/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (101, 'experimental')
Architecture: i386 (i686)

Kernel: Linux 2.6.33-2-686 (SMP w/2 CPU cores)
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

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

pydf recommends no packages.

pydf suggests no packages.

-- no debconf information
--- pydf.orig	2010-05-02 14:12:28.210246852 +0200
+++ pydf	2010-05-02 14:13:58.746245561 +0200
@@ -1,6 +1,6 @@
 #! /usr/bin/python
 
-import sys, os, string, subprocess, struct
+import sys, os, string, struct
 from optparse import OptionParser
 
 from math import log
@@ -10,6 +10,14 @@
     # will not give the same result for broken symbolic links, but who cares...
     os.path.lexists = os.path.exists
 
+if sys.version_info < (3, 0):
+    # getoutput() and getstatusoutput() methods have
+    # been moved from commands to the subprocess module
+    # with Python >= 3.x
+    import commands as cmd
+else:
+    import subprocess as cmd
+
 str_ljust = str.ljust
 str_rjust = str.rjust
 str_center = str.center
@@ -61,7 +69,7 @@
     
 
 def get_terminal_width_resize():
-    c = subprocess.getoutput('resize').split('\n')
+    c = cmd.getoutput('resize').split('\n')
     c = [x for x in c if x.startswith('COLUMNS=')]
     if c:
         c = c[0]
@@ -290,7 +298,7 @@
                 break
         else:
             # fallback, first try to parse mount output
-            status, mout = subprocess.getstatusoutput('mount')
+            status, mout = cmd.getstatusoutput('mount')
             if status !=0:
                 return dummy_result
             mlines = mout.split('\n')

Reply via email to