back to previous xmlstream.py
print an error when we try to connect an inexisting server instead of crash
This commit is contained in:
parent
223b72d463
commit
9e378977f8
14
Core/core.py
14
Core/core.py
|
@ -511,6 +511,7 @@ class GajimCore:
|
||||||
self.hub.sendPlugin('ROSTER_INFO', self.connections[con], (jid, name, sub, ask, groups))
|
self.hub.sendPlugin('ROSTER_INFO', self.connections[con], (jid, name, sub, ask, groups))
|
||||||
|
|
||||||
def BrowseResultCB(self, con, iq_obj):
|
def BrowseResultCB(self, con, iq_obj):
|
||||||
|
print "*************** ICI ************"
|
||||||
identities, features, items = [], [], []
|
identities, features, items = [], [], []
|
||||||
q = iq_obj.getTag('service')
|
q = iq_obj.getTag('service')
|
||||||
if not q:
|
if not q:
|
||||||
|
@ -546,6 +547,11 @@ class GajimCore:
|
||||||
self.hub.sendPlugin('AGENT_INFO_ITEMS', self.connections[con],\
|
self.hub.sendPlugin('AGENT_INFO_ITEMS', self.connections[con],\
|
||||||
(jid, items))
|
(jid, items))
|
||||||
|
|
||||||
|
def DiscoverInfoErrorCB(self, con, iq_obj):
|
||||||
|
print " ERROR *************"
|
||||||
|
jid = str(iq_obj.getFrom())
|
||||||
|
con.browseAgents(jid)
|
||||||
|
|
||||||
def DiscoverInfoCB(self, con, iq_obj):
|
def DiscoverInfoCB(self, con, iq_obj):
|
||||||
# According to JEP-0030:
|
# According to JEP-0030:
|
||||||
# For identity: category, name is mandatory, type is optional.
|
# For identity: category, name is mandatory, type is optional.
|
||||||
|
@ -617,6 +623,8 @@ class GajimCore:
|
||||||
common.jabber.NS_P_DISC_ITEMS)
|
common.jabber.NS_P_DISC_ITEMS)
|
||||||
con.registerHandler('iq',self.DiscoverInfoCB,'result', \
|
con.registerHandler('iq',self.DiscoverInfoCB,'result', \
|
||||||
common.jabber.NS_P_DISC_INFO)
|
common.jabber.NS_P_DISC_INFO)
|
||||||
|
con.registerHandler('iq',self.DiscoverInfoErrorCB,'error', \
|
||||||
|
common.jabber.NS_P_DISC_INFO)
|
||||||
try:
|
try:
|
||||||
con.connect()
|
con.connect()
|
||||||
except IOError, e:
|
except IOError, e:
|
||||||
|
@ -903,8 +911,10 @@ class GajimCore:
|
||||||
log = None, proxy = proxy)
|
log = None, proxy = proxy)
|
||||||
try:
|
try:
|
||||||
c.connect()
|
c.connect()
|
||||||
except IOError, e:
|
except:
|
||||||
log.debug("Couldn't connect to %s %s" % (hostname, e))
|
log.debug("Couldn't connect to %s" % ev[2][0])
|
||||||
|
self.hub.sendPlugin('ERROR', None, \
|
||||||
|
_('Couldn\'t connect to ')+ev[2][0])
|
||||||
return 0
|
return 0
|
||||||
else:
|
else:
|
||||||
log.debug("Connected to server")
|
log.debug("Connected to server")
|
||||||
|
|
|
@ -465,10 +465,7 @@ class Client(Stream):
|
||||||
if self._proxy: self._sock.connect((self._proxy['host'], self._proxy['port']))
|
if self._proxy: self._sock.connect((self._proxy['host'], self._proxy['port']))
|
||||||
else: self._sock.connect((self._hostIP, self._port))
|
else: self._sock.connect((self._hostIP, self._port))
|
||||||
except socket.error, e:
|
except socket.error, e:
|
||||||
self.DEBUG("socket error: "+str(e), DBG_CONN_ERROR)
|
self.DEBUG("socket error: "+str(e),DBG_CONN_ERROR)
|
||||||
raise
|
|
||||||
except socket.gaierror, e:
|
|
||||||
self.DEBUG("socket error: "+str(e), DBG_CONN_ERROR)
|
|
||||||
raise
|
raise
|
||||||
|
|
||||||
if self._connection == TCP_SSL:
|
if self._connection == TCP_SSL:
|
||||||
|
|
Loading…
Reference in New Issue