ceuk/spotui

IndexError Traceback when hitting Enter to exit empty devices popup

taspelund opened this issue · 5 comments

Describe the bug
spotui will exit with a Traceback if you hit enter in the devices popup and there are no active devices.

To Reproduce
Steps to reproduce the behavior:

  1. Ensure there are no active spotify devices
  2. Open spotui
  3. Hit d to open devices popup
  4. Hit Enter

Expected behavior
I would expect the empty box to close without attempting to make a selection if there are no devices to choose from, i.e. it should behave like hitting Escape when there aren't active devices.

Desktop:

➜  ~ uname -a
Linux backlog 4.9.0-6-amd64 #1 SMP Debian 4.9.88-1+deb9u1 (2018-05-07) x86_64 GNU/Linux
➜  ~ cat /etc/os-release 
PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
NAME="Debian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
VERSION_CODENAME=stretch
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

Additional context
Hit enter after this point:
Screenshot_2020-01-10_10-21-00

Traceback:

➜  ~ spotui
Traceback (most recent call last):
  File "/home/trey/.local/bin/spotui", line 11, in <module>
    sys.exit(main())
  File "/home/trey/.local/lib/python3.5/site-packages/spotui/__main__.py", line 6, in main
    SpoTUI = curses.wrapper(App)
  File "/usr/lib/python3.5/curses/__init__.py", line 94, in wrapper
    return func(stdscr, *args, **kwds)
  File "/home/trey/.local/lib/python3.5/site-packages/spotui/src/ui.py", line 8, in __init__
    self.main_form = MainForm(stdscr)
  File "/home/trey/.local/lib/python3.5/site-packages/spotui/src/MainForm.py", line 88, in __init__
    self.popup.receive_input(key)
  File "/home/trey/.local/lib/python3.5/site-packages/spotui/src/DeviceMenu.py", line 49, in receive_input
    self.items[self.component.selected]["handler"]()
IndexError: list index out of range
ceuk commented

Fixed in 0.1.7

I pulled down 0.1.7 and now I'm not seeing any options in the devices box. If I open up the native spotify client I see both the client and spotifyd:

➜  ~ pip3 show spotui
Name: spotui
Version: 0.1.7
Summary: Spotify TUI
Home-page: https://github.com/ceuk/spotui
Author: ceuk
Author-email: None
License: MIT
Location: /home/trey/.local/lib/python3.5/site-packages
Requires: spotipy

Screenshot_2020-01-17_01-16-32

Additionally, hitting empty with the empty devices box doesn't close the popup. I'm not sure if this is unintentional or if the user is supposed to hit Escape to close the window.

ceuk commented

Hey @taspelund - I think I was able to recreate this. However, for me, it appeared after about 5-10 seconds. (had to close and re-open the devices menu). Does waiting for a while with the app open work for you?

@ceuk so far I've not seen the devices box populate after about 10-15 minutes. I've tried opening/closing that menu, as well as adding/playing music from a new device and neither seem to make a difference.

Perhaps there's a timing issue/race condition where the device API call isn't made initially?
I skimmed over the code and at first glance it didn't look like the devices API call is made each time d is pressed, so maybe the code path where the API call is made isn't getting hit.

I'm just surmising, but am happy to try debug versions or more tshooting steps if you'd like.

ceuk commented

@taspelund you were exactly right, I'm stupid. It should be fixed in 0.1.9. It will now refresh devices every time you open the menu. Cheers for the help