Nic0 / tyrs

Twitter and Identica client using curses
http://tyrs.nicosphere.net
61 stars 10 forks source link

tyrs crashed by pressing 'i' #117

Open jeff84 opened 12 years ago

jeff84 commented 12 years ago

When I press the key 'i', tyrs will crash with:

Traceback (most recent call last): File "/usr/bin/tyrs", line 16, in main() File "/usr/lib/python2.7/site-packages/tyrs/tyrs.py", line 66, in main init_tyrs() File "/usr/lib/python2.7/site-packages/tyrs/tyrs.py", line 71, in init_tyrs init_interface() File "/usr/lib/python2.7/site-packages/tyrs/tyrs.py", line 88, in init_interface user_interface = Interface() File "/usr/lib/python2.7/site-packages/tyrs/interface.py", line 49, in init self.main_loop() File "/usr/lib/python2.7/site-packages/tyrs/interface.py", line 62, in main_loop self.loop.run() File "/usr/lib/python2.7/site-packages/urwid/main_loop.py", line 274, in run self.screen.run_wrapper(self._run) File "/usr/lib/python2.7/site-packages/urwid/raw_display.py", line 237, in run_wrapper return fn() File "/usr/lib/python2.7/site-packages/urwid/main_loop.py", line 307, in _run self.event_loop.run() File "/usr/lib/python2.7/site-packages/urwid/main_loop.py", line 682, in run self._loop() File "/usr/lib/python2.7/site-packages/urwid/main_loop.py", line 720, in _loop self._watch_files[fd]() File "/usr/lib/python2.7/site-packages/urwid/main_loop.py", line 358, in _update self.process_input(keys) File "/usr/lib/python2.7/site-packages/urwid/main_loop.py", line 453, in process_input something_handled |= bool(self.unhandled_input(k)) File "/usr/lib/python2.7/site-packages/urwid/main_loop.py", line 488, in unhandled_input return self._unhandled_input(input) File "/usr/lib/python2.7/site-packages/tyrs/keys.py", line 129, in keystroke self.interface.current_user_info() File "/usr/lib/python2.7/site-packages/tyrs/interface.py", line 190, in current_user_info User(self.current_status().user) File "/usr/lib/python2.7/site-packages/tyrs/user.py", line 26, in init self._init_screen() File "/usr/lib/python2.7/site-packages/tyrs/user.py", line 34, in _init_screen maxyx = self.interface.screen.getmaxyx() AttributeError: 'Interface' object has no attribute 'screen'

alferpal commented 12 years ago

Same behavior with both 0.6.2 and the latest git

ghost commented 12 years ago

I have the same problem with the latest git. Here is the stack trace:

Traceback (most recent call last)
  File "/usr/bin/tyrs", line 16, in <module>                                               
    main()
  File "/usr/lib/python2.7/site-packages/tyrs/tyrs.py", line 66, in main
    init_tyrs()
  File "/usr/lib/python2.7/site-packages/tyrs/tyrs.py", line 71, in init_tyrs
    init_interface()
  File "/usr/lib/python2.7/site-packages/tyrs/tyrs.py", line 88, in init_interface
    user_interface = Interface()
  File "/usr/lib/python2.7/site-packages/tyrs/interface.py", line 49, in __init__
    self.main_loop()
  File "/usr/lib/python2.7/site-packages/tyrs/interface.py", line 62, in main_loop
    self.loop.run()
  File "/usr/lib/python2.7/site-packages/urwid/main_loop.py", line 274, in run
    self.screen.run_wrapper(self._run)
  File "/usr/lib/python2.7/site-packages/urwid/raw_display.py", line 237, in run_wrapper
    return fn()
  File "/usr/lib/python2.7/site-packages/urwid/main_loop.py", line 307, in _run
    self.event_loop.run()
  File "/usr/lib/python2.7/site-packages/urwid/main_loop.py", line 682, in run
    self._loop()
  File "/usr/lib/python2.7/site-packages/urwid/main_loop.py", line 720, in _loop
    self._watch_files[fd]()
  File "/usr/lib/python2.7/site-packages/urwid/main_loop.py", line 358, in _update
    self.process_input(keys)
  File "/usr/lib/python2.7/site-packages/urwid/main_loop.py", line 453, in process_input
    something_handled |= bool(self.unhandled_input(k))
  File "/usr/lib/python2.7/site-packages/urwid/main_loop.py", line 488, in unhandled_input
    return self._unhandled_input(input)
  File "/usr/lib/python2.7/site-packages/tyrs/keys.py", line 129, in keystroke
    self.interface.current_user_info()
  File "/usr/lib/python2.7/site-packages/tyrs/interface.py", line 190, in current_user_info
    User(self.current_status().user)
  File "/usr/lib/python2.7/site-packages/tyrs/user.py", line 26, in __init__
    self._init_screen()
  File "/usr/lib/python2.7/site-packages/tyrs/user.py", line 34, in _init_screen
    maxyx = self.interface.screen.getmaxyx()
AttributeError: 'Interface' object has no attribute 'screen'
ghost commented 12 years ago

It seems like pressing i is associated with displaying user's info.

When you press that key a instance of User from interface.py is created. Apparently the goal of the creation of that object is to show a subwindow with the user's information. Here is some of the initialization code for that object:

def _init_screen(self):
    maxyx = self.interface.screen.getmaxyx()
    self.screen = self.interface.screen.subwin(30, 80, 3, 10)
    self.screen.border(0)
    self.screen.refresh()

It's trying to acces to an inexistent attribute of interface and the whole class assumes that it has the screenproperty.

I have noticed that there is no key binding for showing user's info in the help page, and this is the problematic bit of code in keys.py that catches the pressing of i key:

...
# User info
            elif ch == 'i':
                self.interface.current_user_info()
...

I hope @Nic0 can give us some clues on how the implementation of the subwindow with user's information is supposed to be.

Nic0 commented 12 years ago

Thank's to notify this problem. (related issue #120 )

This was some code I've done for the older interface, when it was only some ncurses module interface, and not even finished. When a switch for urwid module, I didn't migrate this part, as it was undocumented (or what I througt).

The idea would be to adapt this code to urwid, with some pop-up window, or even with something like the help interface. My guess is that something like the help screen would be faster/easier to implement. Data are easy to retrieve, and only some urwid interface that need to be done.

I'm really sorry that I don't time that I should to fix all this now, but I'll try to find some time.