def get(self, _id): job = UpstartJob(_id, bus=self.bus) svc = Service(self) svc.id = _id svc.name = self.__fix_name(_id) try: svc.state = job.get_status()['state'] svc.running = svc.state == 'running' except: svc.running = False return svc
def stop(self, _id): """ Basically stop a job. :param _id: job name :type _id: string """ try: UpstartJob(_id).stop() except DBusException as e: raise ServiceOperationError(e)
def get_service(self, _id): """ Get informations from module upstart for one specified job. :param _id: Job name :type _id: string :return: Service object :rtype: Service """ job = UpstartJob(_id, bus=self.bus) svc = Service(self) svc.id = _id svc.name = self.__fix_name(_id) try: svc.state = job.get_status()['state'] svc.running = svc.state == 'running' except Exception as e: svc.running = False return svc
def restart(self, _id): UpstartJob(_id).restart()
def stop(self, _id): UpstartJob(_id).stop()
def start(self, _id): UpstartJob(_id).start()
def restart(self, _id): try: UpstartJob(_id).restart() except DBusException as e: raise ServiceOperationError(e)