Created
June 20, 2012 23:09
-
-
Save shawnbot/2962820 to your computer and use it in GitHub Desktop.
SQS Queue pusher
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 | |
import optparse | |
parser = optparse.OptionParser(usage="%prog -k KEY -s SECRET -q QUEUE msg msg msg") | |
parser.add_option("--key", "-k", dest="key") | |
parser.add_option("--secret", "-s", dest="secret") | |
parser.add_option("--queue", "-q", dest="queue") | |
options, args = parser.parse_args() | |
from boto.sqs.connection import SQSConnection | |
from boto.sqs.message import Message | |
conn = SQSConnection(options.key, options.secret) | |
q = conn.create_queue(options.queue) | |
written = 0 | |
for url in args: | |
msg = Message() | |
msg.set_body(url) | |
status = q.write(msg) | |
if status: | |
written += 1 | |
print "Queued %d message(s)." % written |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment