Move from kombu to amqplib

python3-amqplib already exists in trusty, but python3-kombu does not. This
makes it possible to run britney on a standard trusty without manual backports.
bzr-import-20160707
Martin Pitt 9 years ago
parent de339d3603
commit f4a199a300

@ -23,11 +23,11 @@ import tarfile
import io
import copy
import re
from urllib.parse import urlencode
import urllib.parse
from urllib.request import urlopen
import apt_pkg
import kombu
import amqplib.client_0_8 as amqp
from consts import (AUTOPKGTEST, BINARIES, DEPENDS, RDEPENDS, SOURCE, VERSION)
@ -368,7 +368,7 @@ class AutoPackageTest(object):
# request new results from swift
url = os.path.join(swift_url, 'autopkgtest-' + self.series)
url += '?' + urlencode(query)
url += '?' + urllib.parse.urlencode(query)
try:
f = urlopen(url)
if f.getcode() == 200:
@ -590,13 +590,14 @@ class AutoPackageTest(object):
if amqp_url.startswith('amqp://'):
# in production mode, send them out via AMQP
with kombu.Connection(amqp_url) as conn:
for arch, (queue, requests) in arch_queues.items():
# don't use SimpleQueue here as it always declares queues;
# ACLs might not allow that
with kombu.Producer(conn, routing_key=queue, auto_declare=False) as p:
creds = urllib.parse.urlsplit(amqp_url, allow_fragments=False)
with amqp.Connection(creds.hostname, userid=creds.username,
password=creds.password) as amqp_con:
with amqp_con.channel() as ch:
for arch, (queue, requests) in arch_queues.items():
for (pkg, params) in requests:
p.publish(pkg + '\n' + params)
ch.basic_publish(amqp.Message(pkg + '\n' + params),
routing_key=queue)
elif amqp_url.startswith('file://'):
# in testing mode, adt_amqp will be a file:// URL
with open(amqp_url[7:], 'a') as f:

@ -5,8 +5,9 @@ import os
import sys
import argparse
import json
import urllib.parse
import kombu
import amqplib.client_0_8 as amqp
my_dir = os.path.dirname(os.path.realpath(sys.argv[0]))
@ -80,11 +81,14 @@ if __name__ == '__main__':
params['ppas'] = args.ppa
params = '\n' + json.dumps(params)
with kombu.Connection(config.adt_amqp) as conn:
for arch in args.architecture:
# don't use SimpleQueue here as it always declares queues;
# ACLs might not allow that
with kombu.Producer(conn, routing_key='debci-%s-%s' % (args.series, arch),
auto_declare=False) as p:
creds = urllib.parse.urlsplit(config.adt_amqp, allow_fragments=False)
assert creds.scheme == 'amqp'
with amqp.Connection(creds.hostname, userid=creds.username,
password=creds.password) as amqp_con:
with amqp_con.channel() as ch:
for arch in args.architecture:
queue = 'debci-%s-%s' % (args.series, arch)
for pkg in args.package:
p.publish(pkg + params)
ch.basic_publish(amqp.Message(pkg + params),
routing_key=queue)

Loading…
Cancel
Save