Merge lp:~lifeless/python-oops-tools/amqp into lp:python-oops-tools

Proposed by Robert Collins
Status: Merged
Approved by: Robert Collins
Approved revision: 5
Merged at revision: 4
Proposed branch: lp:~lifeless/python-oops-tools/amqp
Merge into: lp:python-oops-tools
Diff against target: 65 lines (+20/-3)
2 files modified
src/oopstools/NEWS.txt (+6/-0)
src/oopstools/scripts/amqp2disk.py (+14/-3)
To merge this branch: bzr merge lp:~lifeless/python-oops-tools/amqp
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+79749@code.launchpad.net

Commit message

Update the amqp support to be a little easier to use and more robust.

Description of the change

Update the amqp support to be a little easier to use and more robust. Also working properly. (I've had a dev environment doing just-in-time reporting of OOPSes! \o/).

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/oopstools/NEWS.txt'
--- src/oopstools/NEWS.txt 2011-10-18 04:15:08 +0000
+++ src/oopstools/NEWS.txt 2011-10-18 23:10:28 +0000
@@ -9,6 +9,12 @@
99
10* Bumped oops-amqp rev to 0.0.2 for bugfixes. (Robert Collins)10* Bumped oops-amqp rev to 0.0.2 for bugfixes. (Robert Collins)
1111
12* amqp2disk now creates a fanout exchange if --bind-to is supplied.
13 (Robert Collins)
14
15* amqp2disk -v will print the received OOPS ids on the console, for
16 entertainment and delight. (Robert Collins)
17
120.6180.6
13===19===
1420
1521
=== modified file 'src/oopstools/scripts/amqp2disk.py'
--- src/oopstools/scripts/amqp2disk.py 2011-10-18 04:15:08 +0000
+++ src/oopstools/scripts/amqp2disk.py 2011-10-18 23:10:28 +0000
@@ -55,9 +55,12 @@
55 The AMQP environment should be setup in advance with a persistent queue55 The AMQP environment should be setup in advance with a persistent queue
56 bound to your exchange : using transient queues would allow OOPSes to56 bound to your exchange : using transient queues would allow OOPSes to
57 be lost if the amqp2disk process were to be shutdown for a non-trivial57 be lost if the amqp2disk process were to be shutdown for a non-trivial
58 duration. The --bind-to option will cause the queue to be created and58 duration. The --bind-to option will cause the queue (and exchange if
59 bound to the given exchange. This is only needed the first time as it59 necessary) to be created and bound together. This is only needed the
60 is created persistently.60 first time as it is created persistently. Running it when the exchange
61 already exists (to setup a second worker, or because you manually
62 created it with a different setup) is fine. The default setup is a
63 fanout exchange.
61 """)64 """)
62 description = "Load OOPS reports into oops-tools from AMQP."65 description = "Load OOPS reports into oops-tools from AMQP."
63 parser = optparse.OptionParser(66 parser = optparse.OptionParser(
@@ -70,6 +73,8 @@
70 parser.add_option('--queue', help="AMQP queue name.")73 parser.add_option('--queue', help="AMQP queue name.")
71 parser.add_option(74 parser.add_option(
72 '--bind-to', help="AMQP exchange to bind to (only needed once).")75 '--bind-to', help="AMQP exchange to bind to (only needed once).")
76 parser.add_option("-v", "--verbose", action="store_true",
77 help="Print more information about what is going on.")
73 options, args = parser.parse_args(argv[1:])78 options, args = parser.parse_args(argv[1:])
74 def needed(optname):79 def needed(optname):
75 if getattr(options, optname, None) is None:80 if getattr(options, optname, None) is None:
@@ -88,6 +93,8 @@
88 try:93 try:
89 channel = connection.channel()94 channel = connection.channel()
90 try:95 try:
96 channel.exchange_declare(
97 options.bind_to, type="fanout", durable=True, auto_delete=False)
91 channel.queue_declare(98 channel.queue_declare(
92 options.queue, durable=True, auto_delete=False)99 options.queue, durable=True, auto_delete=False)
93 channel.queue_bind(options.queue, options.bind_to)100 channel.queue_bind(options.queue, options.bind_to)
@@ -96,6 +103,10 @@
96 finally:103 finally:
97 connection.close()104 connection.close()
98 config = make_amqp_config(options.output)105 config = make_amqp_config(options.output)
106 if options.verbose:
107 def print_oops(report):
108 print ("Received %s" % report['id'])
109 config.publishers.append(print_oops)
99 receiver = oops_amqp.Receiver(config, factory, options.queue)110 receiver = oops_amqp.Receiver(config, factory, options.queue)
100 try:111 try:
101 receiver.run_forever()112 receiver.run_forever()

Subscribers

People subscribed via source and target branches

to all changes: