diff options
author | Lance Stout <lancestout@gmail.com> | 2013-01-20 20:14:16 -0800 |
---|---|---|
committer | Lance Stout <lancestout@gmail.com> | 2013-01-20 20:14:16 -0800 |
commit | 3423589ba1fc2a6284bf3e4bd7402f1e80fff275 (patch) | |
tree | 0873c1973c170da60bc5a9c597a13d9a65efbe59 /examples/ping.py | |
parent | 1f9286d39e70ef737232522ad7343ff730e9c518 (diff) | |
download | slixmpp-3423589ba1fc2a6284bf3e4bd7402f1e80fff275.tar.gz slixmpp-3423589ba1fc2a6284bf3e4bd7402f1e80fff275.tar.bz2 slixmpp-3423589ba1fc2a6284bf3e4bd7402f1e80fff275.tar.xz slixmpp-3423589ba1fc2a6284bf3e4bd7402f1e80fff275.zip |
Updated XEP-0199 to take and return standardized values.
Handles Iq errors appropriately when the recipient can't be found.
Diffstat (limited to 'examples/ping.py')
-rwxr-xr-x | examples/ping.py | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/examples/ping.py b/examples/ping.py index 0e53b1dd..8fbb5655 100755 --- a/examples/ping.py +++ b/examples/ping.py @@ -62,16 +62,18 @@ class PingTest(sleekxmpp.ClientXMPP): """ self.send_presence() self.get_roster() - result = self['xep_0199'].send_ping(self.pingjid, - timeout=10, - errorfalse=True) - logging.info("Pinging...") - if result is False: - logging.info("Couldn't ping.") - self.disconnect() - sys.exit(1) - else: - logging.info("Success! RTT: %s", str(result)) + + try: + rtt = self['xep_0199'].ping(self.pingjid, + timeout=10) + logging.info("Success! RTT: %s", rtt) + except IqError as e: + logging.info("Error pinging %s: %s", + self.pingjid, + e.iq['error']['condition']) + except IqTimeout: + logging.info("No response from %s", self.pingjid) + finally: self.disconnect() |