Пример #1
0
 def create_empty_remote_proxy(self):
     """Creates empty :class:`.remoteproxies._RemoteProxy`. See
     :meth:`.create_empty_recursive_proxy`.
     """
     return _RemoteProxy(session=self,
                         remote_name=None,
                         is_remote_owned=False)
Пример #2
0
    def get_proxy_object(self, remote_object, local_spec):
        """Creates a proxy object for remote_object.

        **Args:**

        *remote_object*:  the name of the remote object to proxy.

        *local_spec*: a local class object, used to determine which methods
                      are available on the remote object. If None, the spec
                      is determined dynamically.

        Any method calls and attribute requests for the proxy object
        will be executed remotely on remote_object.

        Calling as_recursive_proxy on the proxy object creates a new
        :class:`.remoteproxies._RecursiveProxy` for the proxied object.

        Example:

            >>> RunnerSession.run_python("a = open('test')")
            >>> proxy = RunnerTerminal.get_proxy_object('a', file)
            >>> proxy.readlines() # same as run_python("a.readlines()")
        """
        return _RemoteProxy(self,
                            remote_object,
                            local_spec,
                            is_remote_owned=False)
Пример #3
0
    def get_proxy_object_from_call(self, function_name, *args, **kwargs):
        """Calls a remote function, and proxies the return value.

        The call is done as in :meth:`.run_python`, but the return value
        is a :class:`.remoteproxies._RemoteProxy` for the remote return value.
        """
        handle = self._get_random_handle_name()

        python_call = self._get_python_call(function_name, args, kwargs)

        self.run_python("{handle} = {call}".format(handle=handle,
                                                   call=python_call))

        return _RemoteProxy(self, handle)
Пример #4
0
 def _get_proxy_or_basic(self, handle, response):
     return response.obj if response.isobj else _RemoteProxy(self, handle)