rhinstaller / fedup

Deprecated Fedora Upgrade tool
GNU General Public License v2.0
23 stars 13 forks source link

Handle stupid terminals gracefully #41

Closed greg0ire closed 10 years ago

greg0ire commented 10 years ago

Using gnome-terminal on Fedora 19, I was trying to update to Fedora 20, and got this message :

Traceback (most recent call last): File "/bin/fedup", line 236, in main(args) File "/bin/fedup", line 159, in main pkgs = download_packages(f) File "/bin/fedup", line 65, in download_packages updates = f.build_update_transaction(callback=output.DepsolveCallback(f)) File "/usr/lib/python2.7/site-packages/fedup/download.py", line 257, in build_update_transaction (rv, msgs) = self.buildTransaction(unfinished_transactions_check=False) File "/usr/lib/python2.7/site-packages/yum/init.py", line 1195, in buildTransaction (rescode, restring) = self.resolveDeps() File "/usr/lib/python2.7/site-packages/yum/depsolve.py", line 884, in resolveDeps CheckDeps, checkinstalls, checkremoves, missing = self._resolveRequires(errors) File "/usr/lib/python2.7/site-packages/yum/depsolve.py", line 986, in _resolveRequires self.dsCallback.pkgAdded(txmbr.pkgtup, dscb_ts_state) File "/usr/lib/python2.7/site-packages/fedup/textoutput.py", line 113, in pkgAdded self.progressbar.update(self.mode_counter['ud']) File "/usr/lib/python2.7/site-packages/fedup/textoutput.py", line 76, in update self.tty.write("\r%s" % self) File "/usr/lib/python2.7/site-packages/fedup/textoutput.py", line 69, in str return self.formatstr.format(self) File "/usr/lib/python2.7/site-packages/fedup/textoutput.py", line 61, in bar barwidth = self.width - len(otherstuff.format(self)) - 2 # 2 brackets File "/usr/lib/python2.7/site-packages/fedup/textoutput.py", line 51, in width return term.size.cols or 80 # fallback for stupid terminals AttributeError: 'module' object has no attribute 'size'

greg0ire commented 10 years ago

Simple workaround while waiting for a proper fix : edit /usr/lib/python2.7/site-packages/fedup/textoutput.py and on line 51, simply write return 80.

wgwoods commented 10 years ago

Hrm. That's not supposed to happen; if the terminal is dumb, term.size.cols should just be 0:

def getsize(fd=ttyfd):
    '''Return the size of the tty attached to the given fd (default: stdin)'''
    try:
        buf = fcntl.ioctl(fd, termios.TIOCGWINSZ, struct.pack('8x'))
        (rows, cols, _, _) = struct.unpack('hhhh', buf)
        size = winsize(rows, cols)
    except IOError:
        size = winsize(0, 0)
    return size

size = getsize()

Does it work if you change /usr/lib/python2.7/site-packages/fedup/terminal.py to add this line:

def getsize(fd=ttyfd):
    '''Return the size of the tty attached to the given fd (default: stdin)'''
    size = winsize(0, 0)  # <--- add this line

Also: why is your terminal dumb? How is it set up? Can I reproduce this?

greg0ire commented 10 years ago

I'll be able to try that in ~ 3 hours. My terminal has nothing special that I remember of, it's the original gnome-terminal you get when you install fedora 19 32bits edition. I'll get you the precise version number this evening.

wgwoods commented 10 years ago

Strange. Works totally fine here. What version of fedup and/or yum are on your system?

greg0ire commented 10 years ago

So... it's on a small compaq laptop. gnome-terminal version is 3.8.4, fedup version seems to be 0.8.0 (this file exists : /usr/lib/python2.7/site-packages/fedup-0.8.0-py2.7.egg-info) yum version:

yum --version                                                               ~
3.4.3
  Installés : rpm-4.11.1-3.fc19.i686 à 2013-09-22 19:06
  Compilé   : Fedora Project à 2013-09-09 13:10
  Commité   : Matilainen <pmatilai@redhat.com> à 2013-09-09

  Installés : yum-3.4.3-128.fc19.noarch à 2014-01-06 21:10
  Compilé   : Fedora Project à 2013-12-20 19:59
  Commité   : James Antill <james at fedoraproject.org> à 2013-12-19

aaaaand... I can't reproduce the bug today. Oh, I hate it when it happens. Sorry for bothering you.