insanum / sncli

Simplenote CLI
MIT License
396 stars 34 forks source link

crash on first startup when trying to take a note #58

Closed woky closed 6 years ago

woky commented 6 years ago
$ pip3 install sncli
...
$ sncli # then press C to take a new note
sncli database doesn't exist, forcing full sync...
Starting full sync
ERROR: Failed to get note list from server
Full sync completed
Traceback (most recent call last):
  File "/home/user/.local/bin/sncli", line 11, in <module>
    sys.exit(main())
  File "/home/user/.local/lib/python3.5/site-packages/simplenote_cli/sncli.py", line 1343, in main
    sncli(sync, verbose, config).gui(key)
  File "/home/user/.local/lib/python3.5/site-packages/simplenote_cli/sncli.py", line 1046, in gui
    self.sncli_loop.run()
  File "/home/user/.local/lib/python3.5/site-packages/urwid/main_loop.py", line 278, in run
    self._run()
  File "/home/user/.local/lib/python3.5/site-packages/urwid/main_loop.py", line 376, in _run
    self.event_loop.run()
  File "/home/user/.local/lib/python3.5/site-packages/urwid/main_loop.py", line 682, in run
    self._loop()
  File "/home/user/.local/lib/python3.5/site-packages/urwid/main_loop.py", line 719, in _loop
    self._watch_files[fd]()
  File "/home/user/.local/lib/python3.5/site-packages/urwid/raw_display.py", line 393, in <lambda>
    event_loop, callback, self.get_available_raw_input())
  File "/home/user/.local/lib/python3.5/site-packages/urwid/raw_display.py", line 493, in parse_input
    callback(processed, processed_codes)
  File "/home/user/.local/lib/python3.5/site-packages/urwid/main_loop.py", line 403, in _update
    self.process_input(keys)
  File "/home/user/.local/lib/python3.5/site-packages/urwid/main_loop.py", line 503, in process_input
    k = self._topmost_widget.keypress(self.screen_size, k)
  File "/home/user/.local/lib/python3.5/site-packages/simplenote_cli/sncli.py", line 627, in gui_frame_keypress
    content = self.exec_cmd_on_note(None)
  File "/home/user/.local/lib/python3.5/site-packages/simplenote_cli/sncli.py", line 99, in exec_cmd_on_note
    'line': self.gui_body_get().focus_position + 1,
  File "/home/user/.local/lib/python3.5/site-packages/urwid/listbox.py", line 591, in _get_focus_position
    raise IndexError("No focus_position, ListBox is empty")
IndexError: No focus_position, ListBox is empty
samuelallan72 commented 6 years ago

Thanks for reporting. I can reproduce the bug and am looking into fixing it.

By the way, is there a reason why it's failing to get the note list from the server? Did you have an internet connection at the time? I suspect there would be a few places it would crash if it fails in something when creating the database and syncing for the first time. (in fact, it would probably be better if it crashed ealier instead of continuing with a broken db)

woky commented 6 years ago

@swalladge Thanks for the fix. I was just trying it. I haven't set up any server connection so I suspect that was the cause. But the failure still seemed like a bad way to signal it to the user so I reported it.