import ORBit ORBit.load_file('./pyt.idl') import CORBA orb = CORBA.ORB_init() pyt = orb.string_to_object(open('ior').read()) pyt.op()
#! /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 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 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):
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!"
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()