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

[plugin.program.bluetoothctl] 1.0.1 #3912

Open
wants to merge 1 commit into
base: matrix
Choose a base branch
from

Conversation

JimMadge
Copy link

@JimMadge JimMadge commented Mar 6, 2022

Description

Interact with Bluetooth devices in Kodi using the Linux Bluetooth stack.

Checklist:

  • My code follows the add-on rules and piracy stance of this project.
  • I have read the CONTRIBUTING document
  • Each add-on submission should be a single commit with using the following style: [plugin.video.foo] v1.0.0

@lrusak
Copy link

lrusak commented Mar 6, 2022

Why not just use the bluez dbus API instead of calling a binary using subprocess?

For an example see how LibreELEC does it. https://github.com/LibreELEC/service.libreelec.settings/blob/master/resources/lib/dbus_bluez.py

@JimMadge
Copy link
Author

JimMadge commented Mar 7, 2022

I'm not familiar with D-Bus.

I didn't notice bluez had a D-Bus API. It looks like a better long-term solution, although it would mean adding Python D-Bus bindings as a dependency.

@@ -0,0 +1,386 @@
from functools import wraps
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not good form to have the entire program logic loaded by the file called from the addon.xml (in this case addon.py). That file in never cached, so there is a significant performance hit. Instead, import from a different file and just call it from addon.py.

@@ -0,0 +1,155 @@
from __future__ import annotations
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the empty init.py file is not needed with Python3 and should be removed. This also applies for the ones in the resources and lib folders.

from __future__ import annotations
from typing import Any
import subprocess
from subprocess import CompletedProcess
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just noting this from the other comment. Rather than using subprocess and call a binary, you should use the dbus API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants