test-functions: Hide uninteresting 'git clean' output.
[patchq.git] / drain-queues.py
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3
4 # This program drains all the queues, throwing away all the messages.
5 # Note that messages which are being processed are not and cannot be
6 # drained.
7
8 import pika
9 import config
10
11 connection = pika.BlockingConnection(pika.ConnectionParameters(
12     host = config.mq_server))
13 channel = connection.channel()
14
15 while True:
16     method, _, _ = channel.basic_get(queue = 'patchq_input', no_ack = True)
17     if not method: break
18
19 for t in config.tests:
20     qname = "patchq_test_%s" % t
21     while True:
22         method, _, _ = channel.basic_get(queue = qname, no_ack = True)
23         if not method: break
24
25 while True:
26     method, _, _ = channel.basic_get(queue = 'patchq_reports', no_ack = True)
27     if not method: break
28
29 print "All queues drained."