From f4a199a300ce5f13f8e15fcd72f33073d1be2627 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Fri, 27 Nov 2015 08:16:55 +0100 Subject: [PATCH] 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. --- autopkgtest.py | 19 ++++++++++--------- run-autopkgtest | 20 ++++++++++++-------- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/autopkgtest.py b/autopkgtest.py index a4c3858..bd012a3 100644 --- a/autopkgtest.py +++ b/autopkgtest.py @@ -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: diff --git a/run-autopkgtest b/run-autopkgtest index da0ba37..ccd3a44 100755 --- a/run-autopkgtest +++ b/run-autopkgtest @@ -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)