Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

urlscan should redraw the screen after exec'ing browser #10

Closed
ghost opened this issue Nov 30, 2014 · 12 comments
Closed

urlscan should redraw the screen after exec'ing browser #10

ghost opened this issue Nov 30, 2014 · 12 comments

Comments

@ghost
Copy link

ghost commented Nov 30, 2014

Forwarded from: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=409416


After a text-based browser exits urlscan waits for user input but there
is no display. Control-L neatly fixes the problem, but the program
should probably redraw the screen on its own to restore it.


Reproductible with

echo '\nhttp://github.com/firecat53/urlscan'|BROWSER=links urlscan
@ghost
Copy link
Author

ghost commented Dec 4, 2014

Got this during testing.

Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 552, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 505, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/home/xakz/devel/debian/packages/urlscan/git/urlscan/urlchoose.py", line 200, in _loading_thread
    self.draw_screen(size)
  File "/home/xakz/devel/debian/packages/urlscan/git/urlscan/urlchoose.py", line 204, in draw_screen
    self.ui.draw_screen(size, canvas)
  File "/usr/lib/python2.7/dist-packages/urwid/curses_display.py", line 470, in draw_screen
    assert self._started
AssertionError

How to reproduce:

 ~/devel/urlscan $ echo '\nhttp://github.com/'|BROWSER=links PYTHONPATH=. bin/urlscan

All work fine. I select the link, links starts and load the github page. I press q to quit links, links quits and urlscan redraw the screen, so this fix the bug. but when I press q again to quit urlscan I see the error above. Perhaps a problem with my (old Debian) version of urwid.

@firecat53
Copy link
Owner

  1. What version of urwid and python are you using?
  2. Can you test with a newer version of urwid inside a virtualenv to make sure it works?
  3. Just confirming that it's with python 2.7? Does it work with python 3.x with the packages from the repository?
  4. Does it work for you on Ubuntu?
    Thanks!

@ghost
Copy link
Author

ghost commented Dec 4, 2014

Well, I will separate my tests in different comments that follow.
I also tested with default graphical browser, the problem is unchanged. So, the problem do not come from the text browser.

@ghost
Copy link
Author

ghost commented Dec 4, 2014

Test 1 - Debian stable - python 2.x.

Details:

python   2.7.3-4+deb7u1
python-urwid   1.0.1-2

Traceback:

Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 552, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 505, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/home/xakz/devel/debian/packages/urlscan/git/urlscan/urlchoose.py", line 200, in _loading_thread
    self.draw_screen(size)
  File "/home/xakz/devel/debian/packages/urlscan/git/urlscan/urlchoose.py", line 204, in draw_screen
    self.ui.draw_screen(size, canvas)
  File "/usr/lib/python2.7/dist-packages/urwid/curses_display.py", line 470, in draw_screen
    assert self._started
AssertionError

Long delay (3-4 sec) after quitting urlscan and the above traceback.

@ghost
Copy link
Author

ghost commented Dec 4, 2014

Test 2 - Debian stable - python 3.x

Details:

python3   3.2.3-6
python3-urwid  1.0.1-2

urlscan do not start and output the following traceback:

Traceback (most recent call last):
  File "bin/urlscan", line 71, in <module>
    ui.main()
  File "/home/xakz/devel/debian/packages/urlscan/git/urlscan/urlchoose.py", line 157, in main
    return self.ui.run_wrapper(self.run)
  File "/usr/lib/python3/dist-packages/urwid/curses_display.py", line 151, in run_wrapper
    return fn()
  File "/home/xakz/devel/debian/packages/urlscan/git/urlscan/urlchoose.py", line 165, in run
    self.draw_screen(size)
  File "/home/xakz/devel/debian/packages/urlscan/git/urlscan/urlchoose.py", line 203, in draw_screen
    canvas = self.top.render(size, focus=True)
  File "/usr/lib/python3/dist-packages/urwid/widget.py", line 132, in cached_render
    canv = fn(self, size, focus=focus)
  File "/usr/lib/python3/dist-packages/urwid/container.py", line 596, in render
    focus and self.focus_part == 'body')
  File "/usr/lib/python3/dist-packages/urwid/widget.py", line 170, in finalize_render
    canv = fn(self, size, focus=focus)
  File "/usr/lib/python3/dist-packages/urwid/listbox.py", line 331, in render
    (maxcol, maxrow), focus=focus)
  File "/usr/lib/python3/dist-packages/urwid/listbox.py", line 219, in calculate_visible
    self._set_focus_complete( (maxcol, maxrow), focus )
  File "/usr/lib/python3/dist-packages/urwid/listbox.py", line 531, in _set_focus_complete
    offset, 'above' )
  File "/usr/lib/python3/dist-packages/urwid/listbox.py", line 695, in change_focus
    if target.move_cursor_to_coords((maxcol,),pref_col,row):
  File "/usr/lib/python3/dist-packages/urwid/container.py", line 1273, in move_cursor_to_coords
    if x > col and best is None:
