send-reports: Truncate content to 50K.
[patchq.git] / show-queues.py
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3
4 # Display the contents of the queues.
5 #
6 # Note this cannot display messages which are being processed.
7 #
8 # This works by fetching the messages without acknowledging them,
9 # effectively peeking into the queues.
10
11 import email
12 import json
13 import pika
14
15 import config
16
17 connection = pika.BlockingConnection(pika.ConnectionParameters(
18     host = config.mq_server))
19 channel = connection.channel()
20
21 print "patchq_input (Unordered messages):"
22 while True:
23     method, _, body = channel.basic_get(queue = 'patchq_input', no_ack = False)
24     if not method: break
25     m = email.message_from_string(body) # the email
26     # Only display the subject line.
27     print ("    %s" % m['Subject'])
28
29 for t in config.tests:
30     qname = "patchq_test_%s" % t
31     print ("%s (Threads queued for %s):" % (qname, t))
32     while True:
33         method, _, body = channel.basic_get(queue = qname, no_ack = False)
34         if not method: break
35
36         msgs = json.loads(body)
37         msgs = [email.message_from_string(m) for m in msgs]
38
39         print ("    Thread:")
40         for m in msgs:
41             print ("        %s" % m['Subject'])
42
43 print "patchq_reports (Reports):"
44 while True:
45     method, _, _ = channel.basic_get(queue = 'patchq_reports', no_ack = False)
46     if not method: break
47
48     to, subject, ref, content = json.loads(body)
49
50     print ("    %s" % subject)
51
52 print
53 print "Note that messages being processed are not displayed.  To see all"
54 print "messages use ‘rabbitmqctl list_queues’ and other RabbitMQ admin tools."