예제 #1
0
def start_slashdot_mainpage_scraper():
    print(" >>> Starting slashdot scraper.")
    try:
        slashdot_job = UpstartJob(SLASHDOT_SCRAPER)
        slashdot_job.start()
        print(" >>> Scraper started successfully.")
    except:
        print(" >>> Scraper failed to start.")
예제 #2
0
def start_slashdot_api_server():
    print(" >>> Starting slashdot server.")
    try:
        slashdot_job = UpstartJob(SLASHDOT_API)
        slashdot_job.start()
        print(" >>> Server started succesfully.")
    except:
        print("Slashdot server couldn't start.")
예제 #3
0
 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
예제 #4
0
 def get_service(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
예제 #5
0
def stop_slashdot_api_server():
    jobs = show_upstart_jobs()
    slashdot_job = None
    for job in jobs:
        if job == SLASHDOT_API:
            try:
                print(" >>> Stopping slashdot api")
                slashdot_job = UpstartJob(str(job))
                slashdot_job.stop()
            except:
                print("Job is not running.")
        else:
            pass
예제 #6
0
def stop_slashdot_mainpage_scraper():
    jobs = show_upstart_jobs()
    slashdot_job = None
    for job in jobs:
        if job == SLASHDOT_SCRAPER:
            try:
                print(" >>> Stopping scraper.")
                slashdot_job = UpstartJob(str(job))
                slashdot_job.stop()
                print(" >>> Scraper stopped succesfully.")
            except:
                pass
        else:
            pass
예제 #7
0
    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
예제 #8
0
    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)
예제 #9
0
 def restart(self, _id):
     UpstartJob(_id).restart()
예제 #10
0
 def stop(self, _id):
     UpstartJob(_id).stop()
예제 #11
0
 def start(self, _id):
     UpstartJob(_id).start()
예제 #12
0
 def restart(self, _id):
     try:
         UpstartJob(_id).restart()
     except DBusException as e:
         raise ServiceOperationError(e)