From 1141edf676c7ba8ecd0a0b7c98f02175fb5329b2 Mon Sep 17 00:00:00 2001 From: Piotr Maslanka <piotr.maslanka@henrietta.com.pl> Date: Tue, 10 Jan 2017 20:26:30 +0100 Subject: [PATCH] more forgiving NodeDefinition --- coolamqp/objects.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/coolamqp/objects.py b/coolamqp/objects.py index 064f228..9f86359 100644 --- a/coolamqp/objects.py +++ b/coolamqp/objects.py @@ -279,6 +279,8 @@ class NodeDefinition(object): or a = NodeDefinition('amqp://user:password@host:port/virtual_host', hearbeat=20) + + AMQP connection string may be either bytes or str/unicode Additional keyword parameters that can be specified: @@ -302,9 +304,14 @@ class NodeDefinition(object): self.virtual_host = '/' elif len(args) == 4: self.host, self.user, self.password, self.virtual_host = args - elif len(args) == 1 and isinstance(args[0], six.text_type): + elif len(args) == 1 and isinstance(args[0], (six.text_type, six.binary_type)): + + if isinstance(args[0], six.binary_type): + connstr = args[0].decode('utf8') + else: + connstr = args[0] + # AMQP connstring - connstr = args[0] if not connstr.startswith(u'amqp://'): raise ValueError(u'should begin with amqp://') -- GitLab