cs_thunderbolt.py: re-work module initialization, code cleanup#13691
Open
timfeierabend wants to merge 4 commits intolinuxmint:masterfrom
Open
cs_thunderbolt.py: re-work module initialization, code cleanup#13691timfeierabend wants to merge 4 commits intolinuxmint:masterfrom
timfeierabend wants to merge 4 commits intolinuxmint:masterfrom
Conversation
re-worked settings module init to simplify the startup checks. the main goal is to use d-bus for all checks. the current solution performs 3 checks: 1) Checks for whether bolt is installed by checking if `boltctl` exists on the file system. 2) Checks for whether the system has thunderbolt by querying sysfs. 3) Checks if the bolt daemon is alive. This new implementation performs 2 checks: 1) Checks if `org.freedesktop.bolt` is in the D-Bus activitable list. if bolt is installed, it will appear in this list. This replaces check number 1 above. Since the whole settings module runs off d-bus, this is a more accurate check. 2) If bolt is available, we initialize the Manager proxy, and get the list of domains. Per the documentation, there will be 1 domain/device pair with the same uuid per thunderbolt controller in the system. This replaces check number 2 above. `boltd` knows how to examine sysfs, no need to re-invent the wheel, lets just ask it if it sees thunderbolt support on the system. The check for number 3 is removed because if `org.freedesktop.bolt` isn't running, it will automatically start when we start interacting with it. systems that do have thunderbolt, but don't have any devices connected via thunderbolt, won't automatically start the service until a device connects.
Use the `get_cached_property()` feature of DBusProxy object instead of re-inventing the wheel with the props object and setattr. Renamed DBusProxy to DBusObject since it is a wrapper class around a Gio.DBusProxy. Renamed BoltManagerProxy to BoltManager and BoltDeviceProxy to BoltDevice since they are convienence wrapper classes. Removed DBusProps empty class. Added DBusProperty descriptor class. This class is designed for use with the DBusObject class for easy access to properties. It is used to expose the various properties needed from the BoltDevice class. Changed host device check to call `org.freedesktop.DBus.Properties.Get()` method to get the device type, prevent un-necessary creation of a BoltDevice object. Renamed all properties and methods in the BoltManager and BoltDevice classes to match the DBus naming convention.
os module no longer needed due to refactoring of module initialization
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Re-worked settings module initialization to simplify the startup checks. The main goal is to use D-Bus for all checks. The current solution performs 3 checks:
boltctlexists on the file system.This new implementation performs 2 checks:
org.freedesktop.boltis in the D-Bus activitable list. If it is installed and activatable, it will appear in this list. This replaces check number 1 above. Since this settings module uses D-Bus for all functionality, this is a more accurate check.boltdknows how to examine sysfs, no need to re-invent the wheel, lets just ask it if it sees thunderbolt support on the system.The check for number 3 is removed because if
org.freedesktop.boltisn't running, it will automatically start when we start interacting with it. Systems that do have thunderbolt, but don't have any devices connected via thunderbolt, won't automatically start the service until a device connects.The wrapper classes around the DBus proxy objects were re-factored to make use of
get_cached_property()feature of Gio.DBusProxy objects. No need to re-invent the wheel and manage a property cache when the proxy already does this. The "Proxy" part of their names were removed.