Create a Pushy connection.
Parameters: |
|
---|
Some transports will require additional information to create a connection, such as a username and password. To support this, all keyword arguments are passed through to the transport’s pushy.transport.Popen() function. The address component of target is passed to the Popen function with the name address. For details on the keyword arguments expected by the builtin transports, see pushy.transport.
This class is instantiated by pushy.connect(), and is the primary interface for interacting with the remote interpreter. It provides methods for evaluating Python expressions, copying files between local and remote hosts, and for obtaining references to Python modules in the remote interpreter.
Provides access to the remote interpreter’s modules. Accessing an attribute of modules is equivalent to importing a module.
>>> conn = pushy.connect("local:")
>>> conn.modules.os
<module 'os' from 'C:\Python26\lib\os.pyc'>
>>> os.getpid()
4772
>>> conn.modules.os.getpid()
5564
Boolean flag to specify whether proxies should be garbage collected or not. Disabling garbage collection may improve the speed of Pushy, at the cost of memory growth as new objects are proxied. Garbage collection is enabled by default.
Time in seconds between reconciliation of garbage collected objects.
If gc_enabled is set to True, then object proxies may be garbage collected. When object proxies are garbage collected, their remote counterpart must be also be deleted (reconciled). The garbage collection process will enqueue deletions and, after gc_interval seconds have elapsed since the previous remote-deletion, send a message to the peer to delete the objects enqueued by the garbage collector. The default garbage collection interval is five seconds.
Close the connection.
>>> conn = pushy.connect("local:")
>>> conn.close()
Compiles Python source or function objects in the remote Python interpreter, returning proxied code objects or function objects respectively.
Parameters: |
|
---|
>>> conn = pushy.connect("local:")
>>> conn.compile("1+2", "eval") # Returns a code object.
>>> conn.compile(lambda a, b: a + b) # Returns a function object.
Evaluate an expression or code object in the remote Python interpreter.
Parameters: |
|
---|
>>> conn = pushy.connect("local:")
>>> assert conn.eval("1+2") == 3
>>> remote_str_type = conn.eval("str")
Executes Python source code in the remote interpreter. This is a shortcut to eval(compile(source), globals, locals).
Parameters: |
|
---|
>>> conn = pushy.connect("local:")
>>> locals_ = {}
>>> conn.execute("def abc():\n\tprint 123", locals=locals_)
>>> locals_["abc"]()
123
Copy a file from the remote host to the local host. If the transport class defines a getfile method, that will be used to perform the transfer. Otherwise, Pushy will fall back to a relatively inefficient, transport-independent method.
>>> conn = pushy.connect("local:")
>>> conn.getfile("/remote/path/to/foo.txt", "/local/path/to/bar.txt")
Copy a file from the local host to the remote host. If the transport class defines a putfile method, that will be used to perform the transfer. Otherwise, Pushy will fall back to a relatively inefficient, transport-independent method.
>>> conn = pushy.connect("local:")
>>> conn.putfile("/local/path/to/foo.txt", "/remote/path/to/bar.txt")