feat(cli): Add get_properties helper function for DBus interactions
This function facilitates retrieving specific properties from a DBus interface, improving code modularity and reusability. It supports both system and session bus types, streamlining access to DBus resources.
This commit is contained in:
@@ -17,6 +17,18 @@ class BusType(Enum):
|
||||
SYSTEM = "system"
|
||||
|
||||
|
||||
def get_properties(
|
||||
property_name: str,
|
||||
interface: str,
|
||||
object_path=REVPI_DBUS_BASE_PATH,
|
||||
bus_type=BusType.SYSTEM,
|
||||
):
|
||||
bus = SessionBus() if bus_type is BusType.SESSION else SystemBus()
|
||||
revpi = bus.get(REVPI_DBUS_NAME, object_path)
|
||||
iface = revpi[interface]
|
||||
return getattr(iface, property_name)
|
||||
|
||||
|
||||
def simple_call(
|
||||
method: str,
|
||||
*args,
|
||||
|
||||
Reference in New Issue
Block a user