|
|
@ -86,10 +86,6 @@ def state_symbol(state):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def show_queues(queues, raw, by_queue, queue_class, worker_class):
|
|
|
|
def show_queues(queues, raw, by_queue, queue_class, worker_class):
|
|
|
|
if queues:
|
|
|
|
|
|
|
|
qs = list(map(queue_class, queues))
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
qs = queue_class.all()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
num_jobs = 0
|
|
|
|
num_jobs = 0
|
|
|
|
termwidth, _ = click.get_terminal_size()
|
|
|
|
termwidth, _ = click.get_terminal_size()
|
|
|
@ -97,14 +93,14 @@ def show_queues(queues, raw, by_queue, queue_class, worker_class):
|
|
|
|
|
|
|
|
|
|
|
|
max_count = 0
|
|
|
|
max_count = 0
|
|
|
|
counts = dict()
|
|
|
|
counts = dict()
|
|
|
|
for q in qs:
|
|
|
|
for q in queues:
|
|
|
|
count = q.count
|
|
|
|
count = q.count
|
|
|
|
counts[q] = count
|
|
|
|
counts[q] = count
|
|
|
|
max_count = max(max_count, count)
|
|
|
|
max_count = max(max_count, count)
|
|
|
|
scale = get_scale(max_count)
|
|
|
|
scale = get_scale(max_count)
|
|
|
|
ratio = chartwidth * 1.0 / scale
|
|
|
|
ratio = chartwidth * 1.0 / scale
|
|
|
|
|
|
|
|
|
|
|
|
for q in qs:
|
|
|
|
for q in queues:
|
|
|
|
count = counts[q]
|
|
|
|
count = counts[q]
|
|
|
|
if not raw:
|
|
|
|
if not raw:
|
|
|
|
chart = green('|' + '█' * int(ratio * count))
|
|
|
|
chart = green('|' + '█' * int(ratio * count))
|
|
|
@ -117,22 +113,15 @@ def show_queues(queues, raw, by_queue, queue_class, worker_class):
|
|
|
|
|
|
|
|
|
|
|
|
# print summary when not in raw mode
|
|
|
|
# print summary when not in raw mode
|
|
|
|
if not raw:
|
|
|
|
if not raw:
|
|
|
|
click.echo('%d queues, %d jobs total' % (len(qs), num_jobs))
|
|
|
|
click.echo('%d queues, %d jobs total' % (len(queues), num_jobs))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def show_workers(queues, raw, by_queue, queue_class, worker_class):
|
|
|
|
def show_workers(queues, raw, by_queue, queue_class, worker_class):
|
|
|
|
if queues:
|
|
|
|
|
|
|
|
qs = list(map(queue_class, queues))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
workers = set()
|
|
|
|
workers = set()
|
|
|
|
for queue in qs:
|
|
|
|
for queue in queues:
|
|
|
|
for worker in worker_class.all(queue=queue):
|
|
|
|
for worker in worker_class.all(queue=queue):
|
|
|
|
workers.add(worker)
|
|
|
|
workers.add(worker)
|
|
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
qs = queue_class.all()
|
|
|
|
|
|
|
|
workers = worker_class.all()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not by_queue:
|
|
|
|
if not by_queue:
|
|
|
|
|
|
|
|
|
|
|
|
for worker in workers:
|
|
|
|
for worker in workers:
|
|
|
@ -146,7 +135,7 @@ def show_workers(queues, raw, by_queue, queue_class, worker_class):
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
# Display workers by queue
|
|
|
|
# Display workers by queue
|
|
|
|
queue_dict = {}
|
|
|
|
queue_dict = {}
|
|
|
|
for queue in qs:
|
|
|
|
for queue in queues:
|
|
|
|
queue_dict[queue] = worker_class.all(queue=queue)
|
|
|
|
queue_dict[queue] = worker_class.all(queue=queue)
|
|
|
|
|
|
|
|
|
|
|
|
if queue_dict:
|
|
|
|
if queue_dict:
|
|
|
@ -166,7 +155,7 @@ def show_workers(queues, raw, by_queue, queue_class, worker_class):
|
|
|
|
click.echo('%s %s' % (pad(queue.name + ':', max_length + 1), queues_str))
|
|
|
|
click.echo('%s %s' % (pad(queue.name + ':', max_length + 1), queues_str))
|
|
|
|
|
|
|
|
|
|
|
|
if not raw:
|
|
|
|
if not raw:
|
|
|
|
click.echo('%d workers, %d queues' % (len(workers), len(qs)))
|
|
|
|
click.echo('%d workers, %d queues' % (len(workers), len(queues)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def show_both(queues, raw, by_queue, queue_class, worker_class):
|
|
|
|
def show_both(queues, raw, by_queue, queue_class, worker_class):
|
|
|
|