dstat lost color support in ubuntu 10.10

Bug #660181 reported by Maxime Ritter
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
dstat (Ubuntu)
Fix Released
Undecided
dag

Bug Description

Binary package hint: dstat

Usually when I start dstat, there are nice colors displayed.... But on a fresh xubuntu 10.10 installation, instead of colors, I get this error message : Color support is disabled, python-curses is not installed.

root@rakia:~# dstat -al
Color support is disabled, python-curses is not installed.
----total-cpu-usage---- -dsk/total- -net/total- ---paging-- ---system-- ---load-avg---
usr sys idl wai hiq siq| read writ| recv send| in out | int csw | 1m 5m 15m
  7 2 90 1 0 0| 221k 614k| 0 0 | 0 0 | 992 1560 |0.99 0.66 0.50

And I didn't find any package providing python-curses... Python install bug ? Dstat package ?

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

Ok, in fact it is working ; the TERM environment variable was wrongly set up.

So the real bug are :
- why does dstat complain about missing python-curses instead of a wrong TERM environnement ? (not an ubuntu bug)
- why is the default xubuntu terminal application reporting a wrong TERM ? (Bug #659023)

So we can close this bug.

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

On Wed, 13 Oct 2010, Maxime Ritter wrote:

> Ok, in fact it is working ; the TERM environment variable was wrongly
> set up.
>
> So the real bug are :
> - why does dstat complain about missing python-curses instead of a wrong TERM environnement ? (not an ubuntu bug)
> - why is the default xubuntu terminal application reporting a wrong TERM ? (Bug #659023)
>
> So we can close this bug.
>
> ** Changed in: dstat (Ubuntu)
> Status: New => Invalid

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 ?

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

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

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

Revision history for this message
dag (dag-wieers) wrote :

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]

Revision history for this message
dag (dag-wieers) wrote :
Download full text (3.2 KiB)

On Thu, 14 Oct 2010, dag wrote:

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

Ok, I had some time to look at this and on CentOS 'dumb' is in fact a real
termcap entry that does not support colors. But if I instead use something
fake, I get this:

[dag@moria dstat]$ TERM=dag dstat -ta
Color support is disabled, python-curses is not installed.
----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 19:39:25| 2 0 98 0 0 0| 77k 70k| 0 0 | 0 0 | 318 637
14-10 19:39:26| 1 1 99 0 0 0| 0 0 | 0 0 | 0 0 | 547 1389

So I have now fixed this to display:

[dag@moria dstat]$ TERM=dag ./dstat -ta
Color support is disabled as terminal (TERM=dag) does not support colors.
----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 19:40:06| 2 0 98 0 0 0| 77k 70k| 0 0 | 0 0 | 318 638
14-10 19:40:07| 1 1 99 0 0 0| 0 16k| 0 0 | 0 0 | 515 1210

The fix was quite simple:

----
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 ImportError:
             print >>sys.stderr, 'Color support is disabled as python-curses is not installed.'
             return False
         except:
             print >>sys.stderr, 'Color support is disabled as terminal (TERM=%s) does not support colors.' % os.getenv('TERM')
             return False
     return color
----

Thanks for reporting !
--
-- dag wieers, <email address hidden>, http://dag.wieers.com/ --
[Any errors...

Read more...

dag (dag-wieers)
Changed in dstat (Ubuntu):
status: Invalid → Fix Released
assignee: nobody → dag (dag-wieers)
status: Fix Released → Fix Committed
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.