getScreenWidth() returns an invalid width of zero

Bug #300456 reported by Camilo
10
Affects Status Importance Assigned to Milestone
Smart Package Manager
Fix Released
Undecided
Gustavo Niemeyer

Bug Description

Smart versions: .52 and 1.1

Under a very specific condition, such as when using pexpect to spawn a smart process to do some work from turbo gears web server, smart fails to get a valid screen width when calling getScreenWidth(). In this environment it returns a value of zero which in turn creates problems later on by generating a badly formed self._topicmaskn inside interfaces/text/progress.py TextProgress.setScreenWidth() method.

the workaround is to change the following code from interface.py:

def getScreenWidth():
    s = struct.pack('HHHH', 0, 0, 0, 0)
    try:
        x = fcntl.ioctl(1, termios.TIOCGWINSZ, s)
    except IOError:
        return 80
    return struct.unpack('HHHH', x)[1]

to:

def getScreenWidth():
    s = struct.pack('HHHH', 0, 0, 0, 0)
    try:
        x = fcntl.ioctl(1, termios.TIOCGWINSZ, s)
    except IOError:
        return 80
    width = struct.unpack('HHHH', x)[1]
    if width > 0:
        return width
    else:
        return 80

which ensures returning a valid default value when the width is reported to be zero or less than zero.

Camilo

Related branches

Revision history for this message
Anders F Björklund (afb) wrote :

This was also in openSUSE, as smart-0.52-termios-0width.patch:

* Sat Jan 26 2008 guru AT unixtech.be
- added patch to fix terminal width determination on serial and xen consoles

Changed in smart:
milestone: none → 1.2
Changed in smart:
milestone: 1.2 → 1.1.2
Revision history for this message
Gustavo Niemeyer (niemeyer) wrote :

That's been fixed in trunk with proper testing.

Changed in smart:
assignee: nobody → niemeyer
status: New → Fix Committed
Revision history for this message
Anders F Björklund (afb) wrote :

Released, 2009-03-04

Changed in smart:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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