From 539672f9fa39dd22bb68fc50c22608aec2bdfe22 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Fri, 9 May 2008 11:15:35 +0000 Subject: Enabled PLAIN authentication and setting of username and password for 0-10 python client. Added options to all command line tools to allow a username and password to be specified. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@654759 13f79535-47bb-0310-9956-ffa450edef68 --- python/qpid/connection.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'python/qpid/connection.py') diff --git a/python/qpid/connection.py b/python/qpid/connection.py index 39f882e9c3..4ed430249b 100644 --- a/python/qpid/connection.py +++ b/python/qpid/connection.py @@ -37,6 +37,8 @@ class ChannelsBusy(Exception): pass class SessionBusy(Exception): pass +class ConnectionFailed(Exception): pass + def client(*args): return delegates.Client(*args) @@ -45,7 +47,7 @@ def server(*args): class Connection(Assembler): - def __init__(self, sock, spec=None, delegate=client): + def __init__(self, sock, spec=None, delegate=client, **args): Assembler.__init__(self, sock) if spec == None: spec = load(default()) @@ -58,13 +60,14 @@ class Connection(Assembler): self.condition = Condition() self.opened = False + self.failed = False self.thread = Thread(target=self.run) self.thread.setDaemon(True) self.channel_max = 65535 - self.delegate = delegate(self) + self.delegate = delegate(self, args) def attach(self, name, ch, delegate, force=False): self.lock.acquire() @@ -127,8 +130,10 @@ class Connection(Assembler): def start(self, timeout=None): self.delegate.start() self.thread.start() - if not wait(self.condition, lambda: self.opened, timeout): + if not wait(self.condition, lambda: self.opened or self.failed, timeout): raise Timeout() + if (self.failed): + raise ConnectionFailed() def run(self): # XXX: we don't really have a good way to exit this loop without -- cgit v1.2.1