Пример #1
0
    def ConfigureDevice(self, device_alias, request_data, callback):
        """Send a device config request.

    Args:
      device_alias: the alias of the device to configure
      request_data: the request to send to the device
      callback: The function to call once complete, takes two arguments, a
        RequestStatus object and a response.

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

        controller = SimpleRpcController()
        request = Ola_pb2.DeviceConfigRequest()
        request.device_alias = device_alias
        request.data = request_data
        done = lambda x, y: self._ConfigureDeviceComplete(callback, x, y)
        try:
            self._stub.ConfigureDevice(controller, request, done)
        except socket.error:
            raise OLADNotRunningException()
        return True
Пример #2
0
    def ConfigureDevice(self, device_alias, request_data, callback):
        """Send a device config request.

    Args:
      device_alias: the alias of the device to configure
      request_data: the request to send to the device
      callback: The function to call once complete, takes two arguments, a
        RequestStatus object and a response.
    """
        controller = SimpleRpcController()
        request = Ola_pb2.DeviceConfigRequest()
        request.device_alias = device_alias
        request.data = request_data
        done = lambda x, y: self._ConfigureDeviceComplete(callback, x, y)
        self._stub.ConfigureDevice(controller, request, done)