[Twisted-Python] Nebula Python Integration

Jason L. Asbahr jasbahr at crash.org
Fri Nov 30 15:50:15 EST 2001

Hey, Twisters,

Just wanted to share some news regarding work I've been doing on the 
open source 3D engine, Nebula.  Nebula supports OpenGL on Linux and 
D3D and OpenGL on Windows currently, and will support OpenGL on 
Mac OS X shortly.

Nebula is the chosen client for my open source MMP project, Netsu.

The main Nebula site:  http://www.radonlabs.de/
The Nebula Sourceforge site:  http://sourceforge.net/projects/nebuladevice/

Jason Asbahr
jason at asbahr.com


[ Begin Forward ]

Nebula now has Python support!  It's checked into CVS and has been 
tested on Win32 and Linux.  Please let me know if you run into any 
difficulties with it, or do anything cool with it.

This release exposes the base-level Nebula functions to Python, a
future release will provide Python developers with an object-oriented
interface to Nebula.

Next up: Python tekdemos.




Python Integration Documentation 
Created 2001, by Jason L. Asbahr, jason at asbahr.com


npython is an extension which integrates Python into the 
Nebula Device and exposes the functionality of Nebula to Python.
npython can be invoked from inside the standard Nebula utilities
nsh and gfxserv, in addition, npython can be imported directly 
into Python as an extension module.

To Build

- Copy nebula/code/src/python/npython.epk up one directory to 
- Execute updsrc.tcl to build makefiles.
- Compile with 'make' or DevStudio

To Use

- To use Python in the Nebula utilities:
  nsh -script npythonserver
  gfxserv -script npythonserver

- To use Nebula from Python, simply:
  >>> import npython


npython currently exposes a set of functions to manipulate and control
the Nebula Device.  All functions take arguments formated as strings.

NOTE:  These commands are based on those commands available via Tcl, 
       with a couple differences.  For example, 'dir' has been renamed
       'ndir', and a new command 'set' has been introduced to allow
       invocation of methods on Nebula objects.

new( [class], [path] )
    Create a new object of class [class] with the name
    [path]. Name may be any valid path, missing path
    components will be filled up with 'nroot' objects.
    Returns the complete path name of the new object.

delete( [path] )
    Delete the object with name [path] and all of it's
    sub objects.

    List contents of current 'directory'.

sel( [path] )
    Make the object defined by [path] the current object.
    Returns the complete path of the selected object.
    Returns the full path of the currently selected object.

exists( [path] )
    Check whether object exists. Return "1" if yes,
    return "0" if no.

get( [script] )
    Read a serialized object from the 'real' filesystem.
    The serialized object must have been created with
    the '.save' or '.saveas' object command.
    Returns the full path of the created object.

server( [portname] )
    Leave interactive mode and go into server mode by
    creating an ipc port. In server mode, npython will 
    wait for other Nebula apps to connect and execute any
    incoming commands on the local objects. 

connect( [hostname:portname] )
    Connect to another Nebula application in server mode.
    The remote app may be on the same machine (in this
    case you can omit the leading 'hostname:'), or
    on another machine. Communication will go through
    TCP/IP sockets. 'hostname' is any valid TCP/IP address
    in the form of 'ww.xx.yy.zz', or a machine name that
    can be resolved into a numerical tcp/ip address.

    Disconnect from a server.

    End the npython session (can also be used to shutdown 
    a remote server when in connected state).

Simple Example

new('nroot', 'myObject')

    This will create a new object of class 'nroot' which has the
    name 'myObject'. 


    This makes 'myObject' the current object. 'sel' just works like 'cd'
    in an ordinary shell, except that it selects the current object,
    not the current working directory in the filesystem.


    This invokes the method 'getcmds' on 'myObject', which
    will return a list of all command prototypes that 'myObject'


    Go back to the root object.


More information about the Twisted-Python mailing list