예제 #1
0
파일: OlaClient.py 프로젝트: swgrainger/ola
    def GetCandidatePorts(self, callback, universe=None):
        """Send a GetCandidatePorts request. The result is similar to FetchDevices
    (GetDeviceInfo), except that returned devices will only contain ports
    available for patching to the given universe. If universe is None, then the
    devices will list their ports available for patching to a potential new
    universe.

    Args:
      callback: The function to call once complete, takes a RequestStatus
        object and a list of Device objects.
      universe: The universe to get the candidate ports for. If unspecified,
        return the candidate ports for a new universe.

    Returns:
      True if the request was sent, False otherwise.
    """
        if self._socket is None:
            return False

        controller = SimpleRpcController()
        request = Ola_pb2.OptionalUniverseRequest()

        if universe is not None:
            request.universe = universe

        # GetCandidatePorts works very much like GetDeviceInfo, so we can re-use
        # its complete method.
        done = lambda x, y: self._DeviceInfoComplete(callback, x, y)
        try:
            self._stub.GetCandidatePorts(controller, request, done)
        except socket.error:
            raise OLADNotRunningException()

        return True
예제 #2
0
파일: OlaClient.py 프로젝트: swgrainger/ola
    def FetchUniverses(self, callback):
        """Fetch a list of universes from the server

    Args:
      callback: The function to call once complete, takes two arguments, a
        RequestStatus object and a list of Universe objects.

    Returns:
      True if the request was sent, False otherwise.
    """
        if self._socket is None:
            return False

        controller = SimpleRpcController()
        request = Ola_pb2.OptionalUniverseRequest()
        done = lambda x, y: self._UniverseInfoComplete(callback, x, y)
        try:
            self._stub.GetUniverseInfo(controller, request, done)
        except socket.error:
            raise OLADNotRunningException()
        return True