openstenoproject/plover

`AttributeError` when changing protocol or pressing reconnect button

triallax opened this issue · 2 comments

Describe the bug

Whenever I press on the button labeled "Disconnect and reconnect the machine," or change the protocol (e.g. from "Gemini PR" to "Keyboard"), Plover notifies me that there was an error and prints a stack trace:

2023-10-02 18:40:58,312 [Dummy-1] ERROR: engine update failed
Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/plover/engine.py", line 147, in run
    if func(*args, **kwargs):
       ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/plover/engine.py", line 214, in _update
    self._keyboard_emulation.set_key_press_delay(config['time_between_key_presses'])
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'KeyboardEmulation' object has no attribute 'set_key_press_delay'

This happens regardless of whether my Uni is connected.

To Reproduce

Steps to reproduce the behavior:

  1. Switch protocol, or press on reconnect button
  2. See error

Expected behavior

No errors happen.

Operating system

  • OS: [e.g. Windows 10, Ubuntu 20.04, macOS Catalina] Void Linux
  • Plover Version [e.g. 3.x, 4.x, weekly] 4.0.0rc2

It's worth noting that this issue doesn't happen on 4.0.0rc1 or earlier versions.

Hardware

Not appliacable probably, but it's a Uni 4 connected via Gemini PR. Here's the machine configuration:

Picture of my machine configuration in Plover

Looking at the code, I have no idea why this error may happen other than some weird incompatible installation of sub-packages.

Maybe try completely uninstall Plover (make sure import plover in Python errors out) and reinstall, see if the error persist.

If it still persist, try running those.

$ python

Python 3.11.5 (main, Sep  2 2023, 14:16:33) [GCC 13.2.1 20230801] on linux
Type "help", "copyright", "credits" or "license" for more information.

>>> from plover.oslayer.keyboardcontrol import KeyboardEmulation

>>> KeyboardEmulation()
<plover.oslayer.keyboardcontrol_x11.KeyboardEmulation object at 0x7f4e1c978250>

>>> KeyboardEmulation().set_key_press_delay(1)
⟨no error happen⟩

>>> from plover.oslayer import keyboardcontrol

>>> keyboardcontrol.__file__
'/.../plover/oslayer/linux/keyboardcontrol.py'

If the error disappear, it may still be the case that some method of Plover upgrade does not completely upgrade it, in that case we need detailed reproduction instruction (note that if you install from source you need ./setup.py build etc.)

I ended up narrowing down the issue to plover-wtype-output, as the error disappears when I start Plover with it disabled. I'll see if I can fix it or at least report it to the plugin author.