systemd.job.Job

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

17 Examples 7

Example 1

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 2

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 3

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 4

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 5

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 6

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 7

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 8

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 9

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 10

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 11

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 12

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 13

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 14

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 15

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 16

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 17

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)