TypeError: unorderable types: int() > str()

The version of urwid is probably too old for pyhon3.

@ghost
Copy link
Author

ghost commented Dec 4, 2014

Test 3 - Debian unstable - python 2.x

Details:

python  2.7.8-2
python-urwid   1.2.1-2+b1

Same as test 1, all works fine until I quit urlscan. Traceback:

Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 763, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/home/xakz/devel/debian/packages/urlscan/git/urlscan/urlchoose.py", line 200, in _loading_thread
    self.draw_screen(size)
  File "/home/xakz/devel/debian/packages/urlscan/git/urlscan/urlchoose.py", line 204, in draw_screen
    self.ui.draw_screen(size, canvas)
  File "/usr/lib/python2.7/dist-packages/urwid/curses_display.py", line 504, in draw_screen
    assert self._started
AssertionError

@ghost
Copy link
Author

ghost commented Dec 4, 2014

Test 4 - Debian unstable - python 3.x

Details:

python3   3.4.2-1 
python3-urwid   1.2.1-2+b1

Same as test 1 and 3, Exception when I quit:

Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python3.4/threading.py", line 920, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.4/threading.py", line 868, in run
    self._target(*self._args, **self._kwargs)
  File "/home/xakz/devel/debian/packages/urlscan/git/urlscan/urlchoose.py", line 200, in _loading_thread
    self.draw_screen(size)
  File "/home/xakz/devel/debian/packages/urlscan/git/urlscan/urlchoose.py", line 204, in draw_screen
    self.ui.draw_screen(size, canvas)
  File "/usr/lib/python3/dist-packages/urwid/curses_display.py", line 505, in draw_screen
    assert self._started
AssertionError

@ghost
Copy link
Author

ghost commented Dec 4, 2014

For Ubuntu, the test with python 2.x is exactly the same as test 3. And with python 3.x, its the same as test 4.

Versions in ubuntu:

python 2.7.8-1
python-urwid 1.2.1-2
python3 3.4.2-1
python3-urwid 1.2.1-2

urwid version come directly from debian source package (ubuntu universe)

@ghost
Copy link
Author

ghost commented Dec 4, 2014

Also, I noted that if I do not open any link with urlscan, it do not crash and ends normally.

@firecat53
Copy link
Owner

Ok, I found two problems -- 1 fixable, 1 not.

  1. Using python3.x with any urwid version < 1.2.1 doesn't work. That gives the 'TypeError: unorderable types: int() > str()'. Python2.x works with any version of urwid.
  2. The AssertionError is happening when urlscan is trying to exit but the thread loop (that sleeps 5s before clearing the 'loading url' footer) is still running. Waiting until after that bar clears before quitting prevents the error. Let me see if I can fix that.

@firecat53 firecat53 reopened this Dec 5, 2014
@firecat53
Copy link
Owner

Fixed the AssertionError with bdda3a2
Added a note to the README and updated requirements.txt for minimum version of urwid required for Python 3.x with b7a7127

@ghost
Copy link
Author

ghost commented Dec 5, 2014

Perfect.

I will fill a bug report against python3-urwid on the Debian BTS for python3 + urwid < 1.2.1

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant