source: cows_wps/trunk/cows_wps/controllers/jobs.py @ 5968

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/cows_wps/trunk/cows_wps/controllers/jobs.py@5968
Revision 5968, 1.6 KB checked in by astephen, 10 years ago (diff)

More

Line 
1import logging
2
3from pylons import request, response, session, tmpl_context as c
4from pylons.controllers.util import abort, redirect_to
5
6from cows_wps.renderer.ui_renderer import *
7from cows_wps.controllers import *
8from cows_wps.lib.ui.proc_config import *
9
10from cows_wps.model.managers import requestManager
11from cows_wps.process_handler.context.process_status import STATUS
12
13log = logging.getLogger(__name__)
14
15class JobsController(BaseController):
16
17    def cancel(self):
18        """
19        Cancel a job
20        """
21        job_id = request.params.get("job_id", None)
22        if job_id == None:
23            return "Please provide an argument job_id=<Something>"
24
25        resp = "Nothing yet..."
26        renderer = UIPageRenderer()
27        resp = renderer.render("Job cancellation page",
28                               [("Cancelling: %s" % job_id, resp)])
29        return resp
30
31
32    def index(self):
33        """
34        Reads jobs list and shows.
35        """
36        requestManager.updateRunningRequests()
37
38        resp = '<table border="2"><tr><td>Job id</td><td>type</td><td>user</td><td>status</td></tr>\n'
39        for r in requestManager.getAllRequest():
40            status = r.job.status
41            type = r.job.type
42            job_id = r.job.job_id
43            user = r.user_id
44            row = "<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>\n" % (job_id, type, user, status)
45            resp += row
46
47        resp += "</table>" 
48        renderer = UIPageRenderer()
49        resp = renderer.render("Job list page",
50                               [("All jobs", resp)])
51        return resp
Note: See TracBrowser for help on using the repository browser.