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.if_exists(job_path) return job except dbus.exceptions.DBusException, error: raise SystemdError(error)
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.if_exists(job_path) return job except dbus.exceptions.DBusException, error: raise SystemdError(error)
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.if_exists(job_path) return job except dbus.exceptions.DBusException, error: raise SystemdError(error)
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.if_exists(job_path) return job except dbus.exceptions.DBusException, error: raise SystemdError(error)
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)
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)
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.if_exists(job_path) return job except dbus.exceptions.DBusException, error: raise SystemdError(error)
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.if_exists(job_path) return job except dbus.exceptions.DBusException, error: raise SystemdError(error)
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)
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)
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.if_exists(job_path) return job except dbus.exceptions.DBusException, error: raise SystemdError(error)
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.if_exists(job_path) return job except dbus.exceptions.DBusException, error: raise SystemdError(error)
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)
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)
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.if_exists(job_path) return job except dbus.exceptions.DBusException, error: raise SystemdError(error)