Merge branch 'master' into develop
This commit is contained in:
commit
14aa831169
@ -15,6 +15,7 @@ import getpass
|
|||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
|
|
||||||
import sleekxmpp
|
import sleekxmpp
|
||||||
|
from sleekxmpp.exceptions import IqError, IqTimeout
|
||||||
|
|
||||||
|
|
||||||
# Python versions before 3.0 do not use UTF-8 encoding
|
# Python versions before 3.0 do not use UTF-8 encoding
|
||||||
@ -83,6 +84,7 @@ class Disco(sleekxmpp.ClientXMPP):
|
|||||||
self.get_roster()
|
self.get_roster()
|
||||||
self.send_presence()
|
self.send_presence()
|
||||||
|
|
||||||
|
try:
|
||||||
if self.get in self.info_types:
|
if self.get in self.info_types:
|
||||||
# By using block=True, the result stanza will be
|
# By using block=True, the result stanza will be
|
||||||
# returned. Execution will block until the reply is
|
# returned. Execution will block until the reply is
|
||||||
@ -92,7 +94,7 @@ class Disco(sleekxmpp.ClientXMPP):
|
|||||||
info = self['xep_0030'].get_info(jid=self.target_jid,
|
info = self['xep_0030'].get_info(jid=self.target_jid,
|
||||||
node=self.target_node,
|
node=self.target_node,
|
||||||
block=True)
|
block=True)
|
||||||
if self.get in self.items_types:
|
elif self.get in self.items_types:
|
||||||
# The same applies from above. Listen for the
|
# The same applies from above. Listen for the
|
||||||
# disco_items event or pass a callback function
|
# disco_items event or pass a callback function
|
||||||
# if you need to process a non-blocking request.
|
# if you need to process a non-blocking request.
|
||||||
@ -101,9 +103,12 @@ class Disco(sleekxmpp.ClientXMPP):
|
|||||||
block=True)
|
block=True)
|
||||||
else:
|
else:
|
||||||
logging.error("Invalid disco request type.")
|
logging.error("Invalid disco request type.")
|
||||||
self.disconnect()
|
|
||||||
return
|
return
|
||||||
|
except IqError as e:
|
||||||
|
logging.error("Entity returned an error: %s" % e.iq['error']['condition'])
|
||||||
|
except IqTimeout:
|
||||||
|
logging.error("No response received.")
|
||||||
|
else:
|
||||||
header = 'XMPP Service Discovery: %s' % self.target_jid
|
header = 'XMPP Service Discovery: %s' % self.target_jid
|
||||||
print(header)
|
print(header)
|
||||||
print('-' * len(header))
|
print('-' * len(header))
|
||||||
@ -125,7 +130,7 @@ class Disco(sleekxmpp.ClientXMPP):
|
|||||||
print('Items:')
|
print('Items:')
|
||||||
for item in items['disco_items']['items']:
|
for item in items['disco_items']['items']:
|
||||||
print(' - %s' % str(item))
|
print(' - %s' % str(item))
|
||||||
|
finally:
|
||||||
self.disconnect()
|
self.disconnect()
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user