insanum / sncli

Simplenote CLI
MIT License
397 stars 35 forks source link

Recreate Pipfile.lock #118

Closed samuelallan72 closed 2 years ago

samuelallan72 commented 3 years ago

Dependabot has been complaining for a while, and we haven't updated this in a long time.

Will need to test to check everything still works.

samuelallan72 commented 3 years ago

@pataquets @lostways , as recent committers, would you like to test this out? :)

pataquets commented 3 years ago

After replacing my local Docker image by building from this branch:

docker-build --build-arg editor_packages="bat less nano" github.com/insanum/sncli#bump-deps -t sncli:bump-deps

Just accessing my first, pinned note, saving from editor and exiting, crashes immediately (although note is saved):

AssertionError
    self.gui_update_status_bar()
  File "/sncli/simplenote_cli/sncli.py", line 319, in gui_update_status_bar
    self.gui_header_set(self.gui_body_get().get_status_bar())
  File "/sncli/simplenote_cli/sncli.py", line 187, in gui_header_set
    self.sncli_loop.draw_screen()
  File "/root/.local/share/virtualenvs/sncli-y5kkZ0DZ/lib/python3.9/site-packages/urwid/main_loop.py", line 588, in draw_screen
    canvas = self._topmost_widget.render(self.screen_size, focus=True)
  File "/root/.local/share/virtualenvs/sncli-y5kkZ0DZ/lib/python3.9/site-packages/urwid/widget.py", line 145, in cached_render
    canv = fn(self, size, focus=focus)
  File "/root/.local/share/virtualenvs/sncli-y5kkZ0DZ/lib/python3.9/site-packages/urwid/container.py", line 1089, in render
    body = self.body.render((maxcol, maxrow-ftrim-htrim),
  File "/root/.local/share/virtualenvs/sncli-y5kkZ0DZ/lib/python3.9/site-packages/urwid/widget.py", line 145, in cached_render
    canv = fn(self, size, focus=focus)
  File "/root/.local/share/virtualenvs/sncli-y5kkZ0DZ/lib/python3.9/site-packages/urwid/listbox.py", line 439, in render
    middle, top, bottom = self.calculate_visible(
  File "/root/.local/share/virtualenvs/sncli-y5kkZ0DZ/lib/python3.9/site-packages/urwid/listbox.py", line 389, in calculate_visible
    n_rows = next.rows( (maxcol,) )
  File "/root/.local/share/virtualenvs/sncli-y5kkZ0DZ/lib/python3.9/site-packages/urwid/widget.py", line 205, in cached_rows
    return fn(self, size, focus)
  File "/root/.local/share/virtualenvs/sncli-y5kkZ0DZ/lib/python3.9/site-packages/urwid/container.py", line 2282, in rows
    widths = self.column_widths(size, focus)
  File "/root/.local/share/virtualenvs/sncli-y5kkZ0DZ/lib/python3.9/site-packages/urwid/container.py", line 2061, in column_widths
    static_w = w.pack((maxcol,), focus and i == self.focus_position)[0]
  File "/root/.local/share/virtualenvs/sncli-y5kkZ0DZ/lib/python3.9/site-packages/urwid/widget.py", line 1069, in pack
    trans = self.get_line_translation( maxcol, (text,attr))
  File "/root/.local/share/virtualenvs/sncli-y5kkZ0DZ/lib/python3.9/site-packages/urwid/widget.py", line 1035, in get_line_translation
    return self._cache_translation
AttributeError: 'Text' object has no attribute '_cache_translation'

Output is incomplete, since previous lines appear mixed with my own notes in the terminal and I can't copy them without a significant cleanup effort. Hope it's helpful enough.

Doesn't happen if built from master branch.

samuelallan72 commented 3 years ago

@pataquets oh nice catch! :+1: Looks like we'll need to pin urwid, or update to support a newer version. By the way, do you think we should just drop pipenv support? I'm not sure what the current recommendations are these days, or who is using it (apart from the dockerfile).

pataquets commented 3 years ago

@swalladge : I'm not aware of any Docker {Python,pip,pipenv}-specific best practices, other than the general do-not-cache files. Also, I can't recommend due my limited Python knowledge, sorry. Just the general Docker practice: "whatever works best for your project".

samuelallan72 commented 3 years ago

@pataquets hmm I can't reproduce the issue. Could you share your snclirc?

pataquets commented 3 years ago

Sure! Notice that there's no auth info, I'm passing it via env vars.

[sncli]
cfg_editor=nano
cfg_pager=/usr/bin/batcat --number --paging=always --language=orgmode

kb_edit_note = space
kb_down = down
kb_up = up
kb_page_down = pgdn
kb_page_up = pgup

Also, since you suggest urwid as the possible culprit, I'm guessing that some environment var specific to my system might be needed to reproduce it. I run the Docker image passing the following host environment variables: TERM=screen-256color, COLUMNS, LINES (values depending on window size).

Notice, though, I could not reproduce the error again myself :thinking:

lostways commented 3 years ago

Works great for me. I'm not using docker, but tried with pipenv directly....

➜ sncli-fork git:(bump-deps) pipenv install --dev

Installing dependencies from Pipfile.lock (e4a7b1)… 🎃 ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 38/38 — 00:00:27
To activate this project's virtualenv, run the following: $ pipenv shell
➜ sncli-fork git:(bump-deps) pipenv shell
Spawning environment shell (/usr/bin/zsh). Use 'exit' to leave. . /home/ubuntu/.local/share/virtualenvs/sncli-fork-_bhrWyJs/bin/activate
➜ sncli-fork git:(bump-deps) . /home/ubuntu/.local/share/virtualenvs/sncli-fork-_bhrWyJs/bin/activate

(sncli-fork-_bhrWyJs) ➜ sncli-fork git:(bump-deps) ./sncli --help

Usage:
sncli [OPTIONS] [COMMAND] [COMMAND_ARGS]
OPTIONS:
-h, --help - usage help
-v, --verbose - verbose output

.......

I also tested editing and creating a note via the gui.

samuelallan72 commented 3 years ago

@pataquets @lostways thanks for sharing! I'm a little hesitant to merge the updates, since that first crash. The traceback looks rather like a regression in urwid itself (originating in drawing the widgets). Or maybe a Text node that isn't properly inited?

AttributeError: 'Text' object has no attribute '_cache_translation'

Maybe the bug is triggered by i18n config? What language is your system using @pataquets ?

pataquets commented 2 years ago

@swalladge: I've done a bit more diagnosing following your question. Although I've not found the exact cause of the crash (which I can't reliably reproduce always), my guess is that it might be something locale-related, indeed. My lang-related environment vars.

LANG=ca_ES.UTF-8
LANGUAGE=ca:ca@valencia:es:en
LC_ADDRESS=ca_ES.UTF-8
LC_IDENTIFICATION=ca_ES.UTF-8
LC_MEASUREMENT=ca_ES.UTF-8
LC_MONETARY=ca_ES.UTF-8
LC_NAME=ca_ES.UTF-8
LC_NUMERIC=ca_ES.UTF-8
LC_PAPER=ca_ES.UTF-8
LC_TELEPHONE=ca_ES.UTF-8
LC_TIME=ca_ES.UTF-8

I've also discovered that the Docker image has faulty support for non-English locales (eg. accented chars) and I'm working in a Dockerfile fix to allow baking some specific locale at container build time via an ARG parameter, defaulting to en_US.UTF-8 to keep current behavior. As soon as the PR is done and merged, if you rebase this PR to the latest HEAD, I want to put this PR's image to normal use again and test.

As far as my error report concerns, I think it can be dismissed due to missing locale inside my Docker image, if someone with non-EN_US locale can confirm it's working (/cc @lostways). I can't dismiss that based on my evidence alone. So far, I've got some crashes when saving a note with accented chars.

pataquets commented 2 years ago

@swalladge: now that #125 is in, mind you rebasing this on latest HEAD as discussed above?

samuelallan72 commented 2 years ago

@pataquets ah yes, good idea. I haven't had much time to look at sncli lately though, and not sure when I can get to it. Feel free to have a go and open a PR if you like - I would say after all this time the deps will need to be updated and retested from scratch, rather than a simple rebase.