#!/usr/bin/env python '''This is a client to the test/everything/server test program distributed with ORBit2.''' import sys, os import unittest import ORBit ORBit.load_typelib('Everything') import CORBA # this one is loaded from the typelib ... from orbit import test import constants # from test/everything/constants.h class EverythingTestCase(unittest.TestCase): def test01_attribute(self): '''attributes''' objref = factory.getBasicServer() assert objref._is_a('IDL:orbit/test/BasicServer:1.0') val = objref.foo assert val == constants.STRING_RETN objref.foo = constants.STRING_IN lval = objref.bah
import sys import ORBit, bonobo from time import time from threading import Thread from os.path import abspath IDL_NAME = abspath('ldata.idl') orb = ORBit.CORBA.ORB_init() ORBit.load_file(IDL_NAME) import Test NUM_EXP = 16 NUM_LINEAR = 64 STEP_EXP = 2 STEP_LINEAR = 512 NUM_CALLS = 2000 def main(args): f = file('/tmp/test-ldata.ior', 'r') ior_str = f.readline()[:-1] ldata = orb.string_to_object(ior_str) f.close() asize = STEP_LINEAR for expon in range(NUM_LINEAR): t = time() for count in range(NUM_CALLS): intarray = ldata.get(asize)
import ORBit ORBit.load_file('./pyt.idl') import CORBA orb = CORBA.ORB_init() pyt = orb.string_to_object(open('ior').read()) pyt.op()
import sys import ORBit, bonobo from time import time from threading import Thread from os.path import abspath IDL_NAME = abspath('ldata.idl') orb = ORBit.CORBA.ORB_init() ORBit.load_file(IDL_NAME) import Test NUM_EXP = 16 NUM_LINEAR = 64 STEP_EXP = 2 STEP_LINEAR = 512 NUM_CALLS = 2000 def main(args): f = file('/tmp/test-ldata.ior', 'r') ior_str = f.readline()[:-1] ldata = orb.string_to_object(ior_str) f.close() asize = STEP_LINEAR for expon in range(NUM_LINEAR): t = time() for count in range(NUM_CALLS):
#! /usr/bin/env python import ORBit import CORBA import sys if len(sys.argv) != 2: print "usage: %s <message>" % sys.argv[0] sys.exit(1) ## this should no longer be needed, but is here as workaround to ## http://bugzilla.gnome.org/show_bug.cgi?id=323201 ## you also need to use this if the server is not ORBit2 based ORBit.load_file("./echo.idl") #import Test # use this if the server is not ORBit2 based orb = CORBA.ORB_init(sys.argv) ior = file('iorfile').read() echo = orb.string_to_object(ior)#._narrow(Test.Echo) # _narrow not needed with ORBit2 servers print repr(echo) if sys.argv[1] == 'quit': echo.quit() else: print echo.echo(sys.argv[1])
import sys import ORBit, bonobo from time import time from threading import Thread TYPELIB_NAME = "Accessibility" orb = ORBit.CORBA.ORB_init() ORBit.load_typelib(TYPELIB_NAME) import Accessibility import Accessibility__POA NUM_CALLS = 18000 class ORBThread(Thread): def __init__(self): Thread.__init__(self) self.setDaemon(True) def run(self): orb.run() class AtspiEventListener(Accessibility__POA.EventListener): def ref(self): pass def unref(self): pass def register(self, reg, name): reg.registerGlobalEventListener(self._this(), name)
import sys,os,time,string,re,socket import ORBit ORBit.load_typelib('Everything') ORBit.load_file('/usr/include/server.idl') import CORBA from DBSQLServer import DBSQLServer class DBServer: fields = { 'cid': None, 'start': None, 'ac': None, 'orb': None, 'root_poa': None, 'mypoadbserver': None, 'myref': None, 'myior': None, 'arsref': [], 'arpref': [], 'nhl': None, 'ahls': None, 'acl': None, 'aml': None, 'asl': None, 'adbsl': None, 'acl_maxc': 0, 'aml_maxc': 0, 'asl_maxc': 0, 'adbsl_maxc': 0, 'nsl': None, 'ncl': None,
#!/usr/bin/python # # pass the IOR returned by the following command as an argument: # activation-client -s "repo_ids.has('IDL:Nautilus/MetafileFactory:1.0')" | tail -1 # import sys, os import ORBit, CORBA # we can load type information from a typelib ORBit.load_typelib('Bonobo') # or by parsing IDL ... nautilusdir = os.environ['HOME'] + '/cvs/gnome2/nautilus' ORBit.load_file( '%s/libnautilus-private/nautilus-metafile-server.idl' % nautilusdir, '-I%s -I/usr/share/idl -D__ORBIT_IDL__ -D__nautilus_view_component_COMPILATION' % nautilusdir) import Nautilus__POA class Monitor(Nautilus__POA.MetafileMonitor): i = 0 # Bonobo::Unknown methods ... def ref(self): print "Ref!" def unref(self): print "Unref!"
import sys import ORBit, bonobo from time import time from threading import Thread TYPELIB_NAME = "Accessibility" orb = ORBit.CORBA.ORB_init() ORBit.load_typelib(TYPELIB_NAME) import Accessibility import Accessibility__POA NUM_CALLS = 18000 class ORBThread(Thread): def __init__(self): Thread.__init__(self) self.setDaemon(True) def run(self): orb.run() class AtspiEventListener(Accessibility__POA.EventListener): def ref(self): pass def unref(self): pass
import ORBit import bonobo, gnome ORBit.load_typelib('Accessibility') gnome.init('list-apps', '0.0') REGISTRY_IID = 'OAFIID:Accessibility_Registry:1.0' registry = bonobo.activation.activate("iid == '%s'" % REGISTRY_IID) # get first desktop desktop = registry.getDesktop(0) for i in range(desktop.childCount): child = desktop.getChildAtIndex(i) print child.name child.unref() desktop.unref() registry.unref()
import sys import ORBit sys.path.append('.libs') ORBit.load_typelib('./TestCall_module') import CORBA, PyORBit, PyORBit__POA import cTestCall class PyTestCall(PyORBit__POA.TestCall): def op1(self, other): this = self._this() print " Python impl of TestCall.op1 invoked" other.op2(this) def op2(self, other): print " Python impl of TestCall.op2 invoked" other.op3() def op3(self): this = self._this() print " Python impl of TestCall.op3 invoked" orb = CORBA.ORB_init(sys.argv) poa = orb.resolve_initial_references('RootPOA') # create the C objref c_objref = cTestCall.create_TestCall(orb)
import sys import ORBit sys.path.append('.libs') ORBit.load_typelib('./TestCall_module') import CORBA, PyORBit, PyORBit__POA import cTestCall class PyTestCall(PyORBit__POA.TestCall): def op1(self, other): this = self._this() print " Python impl of TestCall.op1 invoked" other.op2(this) def op2(self, other): print " Python impl of TestCall.op2 invoked" other.op3() def op3(self): this = self._this() print " Python impl of TestCall.op3 invoked" orb = CORBA.ORB_init(sys.argv) poa = orb.resolve_initial_references('RootPOA') # create the C objref c_objref = cTestCall.create_TestCall(orb) # create the python objref py_servant = PyTestCall() py_objref = py_servant._this()
# -*- Mode: Python; py-indent-offset: 4 -*- import gobject del gobject # load the bonobo typelib import ORBit ORBit.load_typelib('Bonobo') del ORBit import activation from _bonobo import * class UnknownBaseImpl(object): def __init__(self): self.__bobj = ForeignObject(self._this()) self.__bobj.connect("destroy", self.__destroy) def get_bonobo_object(self): return self.__bobj def ref(self): self.__bobj.ref() def unref(self): self.__bobj.unref() def queryInterface(self, repoid): return self.__bobj.query_local_interface(repoid).corba_objref() def __destroy(self, foreign): # print "Deactivating Object" poa = self._default_POA() id = poa.servant_to_id(self) poa.deactivate_object(id) # print "Removing reference to ForeignObject"
def server(): print "Server is running..." idlContent = """ // rtbfms.idl module RTBFMS { struct Fighter { string id; string model; short field; boolean friend; boolean alive; }; struct Command { string id; string time; string content; }; interface Grid { typedef sequence<Fighter> FighterList; typedef sequence<Command> CommandList; attribute FighterList fighters; attribute CommandList commands; boolean pushFighter(in string FighterID, in Fighter FighterData); void pullFighter(in string FighterID, inout Fighter FighterData); boolean pushCommand(in string FighterID, in Command CommandData); void pullCommand(in string FighterID, inout Command CommandData); void quitCommand(); }; }; """ idlFile = file(prgName+".idl","w") idlFile.write(idlContent) idlFile.close() ORBit.load_file(prgName+".idl") import RTBFMS__POA class Servant(RTBFMS__POA.Grid): def __init__(self): self.fighters = [] self.commands = [] def pushFighter(self,FighterID,FighterData): self.fighters.append(FighterData) for f in self.fighters: print f.id, f.model, len(f.id) def pullFighter(self,FighterID,FighterData): for fighter in self.fighters: if fighter.id == FighterID: FighterData = fighter return FighterData def pushCommand(self,FighterID,CommandData): self.commands.append(CommandData) for c in self.commands: print c.id, c.time, c.content def pullCommand(self,FighterID,CommandData): for command in self.commands: if command.id == FighterID: CommandData = command return CommandData def quitCommand(self): orb.shutdown(0) orb = CORBA.ORB_init(sys.argv) servant = Servant() objref = servant._this() iorFile = file(prgName+".ior", "w") iorFile.write(orb.object_to_string(objref)) iorFile.close() poa = orb.resolve_initial_references("RootPOA") poa._get_the_POAManager().activate() orb.run()
except getopt.GetoptError: print _("option not recognized, use -h for help") sys.exit(2) if not opts: usage() else: sys.argv[1] = "-ORBIIOPIPv4=1" for opt, arg in opts: if opt in ("-h", "--help"): usage() sys.exit() elif opt in ("-s", "--server"): server() sys.exit() elif opt in ("-c", "--client"): ORBit.load_file(prgName+".idl") import RTBFMS ior = file(prgName+".ior").read() orb = CORBA.ORB_init(sys.argv) try: ior = file(prgName+".ior").read() servant = orb.string_to_object(ior)._narrow(RTBFMS.Grid) except: print "No IOR File" myself = RTBFMS.Fighter() if arg == "sensor": import serial application = Application() application.main() sys.exit()