Created
November 16, 2012 05:06
-
-
Save amitsaha/4084294 to your computer and use it in GitHub Desktop.
Naive Consumer of Fedora Infra Bus
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# Naive consuming, courtesy: threebean | |
# http://fedmsg.readthedocs.org/en/latest/consuming/#naive-consuming | |
import fedmsg | |
config = fedmsg.config.load_config([], None) | |
# Disable that warning about not sending. We know. We only want to tail. | |
config['mute'] = True | |
# Disable timing out so that we can tail forever. This is deprecated and will | |
# disappear in future versions. | |
config['timeout'] = 0 | |
with open('messages','w') as f: | |
for name, endpoint, topic, msg in fedmsg.tail_messages(**config): | |
print name, topic, msg # or use fedmsg.encoding.pretty_dumps(msg) | |
f.write(name + ':' + topic + '\n') | |
f.write(str(msg) + '\n') | |
f.write('\n') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment