API Reference for Enthought Tool Suite 3.2.0
Powerful utility for running a TCP/UDP server that is used to script Mayavi2 from the network. This uses Twisted. This particular version has been written for the wxPython, adding support for a Qt4 version should be trivial.
The key functions exposed are:
serve_tcp(...) serve_udp(...)
See the function documentation for more information. Here is sample usage:
from enthought.mayavi import mlab from enthought.mayavi.tools import server mlab.test_plot3d() server.serve_tcp()
The TCP server will listen on port 8007 by default in the above. Any data sent to the server is simply exec'd, meaning you can do pretty much anything you want. The engine, scene, camera and mlab are all available and can be used. For example after running the above you can do this:
$ telnet localhost 8007 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. scene.camera.azimuth(45) mlab.clf() mlab.test_contour3d() scene.camera.zoom(1.5)
The nice thing about this is that you do not loose any interactivity of your app and can continue to use its UI as before, any network commands will be simply run on top of this.
Warning while this is very powerful it is also a huge security hole since the remote user can do pretty much anything they want.
Serve the M2TCP protocol using the given engine on the specified port logging messages to given logto which is a file-like object. This function will block till the service is closed. There is no need to call mlab.show() after or before this. The Mayavi UI will be fully responsive.
Parameters
engine: Mayavi engine to use. If this is None, mlab.get_engine() is used to find an appropriate engine. port: int: port to serve on. logto: file: File like object to log messages to. If this is None it disables logging. max_connect: int: Maximum number of simulataneous connections to support.
Examples
Here is a very simple example:
from enthought.mayavi import mlab from enthought.mayavi.tools import server mlab.test_plot3d() server.serve_tcp()
The TCP server will listen on port 8007 by default in the above. Any data sent to the server is simply exec'd, meaning you can do pretty much anything you want. The engine, scene, camera and mlab are all available and can be used. For example after running the above you can do this:
$ telnet localhost 8007 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. scene.camera.azimuth(45) mlab.clf() mlab.test_contour3d() scene.camera.zoom(1.5)
Warning
Data sent is exec'd so this is a security hole.
Serve the M2UDP protocol using the given engine on the specified port logging messages to given logto which is a file-like object. This function will block till the service is closed. There is no need to call mlab.show() after or before this. The Mayavi UI will be fully responsive.
Parameters
engine: Mayavi engine to use. If this is None, mlab.get_engine() is used to find an appropriate engine. port: int: port to serve on. logto: file : File like object to log messages to. If this is None it disables logging.
Examples
Here is a very simple example:
from enthought.mayavi import mlab from enthought.mayavi.tools import server mlab.test_plot3d() server.serve_udp()
Test it like so:
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.bind(('', 9008))
s.sendto('camera.azimuth(10)', ('', 9007))
Warning
Data sent is exec'd so this is a security hole.
Simple test for the TCP server.
Simple test for the UDP server.
| Local name | Refers to |
|---|---|
| DatagramProtocol | twisted.internet.protocol.DatagramProtocol |
| Factory | twisted.internet.protocol.Factory |
| log | twisted.python.log |
| Protocol | twisted.internet.protocol.Protocol |
| reactor | twisted.internet.reactor |
| sys | sys |
| wx | wx |
| wxreactor | twisted.internet.wxreactor |
© Copyright 2002-2009 Enthought, Inc.