Exemple #1
0
    def __init__(self, socket):
        """Create a new client.

    Args:
      socket: the socket to use for communications.
    """
        self._socket = socket
        self._channel = StreamRpcChannel(socket, self)
        self._stub = Ola_pb2.OlaServerService_Stub(self._channel)
        self._universe_callbacks = {}
Exemple #2
0
  def __init__(self, our_socket=None, close_callback=None):
    """Create a new client.

    Args:
      socket: the socket to use for communications, if not provided one is
        created.
      close_callback: A callable to run if the socket is closed
    """
    self._socket = our_socket

    if self._socket is None:
      self._socket = socket.socket()
      try:
        self._socket.connect(('localhost', 9010))
      except socket.error:
        raise OLADNotRunningException('Failed to connect to olad')

    self._close_callback = close_callback
    self._channel = StreamRpcChannel(self._socket, self, self._SocketClosed)
    self._stub = Ola_pb2.OlaServerService_Stub(self._channel)
    self._universe_callbacks = {}