Exemplo n.º 1
0
    def get_job_list(self, request):
        try:
            options = request[0]
        except (TypeError, IndexError):
            options = {}

        jobs_list = Job.list(self.collection,
            status=options['statuses'],
            type=options['job_type'])
        total_jobs = jobs_list.count()

        if options.get('limit'):
            limit = int(options['limit'])
            offset = int(options.get('offset', 0))

            jobs_list = jobs_list[offset:offset + limit]

        res = []
        for j in jobs_list:
            try:
                res.append(JobFactory.make_job(j).human_dump())
            except Exception:
                job_id = j.get('id', '[unknown id]')
                logger.exception('Failed to dump job {}'.format(job_id))
                continue
        return {'jobs': res,
                'total': total_jobs}
Exemplo n.º 2
0
 def _get_job(self, job_id):
     jobs_list = Job.list(self.collection, id=job_id).limit(1)
     if not jobs_list:
         raise ValueError('Job {0} is not found'.format(job_id))
     job = JobFactory.make_job(jobs_list[0])
     job.collection = self.collection
     return job
Exemplo n.º 3
0
    def get_job_list(self, request):
        try:
            options = request[0]
        except (TypeError, IndexError):
            options = {}

        jobs_list = Job.list(self.collection,
                             status=options['statuses'],
                             type=options['job_type'])
        total_jobs = jobs_list.count()

        if options.get('limit'):
            limit = int(options['limit'])
            offset = int(options.get('offset', 0))

            jobs_list = jobs_list[offset:offset + limit]

        res = []
        for j in jobs_list:
            try:
                res.append(JobFactory.make_job(j).human_dump())
            except Exception:
                job_id = j.get('id', '[unknown id]')
                logger.exception('Failed to dump job {}'.format(job_id))
                continue
        return {'jobs': res, 'total': total_jobs}
Exemplo n.º 4
0
 def _get_job(self, job_id):
     jobs_list = Job.list(self.collection,
         id=job_id).limit(1)
     if not jobs_list:
         raise ValueError('Job {0} is not found'.format(job_id))
     job = JobFactory.make_job(jobs_list[0])
     job.collection = self.collection
     return job
Exemplo n.º 5
0
 def jobs(self, types=None, statuses=None, ids=None):
     jobs = [JobFactory.make_job(j) for j in Job.list(self.collection,
                                                      status=statuses,
                                                      type=types,
                                                      id=ids)]
     for j in jobs:
         j.collection = self.collection
         j._dirty = False
     return jobs
Exemplo n.º 6
0
    def __init__(self):
        daemon = Pyro4.Daemon()
        ns = Pyro4.locateNS()

        factory = JobFactory()

        uri = daemon.register(factory)
        ns.register("factory", uri)

        print("Server is ready.")
        daemon.requestLoop()
Exemplo n.º 7
0
 def jobs(self, types=None, statuses=None, ids=None, groups=None):
     jobs = [
         JobFactory.make_job(j) for j in Job.list(self.collection,
                                                  status=statuses,
                                                  type=types,
                                                  group=groups,
                                                  id=ids)
     ]
     for j in jobs:
         j.collection = self.collection
         j._dirty = False
     return jobs
Exemplo n.º 8
0
    def get_job_list(self, request):
        try:
            options = request[0]
        except (TypeError, IndexError):
            options = {}

        jobs_list = Job.list(self.collection,
                             status=options['statuses'],
                             type=options['job_type'])
        total_jobs = jobs_list.count()

        if options.get('limit'):
            limit = int(options['limit'])
            offset = int(options.get('offset', 0))

            jobs_list = jobs_list[offset:offset + limit]

        res = [JobFactory.make_job(j).human_dump() for j in jobs_list]
        return {'jobs': res, 'total': total_jobs}
Exemplo n.º 9
0
    def get_job_list(self, request):
        try:
            options = request[0]
        except (TypeError, IndexError):
            options = {}

        jobs_list = Job.list(self.collection,
            status=options['statuses'],
            type=options['job_type'])
        total_jobs = jobs_list.count()

        if options.get('limit'):
            limit = int(options['limit'])
            offset = int(options.get('offset', 0))

            jobs_list = jobs_list[offset:offset + limit]

        res = [JobFactory.make_job(j).human_dump() for j in jobs_list]
        return {'jobs': res,
                'total': total_jobs}