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 2
2
< html >
3
3
< head >
4
4
< 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 >
10
5
</ head >
11
6
< body >
12
7
16
11
PyRes - A Resque offshoot
17
12
</ div >
18
13
< 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 >
25
20
</ ul >
26
21
</ div >
27
22
{%block subtabs%}
File renamed without changes.
Original file line number Diff line number Diff line change @@ -6,14 +6,14 @@ <h1>Queues</h1>
6
6
< th > Name</ th >
7
7
< th > Pending</ th >
8
8
</ tr >
9
- {% for queue in queue_list %}
9
+ {% for queue in queues %}
10
10
< 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 >
13
13
</ tr >
14
14
{% endfor %}
15
15
< tr >
16
- < td > < a class ="queue " href ="{%url failed%} "> failed</ a > </ td >
16
+ < td > < a class ="queue " href ="/ failed/ "> failed</ a > </ td >
17
17
< td > {{failure_count}}</ td >
18
18
</ tr >
19
19
</ table >
Original file line number Diff line number Diff line change 1
1
{% extends "base.html" %}
2
2
{%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 >
5
4
< table >
6
5
< tr >
7
6
< th > Class</ th >
8
7
< th > Args</ th >
9
8
</ tr >
10
- {% for job in waiting %}
9
+ {% for job in resq.peek(queue,0,20) %}
11
10
< tr >
12
11
< td > {{job.klass }}</ td >
13
12
< 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 1
1
{% extends "base.html" %}
2
2
{%block main%}
3
- < h1 > {{current_count }} of {{total_workers }} Workers Working</ h1 >
3
+ < h1 > {{len(workers) }} of {{all_workers }} Workers Working</ h1 >
4
4
< table >
5
5
< tr >
6
6
< th > </ th >
@@ -15,7 +15,6 @@ <h1>{{current_count}} of {{total_workers}} Workers Working</h1>
15
15
{% endif %}
16
16
17
17
{% for worker in workers %}
18
-
19
18
< tr >
20
19
< td > < img src ="" alt ="" title =""> </ td >
21
20
< td > < a href ="# "> {{worker._host}}:{{worker._pid}}</ a > </ td >
You can’t perform that action at this time.
0 commit comments