Comment 4 for bug 660181

Revision history for this message
dag (dag-wieers) wrote : Re: [Bug 660181] Re: dstat lost color support in ubuntu 10.10

On Thu, 14 Oct 2010, Maxime Ritter 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....

Apparently the wrong TERM is not the cause for this. Trying to reproduce
this on my CentOS system I get:

[dag@moria dstat]$ TERM=dumb ./dstat -ta
----system---- ----total-cpu-usage---- -dsk/total- -net/total- ---paging-- ---system--
      time |usr sys idl wai hiq siq| read writ| recv send| in out | int csw
14-10 09:57:45| 6 1 92 1 0 0| 29k 50k| 0 0 |4924B 5696B|2408 7228
14-10 09:57:46| 2 0 98 0 0 0| 0 0 | 262B 112B| 0 0 | 324 685

So the wrong TERM is not the cause here. Could you remove the try/except
statement around that block and send me the exception you get ?

Also, what version of Dstat is this ?

>> ----
>> 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

Yes, that's what I would expect, although without a proven root-cause or
reproducing the problem I prefer not to change it yet.

--
-- dag wieers, <email address hidden>, http://dag.wieers.com/ --
[Any errors in spelling, tact or fact are transmission errors]