Beispiel #1
0
 def __init__(self, *args, **kwargs):
     """
   Constructor
   The arguments are just passed on to InnerRPCClient.
   In practice:
     * args: has to be the service name or URL
     * kwargs: all the arguments InnerRPCClient and BaseClient accept as configuration
 """
     self.__innerRPCClient = InnerRPCClient(*args, **kwargs)
Beispiel #2
0
 def __init__( self, *args, **kwargs ):
   """
     Constructor
     The arguments are just passed on to InnerRPCClient.
     In practice:
       * args: has to be the service name or URL
       * kwargs: all the arguments InnerRPCClient and BaseClient accept as configuration
   """
   self.__innerRPCClient = InnerRPCClient( *args, **kwargs )
Beispiel #3
0
class RPCClient( object ):
  """ This class contains the mechanism to convert normal calls to RPC calls.

      When instanciated, it creates a :class:`~DIRAC.Core.DISET.private.InnerRPCClient.InnerRPCClient`
      as an attribute. Any attribute which is accessed is then either redirected to InnerRPCClient if it has it,
      or creates a MagicMethod object otherwise. If the attribute is a function, MagicMethod will
      trigger the RPC call, using the InnerRPCClient.

      The typical workflow looks like this::

        rpc = RPCClient('DataManagement/FileCatalog')

        # Here, func is the ping function, which we call remotely.
        # We go through RPCClient.__getattr__ which returns us a MagicMethod object
        func = rpc.ping

        # Here we call the method __call__ of the MagicMethod
        func()

  """


  def __init__( self, *args, **kwargs ):
    """
      Constructor
      The arguments are just passed on to InnerRPCClient.
      In practice:

        * args: has to be the service name or URL
        * kwargs: all the arguments InnerRPCClient and BaseClient accept as configuration
    """
    self.__innerRPCClient = InnerRPCClient( *args, **kwargs )


  def __doRPC( self, sFunctionName, args ):
    """
      Execute the RPC action. This is given as an attribute
      to MagicMethod

      :param sFunctionName: name of the remote function
      :param args: arguments to pass to the function
    """
    return self.__innerRPCClient.executeRPC( sFunctionName, args )



  def __getattr__( self, attrName ):
    """ Function for emulating the existance of functions.

           In literature this is usually called a "stub function".
         If the attribute exists in InnerRPCClient, return it,
         otherwise we create a _MagicMethod instance

    """
    if attrName in dir( self.__innerRPCClient ):
      return getattr( self.__innerRPCClient, attrName )
    return _MagicMethod( self.__doRPC, attrName )
Beispiel #4
0
class RPCClient( object ):
  """ This class contains the mechanism to convert normal calls to RPC calls.
      When instanciated, it creates a :any:`~DIRAC.Core.DISET.private.InnerRPCClient.InnerRPCClient` as an attribute.
      Any attribute which is accessed is then either redirected to InnerRPCClient if it has it,
      or creates a MagicMethod object otherwise. If the attribute is a function, MagicMethod will
      trigger the RPC call, using the InnerRPCClient.

      The typical workflow looks like this::

        rpc = RPCClient('DataManagement/FileCatalog')

        # Here, func is the ping function, which we call remotely.
        # We go through RPCClient.__getattr__ which returns us a MagicMethod object
        func = rpc.ping

        # Here we call the method __call__ of the MagicMethod
        func()

  """


  def __init__( self, *args, **kwargs ):
    """
      Constructor
      The arguments are just passed on to InnerRPCClient.
      In practice:
        * args: has to be the service name or URL
        * kwargs: all the arguments InnerRPCClient and BaseClient accept as configuration
    """
    self.__innerRPCClient = InnerRPCClient( *args, **kwargs )


  def __doRPC( self, sFunctionName, args ):
    """
      Execute the RPC action. This is given as an attribute
      to MagicMethod

      :param sFunctionName: name of the remote function
      :param args: arguments to pass to the function
    """
    return self.__innerRPCClient.executeRPC( sFunctionName, args )



  def __getattr__( self, attrName ):
    """ Function for emulating the existance of functions.

           In literature this is usually called a "stub function".
         If the attribute exists in InnerRPCClient, return it,
         otherwise we create a _MagicMethod instance

    """
    if attrName in dir( self.__innerRPCClient ):
      return getattr( self.__innerRPCClient, attrName )
    return _MagicMethod( self.__doRPC, attrName )
Beispiel #5
0
class RPCClient:
    def __init__(self, *args, **kwargs):
        """
    Constructor
    """
        self.__innerRPCClient = InnerRPCClient(*args, **kwargs)

    def __doRPC(self, sFunctionName, args):
        """
    Execute the RPC action
    """
        retVal = self.__innerRPCClient.executeRPC(sFunctionName, args)
        return retVal

    def __getattr__(self, attrName):
        """
    Function for emulating the existance of functions
    """
        if attrName in dir(self.__innerRPCClient):
            return getattr(self.__innerRPCClient, attrName)
        return _MagicMethod(self.__doRPC, attrName)
Beispiel #6
0
class RPCClient:

  def __init__( self, *args, **kwargs ):
    """
    Constructor
    """
    self.__innerRPCClient = InnerRPCClient( *args, **kwargs )

  def __doRPC( self, sFunctionName, args ):
    """
    Execute the RPC action
    """
    retVal = self.__innerRPCClient.executeRPC( sFunctionName, args )
    return retVal

  def __getattr__( self, attrName ):
    """
    Function for emulating the existance of functions
    """
    if attrName in dir( self.__innerRPCClient ):
      return getattr( self.__innerRPCClient, attrName )
    return _MagicMethod( self.__doRPC, attrName )
Beispiel #7
0
 def __init__( self, *args, **kwargs ):
   """
   Constructor
   """
   self.__innerRPCClient = InnerRPCClient( *args, **kwargs )
Beispiel #8
0
 def __init__(self, *args, **kwargs):
     """
 Constructor
 """
     self.__innerRPCClient = InnerRPCClient(*args, **kwargs)