mirror of
https://git.launchpad.net/~ubuntu-release/britney/+git/britney2-ubuntu
synced 2025-05-27 18:31:33 +00:00
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.
This commit is contained in:
parent
de339d3603
commit
f4a199a300
@ -23,11 +23,11 @@ import tarfile
|
|||||||
import io
|
import io
|
||||||
import copy
|
import copy
|
||||||
import re
|
import re
|
||||||
from urllib.parse import urlencode
|
import urllib.parse
|
||||||
from urllib.request import urlopen
|
from urllib.request import urlopen
|
||||||
|
|
||||||
import apt_pkg
|
import apt_pkg
|
||||||
import kombu
|
import amqplib.client_0_8 as amqp
|
||||||
|
|
||||||
from consts import (AUTOPKGTEST, BINARIES, DEPENDS, RDEPENDS, SOURCE, VERSION)
|
from consts import (AUTOPKGTEST, BINARIES, DEPENDS, RDEPENDS, SOURCE, VERSION)
|
||||||
|
|
||||||
@ -368,7 +368,7 @@ class AutoPackageTest(object):
|
|||||||
|
|
||||||
# request new results from swift
|
# request new results from swift
|
||||||
url = os.path.join(swift_url, 'autopkgtest-' + self.series)
|
url = os.path.join(swift_url, 'autopkgtest-' + self.series)
|
||||||
url += '?' + urlencode(query)
|
url += '?' + urllib.parse.urlencode(query)
|
||||||
try:
|
try:
|
||||||
f = urlopen(url)
|
f = urlopen(url)
|
||||||
if f.getcode() == 200:
|
if f.getcode() == 200:
|
||||||
@ -590,13 +590,14 @@ class AutoPackageTest(object):
|
|||||||
|
|
||||||
if amqp_url.startswith('amqp://'):
|
if amqp_url.startswith('amqp://'):
|
||||||
# in production mode, send them out via AMQP
|
# in production mode, send them out via AMQP
|
||||||
with kombu.Connection(amqp_url) as conn:
|
creds = urllib.parse.urlsplit(amqp_url, allow_fragments=False)
|
||||||
for arch, (queue, requests) in arch_queues.items():
|
with amqp.Connection(creds.hostname, userid=creds.username,
|
||||||
# don't use SimpleQueue here as it always declares queues;
|
password=creds.password) as amqp_con:
|
||||||
# ACLs might not allow that
|
with amqp_con.channel() as ch:
|
||||||
with kombu.Producer(conn, routing_key=queue, auto_declare=False) as p:
|
for arch, (queue, requests) in arch_queues.items():
|
||||||
for (pkg, params) in requests:
|
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://'):
|
elif amqp_url.startswith('file://'):
|
||||||
# in testing mode, adt_amqp will be a file:// URL
|
# in testing mode, adt_amqp will be a file:// URL
|
||||||
with open(amqp_url[7:], 'a') as f:
|
with open(amqp_url[7:], 'a') as f:
|
||||||
|
@ -5,8 +5,9 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
import argparse
|
import argparse
|
||||||
import json
|
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]))
|
my_dir = os.path.dirname(os.path.realpath(sys.argv[0]))
|
||||||
|
|
||||||
@ -80,11 +81,14 @@ if __name__ == '__main__':
|
|||||||
params['ppas'] = args.ppa
|
params['ppas'] = args.ppa
|
||||||
params = '\n' + json.dumps(params)
|
params = '\n' + json.dumps(params)
|
||||||
|
|
||||||
with kombu.Connection(config.adt_amqp) as conn:
|
creds = urllib.parse.urlsplit(config.adt_amqp, allow_fragments=False)
|
||||||
for arch in args.architecture:
|
assert creds.scheme == 'amqp'
|
||||||
# don't use SimpleQueue here as it always declares queues;
|
|
||||||
# ACLs might not allow that
|
with amqp.Connection(creds.hostname, userid=creds.username,
|
||||||
with kombu.Producer(conn, routing_key='debci-%s-%s' % (args.series, arch),
|
password=creds.password) as amqp_con:
|
||||||
auto_declare=False) as p:
|
with amqp_con.channel() as ch:
|
||||||
|
for arch in args.architecture:
|
||||||
|
queue = 'debci-%s-%s' % (args.series, arch)
|
||||||
for pkg in args.package:
|
for pkg in args.package:
|
||||||
p.publish(pkg + params)
|
ch.basic_publish(amqp.Message(pkg + params),
|
||||||
|
routing_key=queue)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user