diff options
author | mathieui <mathieui@mathieui.net> | 2015-02-24 18:58:40 +0100 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2015-02-24 22:47:15 +0100 |
commit | c66a4d4097a249efc029b761d6150378a54bf702 (patch) | |
tree | b25d5872f0ab8036c8b05b4207b03163f4bc7868 /examples/disco_browser.py | |
parent | e112e864756f1222a044ee28e3c13c5925618b0c (diff) | |
download | slixmpp-c66a4d4097a249efc029b761d6150378a54bf702.tar.gz slixmpp-c66a4d4097a249efc029b761d6150378a54bf702.tar.bz2 slixmpp-c66a4d4097a249efc029b761d6150378a54bf702.tar.xz slixmpp-c66a4d4097a249efc029b761d6150378a54bf702.zip |
Update the documentation and examples
- update most of the examples with slixmpp
- change the help channels pointed out in the doc
- add a page listing differences from slixmpp and how to use asyncio
nicely with slixmpp
- fix some in-code rst documentation
Diffstat (limited to 'examples/disco_browser.py')
-rwxr-xr-x | examples/disco_browser.py | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/examples/disco_browser.py b/examples/disco_browser.py index 33134c99..796562f2 100755 --- a/examples/disco_browser.py +++ b/examples/disco_browser.py @@ -15,6 +15,7 @@ from argparse import ArgumentParser import slixmpp from slixmpp.exceptions import IqError, IqTimeout +from slixmpp.xmlstream.asyncio import asyncio class Disco(slixmpp.ClientXMPP): @@ -53,6 +54,7 @@ class Disco(slixmpp.ClientXMPP): # our roster. self.add_event_handler("session_start", self.start) + @asyncio.coroutine def start(self, event): """ Process the session_start event. @@ -79,17 +81,17 @@ class Disco(slixmpp.ClientXMPP): # received. Non-blocking options would be to listen # for the disco_info event, or passing a handler # function using the callback parameter. - info = self['xep_0030'].get_info(jid=self.target_jid, - node=self.target_node, - block=True) - elif self.get in self.items_types: + info = yield from self['xep_0030'].get_info(jid=self.target_jid, + node=self.target_node, + coroutine=True) + if self.get in self.items_types: # The same applies from above. Listen for the # disco_items event or pass a callback function # if you need to process a non-blocking request. - items = self['xep_0030'].get_items(jid=self.target_jid, - node=self.target_node, - block=True) - else: + items = yield from self['xep_0030'].get_items(jid=self.target_jid, + node=self.target_node, + coroutine=True) + if self.get not in self.info_types and self.get not in self.items_types: logging.error("Invalid disco request type.") return except IqError as e: @@ -143,7 +145,7 @@ if __name__ == '__main__': parser.add_argument("-p", "--password", dest="password", help="password to use") parser.add_argument("query", choices=["all", "info", "items", "identities", "features"]) - parser.add_argument("target-jid") + parser.add_argument("target_jid") parser.add_argument("node", nargs='?') args = parser.parse_args() |