@@ -12,19 +12,19 @@ class ResWeb(pystache.View):
1212 def __init__ (self , host ):
1313 super (ResWeb , self ).__init__ ()
1414 self .resq = host
15-
15+
1616 def media_folder (self ):
1717 return '/media/'
18-
18+
1919 def close (self ):
2020 self .resq .close ()
21-
21+
2222 def address (self ):
2323 return '%s:%s' % (self .resq .redis .host ,self .resq .redis .port )
24-
24+
2525 def version (self ):
2626 return str (__version__ )
27-
27+
2828 def pages (self , start , size , link_function , width = 20 ):
2929 pages = []
3030
@@ -49,10 +49,10 @@ def __init__(self, host, queue=None, start=0):
4949 self ._queue = queue
5050 self ._start = start
5151 super (Overview , self ).__init__ (host )
52-
52+
5353 def queue (self ):
5454 return self ._queue
55-
55+
5656 def queues (self ):
5757 queues = []
5858 for q in self .resq .queues ():
@@ -61,16 +61,16 @@ def queues(self):
6161 'size' : str (self .resq .size (q )),
6262 })
6363 return queues
64-
64+
6565 def start (self ):
6666 return str (self ._start )
67-
67+
6868 def end (self ):
6969 return str (self ._start + 20 )
70-
70+
7171 def size (self ):
7272 return str (self .resq .size (self ._queue ))
73-
73+
7474 def jobs (self ):
7575 jobs = []
7676 for job in self .resq .peek (self ._queue , self ._start , self ._start + 20 ):
@@ -79,17 +79,17 @@ def jobs(self):
7979 'args' :',' .join (job ['args' ])
8080 })
8181 return jobs
82-
82+
8383 def empty_jobs (self ):
8484 return len (self .jobs ()) == 0
85-
85+
8686 def empty (self ):
8787 return not self ._queue
88-
88+
8989 def fail_count (self ):
9090 #from pyres.failure import Failure
9191 return str (failure .count (self .resq ))
92-
92+
9393 def workers (self ):
9494 workers = []
9595 for w in self .resq .working ():
@@ -113,10 +113,10 @@ def workers(self):
113113 return workers
114114 def worker_size (self ):
115115 return str (len (self .workers ()))
116-
116+
117117 def total_workers (self ):
118118 return str (len (Wrkr .all (self .resq )))
119-
119+
120120 def empty_workers (self ):
121121 if len (self .workers ()):
122122 return False
@@ -127,14 +127,14 @@ class Queues(Overview):
127127
128128class Working (Overview ):
129129 template_name = 'working_full'
130-
130+
131131class Workers (ResWeb ):
132132 def size (self ):
133133 return str (len (self .all ()))
134-
134+
135135 def all (self ):
136136 return Wrkr .all (self .resq )
137-
137+
138138 def workers (self ):
139139 workers = []
140140 for w in self .all ():
@@ -167,7 +167,7 @@ def __init__(self, host, key, start=0):
167167 self .key = key
168168 self ._start = start
169169 super (Queue , self ).__init__ (host )
170-
170+
171171 def start (self ):
172172 return str (self ._start )
173173
@@ -176,13 +176,13 @@ def end(self):
176176 if end > int (self .size ()):
177177 end = self .size ()
178178 return str (end )
179-
179+
180180 def queue (self ):
181181 return self .key
182-
182+
183183 def size (self ):
184184 return str (self .resq .size (self .key ) or 0 )
185-
185+
186186 def jobs (self ):
187187 jobs = []
188188 for job in self .resq .peek (self .key , self ._start , self ._start + 20 ):
@@ -191,29 +191,29 @@ def jobs(self):
191191 'args' : str (job ['args' ])
192192 })
193193 return jobs
194-
194+
195195 def pagination (self ):
196196 return self .pages (self ._start , int (self .size ()), self .link_func )
197-
197+
198198 def link_func (self , start ):
199199 return '/queues/%s/?start=%s' % (self .key , start )
200-
200+
201201
202202class Failed (ResWeb ):
203203 def __init__ (self , host , start = 0 ):
204204 self ._start = start
205205 self .host = host
206206 super (Failed , self ).__init__ (host )
207-
207+
208208 def start (self ):
209209 return str (self ._start )
210-
210+
211211 def end (self ):
212212 return str (self ._start + 20 )
213-
213+
214214 def size (self ):
215215 return str (failure .count (self .resq ) or 0 )
216-
216+
217217 def failed_jobs (self ):
218218 from base64 import b64encode
219219 try :
@@ -230,18 +230,18 @@ def failed_jobs(self):
230230 item ['traceback' ] = job ['backtrace' ]
231231 jobs .append (item )
232232 return jobs
233-
233+
234234 def pagination (self ):
235235 return self .pages (self ._start , int (self .size ()), self .link_func )
236-
236+
237237 def link_func (self , start ):
238238 return '/failed/?start=%s' % start
239-
239+
240240class Stats (ResWeb ):
241241 def __init__ (self , host , key_id ):
242242 self .key_id = key_id
243243 super (Stats , self ).__init__ (host )
244-
244+
245245 def sub_nav (self ):
246246 sub_nav = []
247247 sub_nav .append ({
@@ -257,7 +257,7 @@ def sub_nav(self):
257257 'subtab' :'keys'
258258 })
259259 return sub_nav
260-
260+
261261 def title (self ):
262262 if self .key_id == 'resque' :
263263 return 'Pyres'
@@ -267,7 +267,7 @@ def title(self):
267267 return 'Keys owned by Pyres'
268268 else :
269269 return ''
270-
270+
271271 def stats (self ):
272272 if self .key_id == 'resque' :
273273 return self .resque_info ()
@@ -277,7 +277,7 @@ def stats(self):
277277 return self .key_info ()
278278 else :
279279 return []
280-
280+
281281 def resque_info (self ):
282282 stats = []
283283 for key , value in self .resq .info ().items ():
@@ -286,7 +286,7 @@ def resque_info(self):
286286 'value' : str (value )
287287 })
288288 return stats
289-
289+
290290 def redis_info (self ):
291291 stats = []
292292 for key , value in self .resq .redis .info ().items ():
@@ -298,16 +298,16 @@ def redis_info(self):
298298 def key_info (self ):
299299 stats = []
300300 for key in self .resq .keys ():
301-
301+
302302 stats .append ({
303303 'key' : str (key ),
304304 'type' : str (self .resq .redis .type ('resque:' + key )),
305- 'size' : str (redis_size (key , self .resq ))
305+ 'size' : str (redis_size (key , self .resq ))
306306 })
307307 return stats
308308 def standard (self ):
309309 return not self .resque_keys ()
310-
310+
311311 def resque_keys (self ):
312312 if self .key_id == 'keys' :
313313 return True
@@ -317,13 +317,13 @@ class Stat(ResWeb):
317317 def __init__ (self , host , stat_id ):
318318 self .stat_id = stat_id
319319 super (Stat , self ).__init__ (host )
320-
320+
321321 def key (self ):
322322 return str (self .stat_id )
323-
323+
324324 def key_type (self ):
325325 return str (self .resq .redis .type ('resque:' + str (self .stat_id )))
326-
326+
327327 def items (self ):
328328 items = []
329329 if self .key_type () == 'list' :
@@ -343,32 +343,32 @@ def items(self):
343343 'row' :str (self .resq .redis .get ('resque:' + self .stat_id ))
344344 })
345345 return items
346-
346+
347347 def size (self ):
348348 return redis_size (self .stat_id ,self .resq )
349-
349+
350350class Worker (ResWeb ):
351351 def __init__ (self , host , worker_id ):
352352 self .worker_id = worker_id
353353 super (Worker , self ).__init__ (host )
354354 self ._worker = Wrkr .find (worker_id , self .resq )
355-
355+
356356 def worker (self ):
357357 return str (self .worker_id )
358-
358+
359359 def host (self ):
360360 host ,pid ,queues = str (self .worker_id ).split (':' )
361361 return str (host )
362362 def pid (self ):
363363 host ,pid ,queues = str (self .worker_id ).split (':' )
364364 return str (pid )
365-
365+
366366 def state (self ):
367367 return str (self ._worker .state ())
368-
368+
369369 def started_at (self ):
370370 return str (self ._worker .started )
371-
371+
372372 def queues (self ):
373373 host ,pid ,queues = str (self .worker_id ).split (':' )
374374 qs = []
@@ -379,7 +379,7 @@ def queues(self):
379379 return qs
380380 def processed (self ):
381381 return str (self ._worker .get_processed ())
382-
382+
383383 def failed (self ):
384384 return str (self ._worker .get_failed ())
385385 def data (self ):
@@ -397,7 +397,7 @@ def runat(self):
397397 if self .data ():
398398 return str (datetime .datetime .fromtimestamp (float (data ['run_at' ])))
399399 return ''
400-
400+
401401 """
402402 item = {
403403 'state':w.state(),
@@ -442,9 +442,9 @@ def jobs(self):
442442 t = datetime .datetime .fromtimestamp (float (timestamp ))
443443 item = dict (timestamp = str (timestamp ))
444444 item ['size' ] = str (self .resq .delayed_timestamp_size (timestamp ))
445-
445+
446446 item ['formated_time' ] = str (t )
447-
447+
448448 jobs .append (item )
449449 return jobs
450450
@@ -459,10 +459,10 @@ def __init__(self, host, timestamp, start=0):
459459 self ._start = start
460460 self ._timestamp = timestamp
461461 super (DelayedTimestamp , self ).__init__ (host )
462-
462+
463463 def formated_timestamp (self ):
464464 return str (datetime .datetime .fromtimestamp (float (self ._timestamp )))
465-
465+
466466 def start (self ):
467467 return str (self ._start )
468468
@@ -482,12 +482,12 @@ def jobs(self):
482482 }
483483 jobs .append (item )
484484 return jobs
485-
485+
486486 def no_jobs (self ):
487487 if int (self .size ()) > 0 :
488488 return False
489489 return True
490-
490+
491491 def pagination (self ):
492492 return self .pages (self ._start , int (self .size ()), self .link_func )
493493
0 commit comments