Skip to content

Instantly share code, notes, and snippets.

@shawnbot
Created June 20, 2012 23:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shawnbot/2962820 to your computer and use it in GitHub Desktop.
Save shawnbot/2962820 to your computer and use it in GitHub Desktop.
SQS Queue pusher
#!/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