Ejemplo n.º 1
0
 def format_args(self, job):
     try:
         argnames = inspect.getargspec(job.callable).args
     except:
         argnames = None
     if argnames is not None:
         args = ', '.join('%s=%s' % (k, v)
                             for k, v in zip(argnames, job.args))
     else:
         args = ', '.join(custom_repr(a) for a in job.args)
     kwargs = ', '.join(k + "=" + custom_repr(v)
                         for k, v in job.kwargs.items())
     if args and kwargs:
         args += ", " + kwargs
     elif kwargs:
         args = kwargs
     return 'Args: %s' % args
Ejemplo n.º 2
0
    def format_title(self, job):
        """ Title format
        """
        annotation = self.get_job_annotation(job)
        custom_title = custom_repr(job.callable)
        if not annotation:
            return custom_title

        title = annotation.get('title', custom_title)
        return title
Ejemplo n.º 3
0
    def format_title(self, job):
        """ Title format
        """
        annotation = self.get_job_annotation(job)
        custom_title = custom_repr(job.callable)
        if not annotation:
            return custom_title

        title = annotation.get('title', custom_title)
        return title
Ejemplo n.º 4
0
    def __call__(self):
        self.request.response.setHeader('Content-Type', 'application/json')

        jobs = {
            'queued': [],
            'active': [],
            'completed': [],
            'dead': [],
        }

        for job_status, job in self._filter_jobs():
            jobs[job_status].append({
                'id': u64(job._p_oid),
                'callable': custom_repr(job.callable),
                'args': self.format_args(job),
                'status': self.format_status(job),
                'progress': self.format_progress(job),
                'failure': self.format_failure(job),
            })

        return json.dumps(jobs)