示例#1
0
 def Open(self):
   """Set up the proxy so that it can be started."""
   try:
     self._proxy = SimpleXMLRPCServer.SimpleXMLRPCServer(
         ('localhost', self.listening_port), logRequests=False,
         allow_none=True)
   except SocketServer.socket.error as exception:
     raise errors.ProxyFailedToStart(
         u'Unable to setup a RPC server for listening to port: {0:d} with '
         u'error: {1:s}'.format(self.listening_port, exception))
示例#2
0
  def RegisterFunction(self, function_name, function):
    """Register a function to this RPC proxy.

    Args:
      function_name: The name of the proxy function.
      function: Callback method to the function providing the requested
                information.
    """
    if not self._proxy:
      raise errors.ProxyFailedToStart((
          u'Unable to register a function for a proxy that has not been set '
          u'up yet.'))
    self._proxy.register_function(function, function_name)
示例#3
0
 def StartProxy(self):
   """Start the proxy."""
   if not self._proxy:
     raise errors.ProxyFailedToStart(u'Proxy not set up yet.')
   self._proxy.serve_forever()