systemd.exceptions.SystemdError

Here are the examples of the python api systemd.exceptions.SystemdError taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

42 Examples 7

Example 1

Project: python-systemd
Source File: manager.py
View license
    def create_snapshot(self, name, cleanup):
        try:
            snapshot_path = self.__interface.CreateSnapshot(name, cleanup)
            return str(snapshot_path)
        except dbus.exceptions.DBusException, error:
            raise SystemdError(error)

Example 2

Project: python-systemd
Source File: manager.py
View license
    def get_job(self, ID):
        """Get job by it ID.
        
        @param ID: Job ID.
        
        @raise SystemdError: Raised when no job is found with the given ID.
        
        @rtype: systemd.job.Job
        """
        try:
            job_path = self.__interface.GetJob(ID)
            job = Job(job_path)
            return job
        except dbus.exceptions.DBusException, error:
            raise SystemdError(error)

Example 3

Project: python-systemd
Source File: manager.py
View license
    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.unit.Unit
        """
        try:
            unit_path = self.__interface.GetUnit(name)
            unit = Unit(unit_path)
            return unit
        except dbus.exceptions.DBusException, error:
            raise SystemdError(error)

Example 4

Project: python-systemd
Source File: manager.py
View license
    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)

Example 5

Project: python-systemd
Source File: manager.py
View license
    def kill_unit(self, name, who, mode, signal):
        """Kill unit.
        
        @param name: Unit name (ie: network.service).
        @param who: Must be one of main, control or all.
        @param mode: Must be one of control-group, process-group, process.
        @param signal: Must be one of the well know signal number such  as
        SIGTERM(15), SIGINT(2), SIGSTOP(19) or SIGKILL(9).
        
        @raise SystemdError: Raised when no unit is found with the given name.
        
        @rtype: L{systemd.job.Job}
        """
        try:
            self.__interface.KillUnit(name, who, mode, signal)
        except dbus.exceptions.DBusException, error:
            print error
            raise SystemdError(error)

Example 6

Project: python-systemd
Source File: manager.py
View license
    def list_jobs(self):
        """List all jobs.
        
        @raise SystemdError, IndexError: Raised when dbus error or index error
        is raised.
        
        @rtype: A tuple of L{systemd.unit.Job}
        """
        try:
            jobs = []
            for job in self.__interface.ListJobs():
                jobs.append(Job(job[4]))
            return tuple(jobs)
        except dbus.exceptions.DBusException, error:
            raise SystemdError(error)

Example 7

Project: python-systemd
Source File: manager.py
View license
    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)

Example 8

Project: python-systemd
Source File: manager.py
View license
    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)

Example 9

Project: python-systemd
Source File: manager.py
View license
    def reload_or_restart_unit(self, name, mode):
        """Reload or restart unit.
        
        @param name: Unit name (ie: network.service).
        @param mode: Must be one of fail, replace or isolate.
        
        @raise SystemdError: Raised when no unit is found with the given name.
        
        @rtype: L{systemd.job.Job}
        """
        try:
            job_path = self.__interface.ReloadOrRestartUnit(name, mode)
            job = Job(job_path)
            return job
        except dbus.exceptions.DBusException, error:
            raise SystemdError(error)

Example 10

Project: python-systemd
Source File: manager.py
View license
    def reload_or_try_restart_unit(self, name, mode):
        """Reload or try restart unit.
        
        @param name: Unit name (ie: network.service).
        @param mode: Must be one of fail, replace or isolate.
        
        @raise SystemdError: Raised when no unit is found with the given name.
        
        @rtype: L{systemd.job.Job}
        """
        try:
            job_path = self.__interface.ReloadOrTryRestartUnit(name, mode)
            job = Job(job_path)
            return job
        except dbus.exceptions.DBusException, error:
            raise SystemdError(error)

Example 11

Project: python-systemd
Source File: manager.py
View license
    def reload_unit(self, name, mode):
        """Reload  unit.
        
        @param name: Unit name (ie: network.service).
        @param mode: Must be one of fail, replace.
        
        @raise SystemdError: Raised when no unit is found with the given name or
        mode is not corret.
        
        @rtype: L{systemd.job.Job}
        """
        try:
            job_path = self.__interface.ReloadUnit(name, mode)
            job = Job(job_path)
            return job
        except dbus.exceptions.DBusException, error:
            raise SystemdError(error)

Example 12

Project: python-systemd
Source File: manager.py
View license
    def restart_unit(self, name, mode):
        """Restart unit.
        
        @param name: Unit name (ie: network.service).
        @param mode: Must be one of fail, replace or isolate.
        
        @raise SystemdError: Raised when no unit is found with the given name.
        
        @rtype: L{systemd.job.Job}
        """
        try:
            job_path = self.__interface.RestartUnit(name, mode)
            job = Job(job_path)
            return job
        except dbus.exceptions.DBusException, error:
            raise SystemdError(error)

Example 13

Project: python-systemd
Source File: manager.py
View license
    def start_unit(self, name, mode):
        """Start unit.
        
        @param name: Unit name (ie: network.service).
        @param mode: Must be one of fail or replace.
        
        @raise SystemdError: Raised when no unit is found with the given name.
        
        @rtype: L{systemd.job.Job}
        """
        try:
            job_path = self.__interface.StartUnit(name, mode)
            job = Job(job_path)
            return job
        except dbus.exceptions.DBusException, error:
            raise SystemdError(error)

Example 14

Project: python-systemd
Source File: manager.py
View license
    def start_unit_replace(self, old_unit, new_unit, mode):
        """Start unit replace.
        
        @param old_unit: Old unit.
        @param new_unit: New unit.
        @param mode: Must be one of fail, replace, isolate, rescue or emergency.
        
        @raise SystemdError: Raised when no unit is found with the given name.
        
        @rtype: L{systemd.job.Job}
        """
        try:
            job_path = self.__interface.StartUnitReplace(old_unit, new_unit, mode)
            job = Job(job_path)
            return job
        except dbus.exceptions.DBusException, error:
            raise SystemdError(error)

Example 15

Project: python-systemd
Source File: manager.py
View license
    def stop_unit(self, name, mode):
        """Stop unit.
        
        @param name: Unit name (ie: network.service).
        @param mode:  Must be one of fail or replace.
        
        @raise SystemdError: Raised when no unit is found with the given name.
        
        @rtype: L{systemd.job.Job}
        """
        try:
            job_path = self.__interface.StopUnit(name, mode)
            job = Job(job_path)
            return job
        except dbus.exceptions.DBusException, error:
            raise SystemdError(error)

Example 16

Project: python-systemd
Source File: manager.py
View license
    def subscribe(self):
        try:
            self.__interface.Subscribe()
        except dbus.exceptions.DBusException, error:
            print error
            raise SystemdError(error)

Example 17

Project: python-systemd
Source File: manager.py
View license
    def try_restart_unit(self, name, mode):
        """Try restart unit.
        
        @param name: Unit name (ie: network.service).
        @param mode: Must be one of "fail" or "replace.
        
        @raise SystemdError: Raised when no unit is found with the given name or
        mode is invalid.
        
        @rtype: L{systemd.job.Job}
        """
        try:
            job_path = self.__interface.TryRestartUnit(name, mode)
            job = Job(job_path)
            return job
        except dbus.exceptions.DBusException, error:
            raise SystemdError(error)

Example 18

Project: python-systemd
Source File: unit.py
View license
    def kill(self, who, mode, signal):
        """Kill unit.
        
        @param who: Must be one of main, control or all.
        @param mode: Must be one of control-group, process-group, process.
        @param signal: Must be one of the well know signal number such  as
        SIGTERM(15), SIGINT(2), SIGSTOP(19) or SIGKILL(9).
        
        @raise SystemdError: Raised when who, mode or signal are invalid.
        
        @rtype: systemd.job.Job
        """
        try:
            self.__interface.KillUnit(who, mode, signal)
        except dbus.exceptions.DBusException, error:
            print error
            raise SystemdError(error)

Example 19

Project: python-systemd
Source File: unit.py
View license
    def reload(self, mode):
        """Reload unit.
        
        @param mode: Must be one of fail, replace or isolate.
        
        @raise SystemdError: Raised when mode is invalid.
        
        @rtype: systemd.job.Job
        """
        try:
            job_path = self.__interface.Reload(mode)
            job = Job(job_path)
            return job
        except dbus.exceptions.DBusException, error:
            raise SystemdError(error)

Example 20

Project: python-systemd
Source File: unit.py
View license
    def reload_or_restart(self, mode):
        """Reload or restart unit.
        
        @param mode: Must be one of fail, replace or isolate.
        
        @raise SystemdError: Raised when mode is invalid.
        
        @rtype: systemd.job.Job
        """
        try:
            job_path = self.__interface.ReloadOrRestart(mode)
            job = Job(job_path)
            return job
        except dbus.exceptions.DBusException, error:
            raise SystemdError(error)

Example 21

Project: python-systemd
Source File: unit.py
View license
    def reload_or_try_restart(self, mode):
        """Reload or try restart unit.
        
        @param mode: Must be one of fail, replace or isolate.
        
        @raise SystemdError: Raised when mode is invalid.
        
        @rtype: systemd.job.Job
        """
        try:
            job_path = self.__interface.ReloadOrTryRestart(mode)
            job = Job(job_path)
            return job
        except dbus.exceptions.DBusException, error:
            raise SystemdError(error)

Example 22

Project: python-systemd
Source File: unit.py
View license
    def restart(self, mode):
        """Restart unit.
        
        @param mode: Must be one of fail, replace or isolate.
        
        @raise SystemdError: Raised when mode is invalid.
        
        @rtype: systemd.job.Job
        """
        try:
            job_path = self.__interface.Restart(mode)
            job = Job(job_path)
            return job
        except dbus.exceptions.DBusException, error:
            raise SystemdError(error)

Example 23

Project: python-systemd
Source File: unit.py
View license
    def start(self, mode):
        """Start unit.
        
        @param mode: Must be one of fail or replace.
        
        @raise SystemdError: Raised when mode is invalid.
        
        @rtype: systemd.job.Job
        """
        try:
            job_path = self.__interface.Start(mode)
            job = Job(job_path)
            return job
        except dbus.exceptions.DBusException, error:
            raise SystemdError(error)

Example 24

Project: python-systemd
Source File: unit.py
View license
    def stop(self, mode):
        """Stop unit.
        
        @param mode:  Must be one of fail or replace.
        
        @raise SystemdError: Raised when mode is invalid.
        
        @rtype: systemd.job.Job
        """
        try:
            job_path = self.__interface.Stop(mode)
            job = Job(job_path)
            return job
        except dbus.exceptions.DBusException, error:
            raise SystemdError(error)

Example 25

Project: python-systemd
Source File: unit.py
View license
    def try_restart(self,mode):
        """Try restart unit.
        
        @param mode: Must be one of "fail" or "replace.
        
        @raise SystemdError: Raised when mode is invalid.
        
        @rtype: L{systemd.job.Job}
        """
        try:
            job_path = self.__interface.TryRestart(mode)
            job = Job(job_path)
            return job
        except dbus.exceptions.DBusException, error:
            raise SystemdError(error)

Example 26

Project: python-systemd
Source File: job.py
View license
    def cancel(self):
        try:
            self.__interface.Cancel()
        except dbus.exceptions.DBusException, error:
            raise SystemdError(error)

Example 27

Project: python-systemd
Source File: manager.py
View license
    def clear_jobs(self):
        try:
            self.__interface.ClearJobs()
        except dbus.exceptions.DBusException, error:
            raise SystemdError(error)

Example 28

Project: python-systemd
Source File: manager.py
View license
    def dump(self):
        try:
            self.__interface.Dump()
        except dbus.exceptions.DBusException, error:
            raise SystemdError(error)

Example 29

Project: python-systemd
Source File: manager.py
View license
    def exit(self):
        try:
            self.__interface.Exit()
        except dbus.exceptions.DBusException, error:
            raise SystemdError(error)

Example 30

Project: python-systemd
Source File: manager.py
View license
    def halt(self):
        try:
            self.__interface.Halt()
        except dbus.exceptions.DBusException, error:
            raise SystemdError(error)

Example 31

Project: python-systemd
Source File: manager.py
View license
    def k_exec(self):
        try:
            self.__interface.KExec()
        except dbus.exceptions.DBusException, error:
            raise SystemdError(error)

Example 32

Project: python-systemd
Source File: manager.py
View license
    def power_off(self):
        try:
            self.__interface.PowerOff()
        except dbus.exceptions.DBusException, error:
            raise SystemdError(error)

Example 33

Project: python-systemd
Source File: manager.py
View license
    def reboot(self):
        try:
            self.__interface.Reboot()
        except dbus.exceptions.DBusException, error:
            raise SystemdError(error)

Example 34

Project: python-systemd
Source File: manager.py
View license
    def reexecute(self):
        try:
            self.__interface.Reexecute()
        except dbus.exceptions.DBusException, error:
            raise SystemdError(error)

Example 35

Project: python-systemd
Source File: manager.py
View license
    def reload(self):
        try:
            self.__interface.Reload()
        except dbus.exceptions.DBusException, error:
            raise SystemdError(error)

Example 36

Project: python-systemd
Source File: manager.py
View license
    def reset_failed(self):
        try:
            self.__interface.ResetFailed()
        except dbus.exceptions.DBusException, error:
            raise SystemdError(error)

Example 37

Project: python-systemd
Source File: manager.py
View license
    def reset_failed_unit(self, name):
        try:
            self.__interface.ResetFailedUnit(name)
        except dbus.exceptions.DBusException, error:
            raise SystemdError(error)

Example 38

Project: python-systemd
Source File: manager.py
View license
    def set_environment(self, names):
        try:
            self.__interface.SetEnvironment(names)
        except dbus.exceptions.DBusException, error:
            raise SystemdError(error)

Example 39

Project: python-systemd
Source File: manager.py
View license
    def unset_environment(self, names):
        try:
            self.__interface.UnsetEnvironment(names)
        except dbus.exceptions.DBusException, error:
            raise SystemdError(error)

Example 40

Project: python-systemd
Source File: manager.py
View license
    def unsubscribe(self):
        try:
            self.__interface.Unsubscribe()
        except dbus.exceptions.DBusException, error:
            raise SystemdError(error)

Example 41

Project: python-systemd
Source File: snapshot.py
View license
    def remove(self):
        try:
            self.__interface.Remove()
        except dbus.exceptions.DBusException, error:
            raise SystemdError(error)

Example 42

Project: python-systemd
Source File: unit.py
View license
    def reset_failed(self):
        try:
            self.__interface.ResetFailed()
        except dbus.exceptions.DBusException, error:
            raise SystemdError(error)