File tree Expand file tree Collapse file tree 9 files changed +72
-20
lines changed
Expand file tree Collapse file tree 9 files changed +72
-20
lines changed Original file line number Diff line number Diff line change 1+ from jinja2 import Environment , PackageLoader
2+ env = Environment (loader = PackageLoader ('resweb' , 'templates' ))
3+ from itty import *
4+ from pyres import ResQ
5+ from pyres .failure import Failure
6+ from pyres .worker import Worker
7+ HOST = "localhost:6379"
8+ resq = ResQ (HOST )
9+
10+ @get ("/" )
11+ def index (request ):
12+ queues = ResQ .queues (HOST )
13+ failure_count = Failure .count (ResQ (HOST ))
14+ template = env .get_template ('overview.html' )
15+ dic = {
16+ 'queues' :queues ,
17+ 'failure_count' :failure_count ,
18+ 'resq' : resq
19+ }
20+ return str (template .render (dic ))
21+
22+
23+
24+ @get ("/working/" )
25+ def working (request ):
26+ workers = Worker .working (request .resq ._server )
27+ template = env .get_template ('working.html' )
28+ dic = {
29+ 'all_workers' :Worker .all (settings .RESQ_HOST ),
30+ 'workers' :workers ,
31+ 'resq' : resq
32+ }
33+ return str (template .render (dic ))
34+
35+ @get ("/queues/" )
36+ def queues (request ):
37+ return ""
38+
39+ @get ('/queues/(?P<queue_id>\w+)/' )
40+ def queue (request , queue_id ):
41+ context = {}
42+ context ['queue' ] = queue_id
43+ context ['resq' ] = resq
44+ template = env .get_template ('queue_detail.html' )
45+ return str (template .render (context ))
46+
47+ @get (r'/failed/$' )
48+ def failed (request ):
49+ return ""
50+
51+ @get (r'/workers/$' )
52+ def workers (request ):
53+ return ""
54+
55+ @get (r'/stats/$' )
56+ def stats (request ):
57+ return ""
58+
59+ run_itty ()
Original file line number Diff line number Diff line change 22< html >
33< head >
44 < title > PyRes.</ title >
5- < link href ="<%=u 'style.css' %> " media ="screen " rel ="stylesheet " type ="text/css ">
6- < link href ="<%=u 'tabs.css' %> " media ="screen " rel ="stylesheet " type ="text/css ">
7- < script src ="<%=u 'jquery-1.3.2.min.js' %> " type ="text/javascript "</ script >
8- < script src ="<%=u 'jquery.relatize_date.js' %> " type ="text/javascript "</ script >
9- < script src ="<%=u 'ranger.js' %> " type ="text/javascript "> </ script >
105</ head >
116< body >
127
1611 PyRes - A Resque offshoot
1712 </ div >
1813 < ul >
19- < li > < a href ='{%url overview %} '> Overview</ a > </ li >
20- < li > < a href ='{%url working %} '> Working</ a > </ li >
21- < li > < a href ='{%url failed %} '> Failed</ a > </ li >
22- < li > < a href ='{%url queues %} '> Queues</ a > </ li >
23- < li > < a href ='{%url workers %} '> Workers</ a > </ li >
24- < li > < a href ='{%url stats %} '> Stats</ a > </ li >
14+ < li > < a href ='/ '> Overview</ a > </ li >
15+ < li > < a href ='/ working/ '> Working</ a > </ li >
16+ < li > < a href ='/ failed/ '> Failed</ a > </ li >
17+ < li > < a href ='/ queues/ '> Queues</ a > </ li >
18+ < li > < a href ='/ workers/ '> Workers</ a > </ li >
19+ < li > < a href ='/ stats '> Stats</ a > </ li >
2520 </ ul >
2621 </ div >
2722 {%block subtabs%}
File renamed without changes.
Original file line number Diff line number Diff line change @@ -6,14 +6,14 @@ <h1>Queues</h1>
66 < th > Name</ th >
77 < th > Pending</ th >
88 </ tr >
9- {% for queue in queue_list %}
9+ {% for queue in queues %}
1010 < tr >
11- < td > < a class ="queue " href ="/queues/{{queue.name }}/ "> {{queue.name }}</ a > </ td >
12- < td > {{queue.count }}</ td >
11+ < td > < a class ="queue " href ="/queues/{{queue}}/ "> {{queue}}</ a > </ td >
12+ < td > {{ resq.size(queue) }}</ td >
1313 </ tr >
1414 {% endfor %}
1515 < tr >
16- < td > < a class ="queue " href ="{%url failed%} "> failed</ a > </ td >
16+ < td > < a class ="queue " href ="/ failed/ "> failed</ a > </ td >
1717 < td > {{failure_count}}</ td >
1818 </ tr >
1919</ table >
Original file line number Diff line number Diff line change 11{% extends "base.html" %}
22{%block main%}
3- < h1 > {{queue.count}} Pending Jobs in '{{queue.name}}'</ h1 >
4- < h2 > Showing 0 to 20</ h2 >
3+ < h1 > {{resq.size(queue)}} Pending Jobs in '{{queue}}'</ h1 >
54< table >
65 < tr >
76 < th > Class</ th >
87 < th > Args</ th >
98 </ tr >
10- {% for job in waiting %}
9+ {% for job in resq.peek(queue,0,20) %}
1110 < tr >
1211 < td > {{job.klass }}</ td >
1312 < td > {{ job.args }}</ td >
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change 11{% extends "base.html" %}
22{%block main%}
3- < h1 > {{current_count }} of {{total_workers }} Workers Working</ h1 >
3+ < h1 > {{len(workers) }} of {{all_workers }} Workers Working</ h1 >
44< table >
55 < tr >
66 < th > </ th >
@@ -15,7 +15,6 @@ <h1>{{current_count}} of {{total_workers}} Workers Working</h1>
1515 {% endif %}
1616
1717 {% for worker in workers %}
18-
1918 < tr >
2019 < td > < img src ="" alt ="" title =""> </ td >
2120 < td > < a href ="# "> {{worker._host}}:{{worker._pid}}</ a > </ td >
You can’t perform that action at this time.
0 commit comments