2 # -*- coding: utf-8 -*-
4 # Inject one or more mbox of email, or a single email into the system.
6 # ./inject-mbox.py mbox [mbox ...]
7 # ./inject-mbox.py < single_email
9 # Note that if you inject the same message or message threads twice,
10 # then they are processed twice. patchq does not deduplicate.
12 # This script will inject anything that looks similar enough to an
13 # email, even non-patches, cover letters, etc. The ‘threader.py’
14 # script filters out non-patches.
22 connection = pika.BlockingConnection(pika.ConnectionParameters(
23 host = config.mq_server))
24 channel = connection.channel()
31 print("Injecting %s" % m['Subject'])
33 channel.basic_publish(exchange = 'patchq_input',
36 processed = processed+1
38 # Read from mboxes passed on the command line, or read a single
41 for arg in sys.argv[1:]:
42 mbox = mailbox.mbox(arg)
46 m = email.message_from_file(sys.stdin)
49 print ("Processed %d email(s)." % processed)