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

plyer.vibrator.exists() throws NotImplementedError on Linux, should return False? #727

Open
fovea1959 opened this issue Nov 13, 2022 · 1 comment

Comments

@fovea1959
Copy link

I am writing a Kivy multiplatform app (Android and Linux). I am trying to deal with the possible lack of a vibrator by guarding the call to .vibrate() with an .exists() check.

        if plyer.vibrator.exists():
            plyer.vibrator.vibrate()

plyer.vibrate.exists() currently throws a NotImplementedError on Linux.

 Traceback (most recent call last):
   File "/home/wegscd/.virtualenvs/KivyTest/lib/python3.8/site-packages/plyer/utils.py", line 93, in _ensure_obj
     mod = __import__(module, fromlist='.')
 ModuleNotFoundError: No module named 'plyer.platforms.linux.vibrator'
 Traceback (most recent call last):
   File "/home/wegscd/PycharmProjects/KivyTest/main.py", line 208, in <module>
     TabbedPanelApp().run()
   File "/home/wegscd/.virtualenvs/KivyTest/lib/python3.8/site-packages/kivy/app.py", line 954, in run
     self._run_prepare()
   File "/home/wegscd/.virtualenvs/KivyTest/lib/python3.8/site-packages/kivy/app.py", line 924, in _run_prepare
     root = self.build()
   File "/home/wegscd/PycharmProjects/KivyTest/main.py", line 204, in build
     return MainWidget()
   File "/home/wegscd/PycharmProjects/KivyTest/main.py", line 198, in __init__
     if plyer.vibrator.exists():
   File "/home/wegscd/.virtualenvs/KivyTest/lib/python3.8/site-packages/plyer/facades/vibrator.py", line 77, in exists
     return self._exists()
   File "/home/wegscd/.virtualenvs/KivyTest/lib/python3.8/site-packages/plyer/facades/vibrator.py", line 94, in _exists
     raise NotImplementedError()
 NotImplementedError

I would submit that it should just return False?

I am willing to write the implementation if the team is amenable to accepting it. I just tested this with plyer 2.1.0 and Kivy 2.1.0.

@fovea1959
Copy link
Author

Patch for 2.1.0 is attached; returns False for .exists() instead of raising NotImplementedError(). I don't have a patch for iOS; I don't understand how it's .exists() works.

plyer.vibrator.patch.txt

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

1 participant