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

bluez5: Fix AttributeError when registering an agent twice #209

Merged
merged 1 commit into from
Jul 3, 2024

Conversation

fkleon
Copy link
Contributor

@fkleon fkleon commented Jul 3, 2024

While I'm in there..

I noticed during some further testing that when starting bluetoothctl multiple times, with the bluez5 mock active, an AttributeError is raised instead of the expected org.bluez.Error.AlreadyExists:

$ systemctl mask bluetooth
$ systemctl stop bluetooth
$ python3 -m dbusmock --system -t bluez5 -e $SHELL

$ bluetoothctl
Waiting to connect to bluetoothd...
1720009617.228 RegisterAgent "/org/bluez/agent" ""
[SIGNAL] org.freedesktop.DBus.Mock.MethodCalled
[bluetooth]# Agent registered
[bluetooth]# quit

$ bluetoothctl
Waiting to connect to bluetoothd...
1720009619.963 RegisterAgent "/org/bluez/agent" ""
1720009619.963 RegisterAgent raised: 'DBusMockObject' object has no attribute 'agent_path'
[SIGNAL] org.freedesktop.DBus.Mock.MethodCalled
[bluetooth]# Failed to register agent: org.freedesktop.DBus.Python.AttributeError
[bluetooth]# quit

Actually, against the real bluez5 implementation, the agent would be automatically unregistered when the bluetoothctl client disconnects from DBus.. but that's a limitation of this mock/template.

@fkleon
Copy link
Contributor Author

fkleon commented Jul 3, 2024

On centos9:

AssertionError: 'Agent registered' not found in ['Waiting to connect to bluetoothd...', 'org.freedesktop.DBus.Mock.MethodCalled', 'registered']

Not sure why this prints just registered instead of Agent registered on the old version. Based on the BlueZ source code it should be the same output.. 🤔

I guess I'll make this assertion conditional on the BlueZ version too..

Copy link
Owner

@martinpitt martinpitt left a comment

Choose a reason for hiding this comment

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

Thanks @fkleon! Now that you have a commit in main the tests start automatically for you, nice 🎉

@martinpitt martinpitt merged commit 2004c98 into martinpitt:main Jul 3, 2024
16 checks passed
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

Successfully merging this pull request may close these issues.

2 participants