def setup_client jid password Connect and authorize jid xmpp protocol

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
def setup_client(jid, password):
"""
Connect and authorize.
"""
jid = xmpp.protocol.JID(jid)
client = xmpp.Client(jid.getDomain())#, debug=[])
if client.connect():
if client.auth(jid.getNode(), password):
return client
else:
raise Exception('Could not authorize.')
else:
raise Exception('Could not connect.')