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

python: catch more DBus exceptions #13

Merged
merged 2 commits into from Mar 30, 2017

Conversation

Projects
None yet
2 participants
@Hjdskes
Copy link
Member

Hjdskes commented Mar 29, 2017

Gio.bus_get_sync may return None when the DBus service is not available (see libratbag/piper#2). In addition to this, the service may time out when it is being started in which case Gio.DBusProxy.new_sync will raise a GLib.Gerror.

This commit checks for both scenarios and raises a RatbagdDBusUnavailable
exception when either one of them occurs. This will in turn be caught in for
example Piper to properly deal with this. This fixes libratbag/piper#2.

@whot I hope this is acceptable as my mandatory GSoC contribution to Piper!

@whot
Copy link
Member

whot left a comment

just a tiny change, I wish I could do these things directly in the interface here...

Thanks for the patch though, please force-push and ping me in a comment on the PR so I can merge it asap

object_path,
'org.freedesktop.ratbag1.{}'.format(interface),
None)
if self._dbus == None:

This comment has been minimized.

@whot

whot Mar 30, 2017

Member

I learned this the hard way: "if foo == None" is not correct, we should use "if foo is None". Forgot what the exact difference is (Google remembers :) but it matters enough to be annoying.

This comment has been minimized.

@Hjdskes

Hjdskes Mar 30, 2017

Author Member

Right, is checks for address equivalence and == checks for value equivalence.

Hjdskes added some commits Mar 29, 2017

python: catch more DBus exceptions
Gio.bus_get_sync may return None when the DBus service is not available (see
libratbag/piper#2). In addition to this, the service may time out when it is
being started in which case Gio.DBusProxy.new_sync will raise a GLib.Gerror.

This commit checks for both scenarios and raises a RatbagdDBusUnavailable
exception when either one of them occurs. This will in turn be caught in for
example Piper to properly deal with this.
python: replace == None with is None
== checks for value equivalence, but in this case what we
really want is address equivalence. Hence we use is.
@Hjdskes

This comment has been minimized.

Copy link
Member Author

Hjdskes commented Mar 30, 2017

@whot Ping! I also replaced another == None instance in a separate commit. I can squash those if you prefer, but you can also do this from the GitHub interface when you merge the PR.

@whot

whot approved these changes Mar 30, 2017

@whot whot merged commit 617cd62 into libratbag:master Mar 30, 2017

@Hjdskes Hjdskes deleted the Hjdskes:catch-dbus branch May 17, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.