Ejemplo n.º 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.")
Ejemplo n.º 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.")
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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)
Ejemplo n.º 9
0
 def restart(self, _id):
     UpstartJob(_id).restart()
Ejemplo n.º 10
0
 def stop(self, _id):
     UpstartJob(_id).stop()
Ejemplo n.º 11
0
 def start(self, _id):
     UpstartJob(_id).start()
Ejemplo n.º 12
0
 def restart(self, _id):
     try:
         UpstartJob(_id).restart()
     except DBusException as e:
         raise ServiceOperationError(e)