Esempio n. 1
0
    def get_unit(self, name):
        """Get unit by it name.

        @param name: Unit name (ie: network.service).

        @raise SystemdError: Raised when no unit is found with the given name.

        @rtype: systemd_dbus.unit.Unit
        """
        unit_path = self.__interface.GetUnit(name)
        unit = Unit(unit_path)
        return unit
Esempio n. 2
0
    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_dbus.unit.Unit
        """
        unit_path = self.__interface.GetUnitByPID(pid)
        unit = Unit(unit_path)
        return unit
Esempio n. 3
0
    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_dbus.unit.Unit}
        """
        units = []
        for unit in self.__interface.ListUnits():
            units.append(Unit(unit[6]))
        return tuple(units)
Esempio n. 4
0
    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_dbus.unit.Unit}
        """
        try:
            unit_path = self.__interface.LoadUnit(name)
            unit = Unit(unit_path)
            return unit
        except dbus.exceptions.DBusException as error:
            raise SystemdError(error)