Comment 3 for bug 660181

Revision history for this message
Maxime Ritter (airmax) wrote :

dag wrote:
> Quite easy, the block that tests for a functional curses apparently fails
> on Ubuntu 10.10. What TERM was set in this case so I can reproduce the
> problem and see if another error message makes any sense in this case ?

TERM=dumb

It's very easy to reproduce : take a Xubuntu i386 10.10 CD, and install it with an unplugged internet connection (or without the package updates, as the fix for Bug #621927 has been released, but didn't catch my mirror). Reboot, run the xfce terminal (default terminal in xubuntu), apt-get install dstat, then run dstat....

>
> ----
> def gettermcolor(color=True):
> "Return whether the system can use colors or not"
> if color and sys.stdout.isatty():
> try:
> import curses
> curses.setupterm()
> if curses.tigetnum('colors') < 0:
> return False
> except:
> print >>sys.stderr, 'Color support is disabled, python-curses is not installed.'
> return False
> return color
> ----
>
> If you have a better implementation or any suggestion, feel free to
> provide that information rather than pointing in a general direction...

I don't know Python, but I can some suggest 2 fixes :

1. you can change the message to "Color support is disabled, python-curses is not installed, not working, or TERM $env{'TERM'} not recognized".

2. Something like that (like that, as I said, I don't the Python langage) :

def gettermcolor(color=True):
     "Return whether the system can use colors or not"
     if color and sys.stdout.isatty():
         try:
             import curses
         except:
             print >>sys.stderr, 'Color support is disabled, python-curses is not installed.'
             return False
 try:
             curses.setupterm()
             if curses.tigetnum('colors') < 0:
                 return False
         except:
             print >>sys.stderr, 'Color support is disabled; TERM=$ENV{'TERM'} not recognized, or python-curses is not working.'
             return False
     return color