summaryrefslogtreecommitdiff
path: root/examples/ping.py
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2015-02-24 18:58:40 +0100
committermathieui <mathieui@mathieui.net>2015-02-24 22:47:15 +0100
commitc66a4d4097a249efc029b761d6150378a54bf702 (patch)
treeb25d5872f0ab8036c8b05b4207b03163f4bc7868 /examples/ping.py
parente112e864756f1222a044ee28e3c13c5925618b0c (diff)
downloadslixmpp-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/ping.py')
-rwxr-xr-xexamples/ping.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/examples/ping.py b/examples/ping.py
index 06b03c51..39118ac4 100755
--- a/examples/ping.py
+++ b/examples/ping.py
@@ -12,6 +12,8 @@
import logging
from getpass import getpass
from argparse import ArgumentParser
+from slixmpp.exceptions import IqError, IqTimeout
+from slixmpp import asyncio
import slixmpp
@@ -36,6 +38,7 @@ class PingTest(slixmpp.ClientXMPP):
# our roster.
self.add_event_handler("session_start", self.start)
+ @asyncio.coroutine
def start(self, event):
"""
Process the session_start event.
@@ -53,8 +56,8 @@ class PingTest(slixmpp.ClientXMPP):
self.get_roster()
try:
- rtt = self['xep_0199'].ping(self.pingjid,
- timeout=10)
+ rtt = yield from self['xep_0199'].ping(self.pingjid,
+ timeout=10)
logging.info("Success! RTT: %s", rtt)
except IqError as e:
logging.info("Error pinging %s: %s",
@@ -78,8 +81,7 @@ if __name__ == '__main__':
action="store_const", dest="loglevel",
const=logging.DEBUG, default=logging.INFO)
parser.add_argument("-t", "--pingto", help="set jid to ping",
- action="store", type="string", dest="pingjid",
- default=None)
+ dest="pingjid", default=None)
# JID and password options.
parser.add_argument("-j", "--jid", dest="jid",