diff options
author | Lance Stout <lancestout@gmail.com> | 2013-01-21 02:34:22 -0800 |
---|---|---|
committer | Lance Stout <lancestout@gmail.com> | 2013-01-21 02:34:22 -0800 |
commit | bad405bea96405eb952888dc6996b8b40be85ac4 (patch) | |
tree | b5998707d5d8d836eaa807f1e755047c1aed5c48 /examples/ping.py | |
parent | 648f3f978a84445ed188be055453ac4cab3ed4f5 (diff) | |
parent | 4f9a95b011277ab64a137aceeb4df2e9fc0f1e25 (diff) | |
download | slixmpp-bad405bea96405eb952888dc6996b8b40be85ac4.tar.gz slixmpp-bad405bea96405eb952888dc6996b8b40be85ac4.tar.bz2 slixmpp-bad405bea96405eb952888dc6996b8b40be85ac4.tar.xz slixmpp-bad405bea96405eb952888dc6996b8b40be85ac4.zip |
Merge branch 'master' into develop
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() |