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

Adding linefeed in interactive edit not working. #48

Closed
xircon opened this issue Nov 28, 2020 · 16 comments
Closed

Adding linefeed in interactive edit not working. #48

xircon opened this issue Nov 28, 2020 · 16 comments
Assignees

Comments

@xircon
Copy link

xircon commented Nov 28, 2020

Using micro editor, I set up a phrase:

qk -n 'updg'

Enter the phrase, press enter:

image

Phrase after expansion:

image

Also qk daemon seems to not work after an interactive edit and I have to restart:

qk stop && qk start

Then all is good.

If I manually edit the json and add '\n' it works.

@bostrt
Copy link
Owner

bostrt commented Nov 28, 2020 via email

@xircon
Copy link
Author

xircon commented Nov 28, 2020

Thanks.

@bostrt bostrt self-assigned this Nov 28, 2020
@bostrt
Copy link
Owner

bostrt commented Nov 28, 2020

I'm reworking the edit screen a bit to address the issue you found with newlines.

Regarding the quikey-daemon failure, here's the stacktrace when editing a phrase as you stated. I'll address this as well.

$ quikey-daemon start -f
/home/rbost/.cache/quikey/quikey.pid
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib64/python3.7/threading.py", line 926, in _bootstrap_inner
    self.run()
  File "/home/rbost/.local/lib/python3.7/site-packages/quikey/filewatch.py", line 24, in run
    observer.notify()
  File "/home/rbost/.local/lib/python3.7/site-packages/quikey/qkdaemon.py", line 31, in notify
    self.init_phrase_handlers()
  File "/home/rbost/.local/lib/python3.7/site-packages/quikey/qkdaemon.py", line 25, in init_phrase_handlers
    phrases = self.db.all()
  File "/home/rbost/.local/lib/python3.7/site-packages/quikey/models.py", line 33, in all
    return self.db.all()
  File "/home/rbost/.local/lib/python3.7/site-packages/tinydb/database.py", line 426, in all
    return list(itervalues(self._read()))
  File "/home/rbost/.local/lib/python3.7/site-packages/tinydb/database.py", line 399, in _read
    return self._storage.read()
  File "/home/rbost/.local/lib/python3.7/site-packages/tinydb/database.py", line 90, in read
    raw_data = self._storage.read() or {}
  File "/home/rbost/.local/lib/python3.7/site-packages/tinydb/storages.py", line 108, in read
    return json.load(self._handle)
  File "/usr/lib64/python3.7/json/__init__.py", line 296, in load
    parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
  File "/usr/lib64/python3.7/json/__init__.py", line 348, in loads
    return _default_decoder.decode(s)
  File "/usr/lib64/python3.7/json/decoder.py", line 340, in decode
    raise JSONDecodeError("Extra data", s, end)
json.decoder.JSONDecodeError: Extra data: line 1 column 9318 (char 9317)

@bostrt
Copy link
Owner

bostrt commented Nov 29, 2020

The quikey-daemon issue has been a troubleshooting challenge, but using inotify CLI tools, I see the phrase database is invalid for a very short period of time. I'll have to dig into why this is the case next.

$ inotifywait -e modify $WATCHFILE && cat $WATCHFILE
Setting up watches.
Watches established.
/home/rbost/.local/share/quikey/phrases.json MODIFY 
{"_default": {"1": {"key": ":test:", "value": "testing", "tags": [], "updated": "2020-11-29T02:27:35.160585"}}}}}

Note the extra } at the end

@xircon
Copy link
Author

xircon commented Nov 29, 2020

May be a lack of coffee, but I can see 2 extra closing braces?

@bostrt
Copy link
Owner

bostrt commented Nov 29, 2020 via email

@bostrt
Copy link
Owner

bostrt commented Nov 29, 2020

Looks like its due to tinydb not supporting multi-threading/processing. Fortunately, quikey edits do not require high performance so I can introduce a file lock to address this. I'll start work on this soon and have a goal to get a new release out this week.

Reference:
msiemens/tinydb#215

@xircon
Copy link
Author

xircon commented Nov 29, 2020

Anything I can do, let me know.

@xircon
Copy link
Author

xircon commented Nov 29, 2020

Quick test, all seems to be working, needs python-filelock adding to the aur package's depends.

@bostrt
Copy link
Owner

bostrt commented Nov 29, 2020 via email

@SanskritFritz
Copy link

I don't have python-filelock installed on my archlinux, but qk seems to work well here. Why is that dependency needed?

Don't get me wrong, I'm willing to add it, just want to clarify this.

@SanskritFritz
Copy link

Ah, OK, it's a new dependency, now I see. So it will be included in the next release, however, the -git package will be updated soon.

@bostrt
Copy link
Owner

bostrt commented Nov 29, 2020 via email

@bostrt
Copy link
Owner

bostrt commented Nov 29, 2020 via email

@xircon
Copy link
Author

xircon commented Nov 29, 2020

Thank you both!

@SanskritFritz
Copy link

OK, AUR packages updated, thanks guys. This stuff is getting better and better.

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

3 participants