def list_units(self): """List all units, inactive units too. @raise SystemdError: Raised when dbus error or index error is raised. @rtype: A tuple of L{systemd.unit.Unit} """ try: units = [] for unit in self.__interface.ListUnits(): units.append(Unit(unit[6])) return tuple(units) except dbus.exceptions.DBusException, error: raise SystemdError(error)
def load_unit(self, name): """Load unit by it name. @param name: Unit name (ie: network.service). @raise SystemdError: Raised when no unit is found with the given name. @rtype: L{systemd.unit.Unit} """ try: unit_path = self.__interface.LoadUnit(name) unit = Unit(unit_path) return unit except dbus.exceptions.DBusException, error: raise SystemdError(error)
def get_unit_by_pid(self, pid): """Get unit by it PID. @param PID: Unit PID. @raise SystemdError: Raised when no unit with that PID is found. @rtype: systemd.unit.Unit """ try: unit_path = self.__interface.GetUnitByPID(pid) unit = Unit(unit_path) return unit except dbus.exceptions.DBusException, error: raise SystemdError(error)