def rotx(): rotx=npython.new ('nipol','rotx') npython.sel ('rotx') rotx.connect('rx') rotx.addkey1f(0,0) rotx.addkey1f(5,360) npython.sel ('..') return ()
def rotz(): rotz=npython.new ('nipol','rotz') npython.sel ('rotz') rotz.connect('rz') rotz.addkey1f(0,0) rotz.addkey1f(5,360) npython.sel ('..') return ()
def roty(): # catch ('{','delete','roty','}','err') # catch ('{','delete','roty2','}','err') roty=npython.new ('nipol','roty') npython.sel ('roty') roty.connect('ry') roty.addkey1f(0,0) roty.addkey1f(3,360) npython.sel ('..') return ()
def roty2(): catch ('{','delete','roty','}','err') catch ('{','delete','roty2','}','err') roty2=npython.new ('nipol','roty2') npython.sel ('roty2') roty2.connect('ry') roty2.addkey1f(0,360) roty2.addkey1f(3,0) npython.sel ('..') return ()
def testSetCommand(self): # Returns an opaque 'Nebula Object' object = npython.new('n3dnode','four') # Select the object npython.sel('four') # Set a value on the object npython.set('txyz',0,30,0) # Clean up and delete object npython.sel('..') npython.delete('four')
def testSameObjectReturn(self): root = npython.sel('/') ee = npython.new('nroot', '/ee') ee_same = npython.sel('/ee') ee_same2 = root['ee'] assert ee is ee_same, "Returned diffrent objects. Must be same object" assert ee is ee_same2, "Returned diffrent objects. Must be same object" npython.sel('/') npython.delete('/ee')
def testExceptionsInDictAccess(self): s = npython.sel('/sys') try: s['UnlikelyToExistObject'] except KeyError: # all right pass else: assert 1 == 0, 'Key error not thrown' npython.sel('/')
def map_input(): cwd = npython.psel() npython.sel("/sys/servers/input") npython.set("beginmap") npython.set("map", "keyb0:shift.pressed", "dolly") npython.set("map", "keyb0:ctrl.pressed", "orbit") npython.set("map", "mouse0:btn0.pressed", "pan") npython.set("map", "mouse0:btn1.pressed", "orbit") npython.set("map", "mouse0:btn2.pressed", "dolly") npython.set("map", "keyb0:space.down", "script:orig()") npython.set("map", "keyb0:j.down", "script:janaview()") npython.set("map", "keyb0:esc.down", "script:npython.set('/sys/servers/console.toggle')") npython.set("endmap") npython.sel(cwd)
def testGetCwdObject(self): x = npython.new('nroot','/x') x3 = npython.sel('/x') x2 = npython.GetCwdObject() assert x is x2, "Error diff object returned, must be same" npython.delete('/x')
def testFailedSelCommand(self): # Should throw an exception try: result = npython.sel('') except: # Exception thrown pass else: assert 1 == 0, 'No exception thrown'
def loadScript(self, script, brightness): npython.sel('/') npython.delete('/usr/scene') npython.new('n3dnode', '/usr/scene') npython.set('/sys/servers/console.unwatch') npython.set('/sys/servers/time.starttime') npython.set('/sys/servers/shadow.setcastshadows', 0) if self.execNamespace.has_key('tl'): self.execNamespace['tl'].destroy() del self.execNamespace['tl'] npython.set('/sys/servers/time.lockdeltat', 0.0) gfx = npython.sel('/sys/servers/gfx') apply(gfx.setclearcolor, ((brightness),) * 4) self.execNamespace['bg'] = brightness print 'Executing', script execfile(script, self.execNamespace) observerlib.orig()
def testWekRefs(self): sysobj = npython.sel('/sys') try: ref = weakref.ref(sysobj) except: assert 1 == 0, "Can't create weakref" weakrefscount = weakref.getweakrefcount(sysobj) assert weakrefscount, "Something strange with weak refs" try: ref().getcmds() except: assert 1 == 0, "Can't access weakrefed object"
def testEmptySelCommand(self): # Returns an opaque 'Nebula Object' result = npython.sel() pass
def testDictLookup(self): root = npython.sel('/') testobj = root['sys'] assert locals().has_key('testobj'), "Can't lookup object by [] syntax"
def testLoopDictLookup(self): root = npython.sel('/') npython.new('nroot', '/ee') for obj in root: assert locals().has_key('obj'), "Can't lookup object by iterator" npython.delete('/ee')
def sc(): npython.sel ('/usr/scene') return ()
def st(): npython.sel ('/usr/scene/std') return ()
def l(): npython.sel ('/') npython.sel ('usr') npython.sel ('scene') npython.sel ('dlight') return ()
def gfx(): #connect ('localhost:gfxserv') npython.sel ('/') return ()
def testUpSelCommand(self): # Returns an opaque 'Nebula Object' result = npython.sel('..') # TODO: Test result object itself path = npython.psel() assert path == '/'