summaryrefslogtreecommitdiff
path: root/src/leap/common/events/__init__.py
diff options
context:
space:
mode:
authordrebs <drebs@leap.se>2013-07-24 16:26:52 -0300
committerdrebs <drebs@leap.se>2013-07-24 16:55:20 -0300
commitb7c74e4f293d0e611ea038e04022fbe700a8cb42 (patch)
treeb121ebc957b36584fdab077b3071b183776ab293 /src/leap/common/events/__init__.py
parent1f1412f3c31dfba10135ceae4641313ee48318c8 (diff)
Trying to init events server raises when given port is not free.
* Also fix and improve some tests.
Diffstat (limited to 'src/leap/common/events/__init__.py')
-rw-r--r--src/leap/common/events/__init__.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/leap/common/events/__init__.py b/src/leap/common/events/__init__.py
index d498340..388ee17 100644
--- a/src/leap/common/events/__init__.py
+++ b/src/leap/common/events/__init__.py
@@ -123,3 +123,34 @@ def signal(signal, content="", mac_method="", mac="", reqcbk=None,
:rtype: leap.common.events.events_pb2.EventsResponse or None
"""
return client.signal(signal, content, mac_method, mac, reqcbk, timeout)
+
+def ping_client(port, reqcbk=None, timeout=1000):
+ """
+ Ping a client running in C{port}.
+
+ :param port: the port in which the client should be listening
+ :type port: int
+ :param reqcbk: a callback to be called when a response from client is
+ received
+ :type reqcbk: function
+ callback(leap.common.events.events_pb2.EventResponse)
+ :param timeout: the timeout for synch calls
+ :type timeout: int
+ """
+ return client.ping(port, reqcbk=reqcbk, timeout=timeout)
+
+
+def ping_server(port=server.SERVER_PORT, reqcbk=None, timeout=1000):
+ """
+ Ping the server.
+
+ :param port: the port in which server should be listening
+ :type port: int
+ :param reqcbk: a callback to be called when a response from server is
+ received
+ :type reqcbk: function
+ callback(leap.common.events.events_pb2.EventResponse)
+ :param timeout: the timeout for synch calls
+ :type timeout: int
+ """
+ return server.ping(port, reqcbk=reqcbk, timeout=timeout)