示例#1
0
    def setUp(self):
        self._orb = CORBA.ORB_init()
        self._poa = self._orb.resolve_initial_references("RootPOA")

        prop = OpenRTM_aist.Properties(defaults_str=configsample_spec)
        ca = OpenRTM_aist.ConfigAdmin(prop.getNode("conf"))
        self._sdoconf = Configuration_impl(ca)
示例#2
0
def main(argv):

    print "Game Server starting..."

    orb = CORBA.ORB_init(argv, CORBA.ORB_ID)
    poa = orb.resolve_initial_references("RootPOA")

    poa._get_the_POAManager().activate()

    gf_impl = GameFactory_i(poa)
    gf_id = poa.activate_object(gf_impl)
    gf_obj = poa.id_to_reference(gf_id)

    print orb.object_to_string(gf_obj)

    # Bind the GameFactory into the Naming service. This code is
    # paranoid about checking all the things which could go wrong.
    # Normally, you would assume something this fundamental works, and
    # just die with uncaught exceptions if it didn't.
    try:
        nameRoot = orb.resolve_initial_references("NameService")
        nameRoot = nameRoot._narrow(CosNaming.NamingContext)
        if nameRoot is None:
            print "NameService narrow failed!"
            sys.exit(1)

    except CORBA.ORB.InvalidName, ex:
        # This should never happen, since "NameService" is always a
        # valid name, even if it hadn't been configured.

        print "Got an InvalidName exception when resolving NameService!"
        sys.exit(1)
示例#3
0
 def setUp(self):
     self._orb = CORBA.ORB_init([''])
     test = MEDCouplingCorbaSwigTest.MEDCouplingCorbaServBasicsTest()
     f = file(test.buildFileNameForIOR(), "r")
     ior = f.read()
     self._objC = self._orb.string_to_object(ior)
     pass
示例#4
0
def equals(a, b, client=None):
    """
    Compare whether the two objects a and b are the same on the server.
    param a, b object to compare.
    param client either an instance of Client or a client to the Tools interface.
    """
    import CORBA

    orb = CORBA.ORB_init()
    return a == b or orb.object_to_string(a) == orb.object_to_string(b)
示例#5
0
def main(args):
    orb = CORBA.ORB_init(args)
    poa = orb.resolve_initial_references("RootPOA")

    ti = Test_i()
    to = ti._this()

    print orb.object_to_string(to)

    poa._get_the_POAManager().activate()
    orb.run()
  def setUp(self):
    orb = CORBA.ORB_init(sys.argv)
    poa = orb.resolve_initial_references("RootPOA")
    poa._get_the_POAManager().activate()

    self._mysvc = MyService_impl()
    self._mycon = OpenRTM_aist.CorbaConsumer()
    #self._mysvc._this()

    self._cpSvc = CorbaPort("MyService")
    self._cpCon = CorbaPort("MyService")
示例#7
0
def main(args):
    orb = CORBA.ORB_init(args)
    poa = orb.resolve_initial_references("RootPOA")

    orb.register_value_factory(CORBA.id(ValueTest.Three), Three_i)

    ti = Test_i()
    to = ti._this()

    print orb.object_to_string(to)

    poa._get_the_POAManager().activate()
    orb.run()
示例#8
0
def main():
    orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID)
    poa = orb.resolve_initial_references("RootPOA")
    poaManager = poa._get_the_POAManager()
    poaManager.activate()
    obj = orb.resolve_initial_references("Channel")
    channel = obj._narrow(CosEventChannelAdmin.EventChannel)

    testproxypushconsumer.test(channel)
    testproxypullsupplier.test(channel)
    testproxypullconsumer.test(channel)
    testproxypushsupplier.test(channel)
    time.sleep(3)
示例#9
0
 def __init__(self):
     self._orb = CORBA.ORB_init([
         sys.argv[0], "-ORBInitRef",
         "NameService=corbaloc::localhost:2809/NameService"
     ], CORBA.ORB_ID)
     self._loader = None
     self._ns = None
     self._model = None
     self._joints = []
     self._links = []
     self._linknamemap = {}
     self._linknamemap['world'] = 'world'
     self._materials = []
     self._sensors = []
     self._assethandler = None
示例#10
0
def main(args):
    orb = CORBA.ORB_init(args)

    obj = orb.string_to_object(args[1])
    obj = obj._narrow(ValueTest.Test)

    v1 = ValueTest.One("hello", 123)
    v2 = ValueTest.One("test", 42)

    ret = obj.op1(v1, v2)
    ret = obj.op1(v1, v1)
    ret = obj.op1(v1, None)
    ret = obj.op1(None, v1)
    ret = obj.op1(None, None)

    orb.destroy()
示例#11
0
def createALocalField5():
    m=createALocalCMesh4()
    field=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME)
    field.setMesh(m)
    da=DataArrayDouble.New()
    field.setTime(14.5,0,0)
    da.setValues([float(7*i) for i in range(24)],24,1)
    field.setName("MeshOnCMesh");
    field.setArray(da)
    return field;
    

######

orb = CORBA.ORB_init([], CORBA.ORB_ID)
poa=orb.resolve_initial_references("RootPOA");
mgr=poa._get_the_POAManager();
mgr.activate();

###### Searching for 

naming_service = SALOME_NamingServicePy_i(orb)
rp=SALOME_ContainerManager_idl._0_Engines.ResourceParameters("","","",["PARAVIS"],1,10,10,1,1,"first",[])
cp=SALOME_ContainerManager_idl._0_Engines.ContainerParameters("","get","",1,False,"",rp)
sm=naming_service.Resolve("/ContainerManager")
cont=sm.GiveContainer(cp)
paraviz=naming_service.Resolve("/Containers/%s/FactoryServer/PARAVIS_inst_1"%(cont.getHostName()))

######
示例#12
0
 def __init__(self):      
     self.__ip = ''
     self.__port = ''
     self._serverMngr = None               
     self.__orb = CORBA.ORB_init()
     self._isConnected = False
示例#13
0
 def __init__(self, server, port, argv):
     self.server = server
     self.port = port
     self.orb = CORBA.ORB_init(argv, CORBA.ORB_ID)
示例#14
0
def main():
    #
    # Start orb.
    orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID)

    # Process Options
    verbose = 0
    needNameService = 0
    channelName = "EventChannel"
    factoryName = "EventChannelFactory"
    criteria = []

    try:
        opts, args = getopt.getopt(sys.argv[1:], "n:N:m:c:i:p:q:R:r:vh")
    except getopt.error:
        # print help information and exit:
        usage()
        sys.exit(-1)
    for option, optarg in opts:
        if option == '-n':
            channelName = optarg
            needNameService = 1
        elif option == '-N':
            factoryName = optarg
        elif option == '-m':  ## OLD OPTION
            criteria.append(makeNVP("MaxEventsPerConsumer", int(optarg)))
        elif option == '-c':
            criteria.append(makeNVP("CyclePeriod_ns", int(optarg)))
        elif option == '-i':
            criteria.append(makeNVP("InsName", optarg))  # string param
        elif option == '-p':
            criteria.append(makeNVP("MaxNumProxies", int(optarg)))
        elif option == '-q':
            criteria.append(makeNVP("MaxQueueLength", int(optarg)))
        elif option == '-R':
            criteria.append(makeNVP("PullRetryPeriod_ms", int(optarg)))
        elif option == '-r':  ## This option is deprecated in favour of -R:
            criteria.append(makeNVP("PullRetryPeriod", int(optarg)))
        elif option == '-v':
            verbose = 1
        elif option == '-h':
            usage()
            sys.exit(0)
        else:
            usage()
            sys.exit(-1)

    # Use one big try...catch block.
    # 'action' variable keeps track of what we're doing.
    action = "start"
    try:

        #
        # Get Name Service root context.
        rootContext = None
        try:
            action = "resolve initial reference 'NameService'"
            obj = orb.resolve_initial_references("NameService")
            rootContext = obj._narrow(CosNaming.NamingContext)
            if rootContext is None:
                raise CORBA.OBJECT_NOT_EXIST(0, CORBA.COMPLETED_NO)
        except CORBA.Exception, ex:
            if needNameService:
                raise ex
            else:
                sys.stderr.write("Warning - failed to %s\n" % action)

        #
        # Obtain reference to the Event Channel Factory implementation.
        # (from command-line argument or from the Naming Service).
        if len(args):
            action = "convert URI from command line into object reference"
            obj = orb.string_to_object(args[0])
        else:
            action = "find Event Channel Factory in naming service"
            obj = rootContext.resolve(str2name(factoryName))

        action = "narrow object reference to event channel factory"
        factory = obj._narrow(EventChannelAdmin.EventChannelFactory)
        if factory is None:
            sys.stderr.write(
                "Failed to narrow Event Channel Factory reference.\n")
            sys.exit(1)

        # Check that the factory is of the right type
        action = "check factory supports EventChannel object interface"
        key = [CosNaming.NameComponent("EventChannel", "object interface")]
        if not factory.supports(key):
            sys.stderr.write('Factory does not support Event Channel Interface!'+ \
              ' [%s]\n'%factoryName)
            sys.exit(1)

        #
        # Create Event Channel Object.
        action = "create EventChannel object"
        channelObj = factory.create_object(key, criteria)
        if channelObj is None:
            sys.stderr.write('Channel Factory returned nil reference!'+ \
              ' [%s]\n'%channelName)
            sys.exit(1)

        # Print the new EventChannel's IOR to standard output.
        if verbose:
            print orb.object_to_string(channelObj)

        # Narrow object returned to an Event Channel
        channel = channelObj._narrow(CosEventChannelAdmin.EventChannel)
        if channel is None:
            sys.stderr.write('Failed to narrow Event Channel!'+ \
              ' [%s]\n'%channelName)
            sys.exit(1)

        #
        # Register event channel with naming service
        if rootContext is not None:
            name = str2name(channelName)
            try:
                action = "register (bind) EventChannel with the naming service"
                rootContext.bind(name, channel)
            except CosNaming.NamingContext.AlreadyBound, ex:
                action = "register (rebind) EventChannel with the naming service"
                rootContext.rebind(name, channel)
示例#15
0
    def __init__(self, o, client=None):
        import CORBA

        orb = CORBA.ORB_init()
        self.client = client
        self.ostr = orb.object_to_string(o)
示例#16
0
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
#
# See http://www.salome-platform.org/ or email : [email protected]
#
# Author : Anthony Geay (CEA/DEN)

import CORBA
import MEDCouplingCorbaSwigTest
import MEDCouplingCorbaSwigTestServ

orb = CORBA.ORB_init([''])
poa = orb.resolve_initial_references("RootPOA")
mgr = poa._get_the_POAManager()
mgr.activate()
compo = MEDCouplingCorbaSwigTestServ.MEDCouplingMeshFieldFactoryComponentPy(
    orb)
compoPtr = compo._this()
ior = orb.object_to_string(compoPtr)
test = MEDCouplingCorbaSwigTest.MEDCouplingCorbaServBasicsTest()
f = file(test.buildFileNameForIOR(), "w")
f.write(ior)
f.close()
orb.run()
 def __init__(self):
     self._orb = CORBA.ORB_init()
     self._poa = self._orb.resolve_initial_references("RootPOA")
     OpenRTM_aist.RTObject_impl.__init__(self, orb=self._orb, poa=self._poa)
 def setUp(self):
     self._orb = CORBA.ORB_init()
     self._poa = self._orb.resolve_initial_references("RootPOA")
     inport = OpenRTM_aist.InPort("in", RTC.TimedLong(RTC.Time(0, 0), 0),
                                  OpenRTM_aist.RingBuffer(8))
     self._dip = DataInPort("in", inport, None)
示例#19
0
    def __init__(self):
        self.orb = CORBA.ORB_init()
        try:
            self.ior = open("LTTSample0.rtc").read()
        except:
            print "LTTSample0.rtc not found"
            import time, sys
            write = sys.stdout.write
            write("Launching LTTSampleComp...")
            sys.stdout.flush()
            if os.sep == '\\':
                os.system("start LTTSampleComp.exe")
            else:
                os.system("./LTTSampleComp&")
            while True:
                try:
                    self.ior = open("LTTSample0.rtc").read()
                    break;
                except:
                    write(".")
                    sys.stdout.flush()
                    time.sleep(0.01)
                    pass
            print "done"
        obj = self.orb.string_to_object(self.ior)
        if CORBA.is_nil(obj):
            print "Object in LTTSample0.rtc is nil. Restarting LTTSampleComp..."
            if os.sep == '\\':
                os.system("start LTTSampleComp.exe")
            else:
                os.system("./LTTSampleComp&")
            self.ior = open("LTTSample0.rtc").read()
            obj = self.orb.string_to_object(self.ior)
            if CORBA.is_nil(obj):
                print "Object reference is nil"
                sys.exit(1)

        import omniORB
        import sys

        if os.sep == '\\':
            os.system("omniidl -I. -bpython SDOPackage.idl RTC.idl LogicalTimeTriggeredEC.idl")
            import RTC
            import OpenRTM
        else:
            self.sdo_idl = omniORB.importIDL("idl/SDOPackage.idl")
            self.rtc_idl = omniORB.importIDL("idl/RTC.idl", ["-Iidl"])
            self.ltt_idl = omniORB.importIDL("idl/LogicalTimeTriggeredEC.idl",
                                         ["-Iidl"])
            RTC = sys.modules["RTC"]
            OpenRTM = sys.modules["OpenRTM"]
        try:
            self.rtobj = obj._narrow(RTC.RTObject)
        except:
            print "Narrowing failed. Restarting LTTSampleComp..."
            import time
            print "Launching LTTSampleComp..."
            if os.sep == '\\':
                os.system("start LTTSampleComp.exe")
            else:
                os.system("./LTTSampleComp&")
            time.sleep(1.0)
            obj = self.orb.string_to_object(open("LTTSample0.rtc").read())
            self.rtobj = obj._narrow(RTC.RTObject)

        cxts = self.rtobj.get_owned_contexts()
        self.lttcxt = cxts[0]._narrow(OpenRTM.LogicalTimeTriggeredEC)
        profile = self.lttcxt.get_profile()
        p = {}
        p["kind"] = profile.kind
        p["rate"] = profile.rate
        p["owner"] = profile.owner
        from omniORB import any
        for prop in profile.properties:
            p[prop.name] = any.from_any(prop.value)
        print "ExecutionContext:"
        print "      type:", p.pop("type")
        print "      name:", p.pop("name")
        print "      kind:", p.pop("kind")
        print "      rate:", p.pop("rate")
        print "     owner:", p.pop("owner")
        print "properties:", p
示例#20
0
        ]
        a = CORBA.Any(tc, seq)
        b = CORBA.Any(tc, seq)

        assert a == b

    def test28_typecode(self):
        '''TypeCodes'''
        objref = factory.getAnyServer()

        inarg = CORBA.TypeCode('IDL:orbit/test/ArrayUnion:1.0')
        inoutarg = CORBA.TypeCode('IDL:orbit/test/AnyServer:1.0')
        retn, inout, out = objref.opTypeCode(inarg, inoutarg)

        assert retn == CORBA.TypeCode(
            'IDL:orbit/test/VariableLengthStruct:1.0')
        assert inout == CORBA.TypeCode('IDL:orbit/test/TestException:1.0')
        assert out == CORBA.TypeCode('IDL:orbit/test/AnEnum:1.0')


if __name__ == '__main__':
    orb = CORBA.ORB_init(sys.argv, 'orbit-local-orb')

    filename = os.environ.get('TEST_SERVER_IORFILE',
                              '../../../ORBit2/test/everything/iorfile')
    ior = file(filename, 'r').read()
    factory = orb.string_to_object(ior)
    del filename, ior

    unittest.main()
示例#21
0
def main():
  orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID)

  # Process Options
  discnum = 0
  sleepInterval = 0
  channelName = "EventChannel"

  # Process Options
  try:
    opts,args=getopt.getopt(sys.argv[1:],"d:s:n:h")
  except getopt.error:
    # print help information and exit:
    usage()
    sys.exit(-1)
  for option, optarg in opts:
    if option=='-d':
      discnum = int(optarg)
    elif option=='-s':
      sleepInterval = int(optarg)
    elif option=='-n':
      channelName = optarg
    elif option=='-h':
      usage()
      sys.exit(0)
    else:
      usage()
      sys.exit(-1)

  # Ignore broken pipes
  if signal.__dict__.has_key('SIGPIPE'):
    signal.signal(signal.SIGPIPE, signal.SIG_IGN)

  action="start" # Use this variable to help report errors.
  try:

    action="resolve initial reference 'RootPOA'"
    poa=orb.resolve_initial_references("RootPOA")

    action="activate the RootPOA's POAManager"
    poaManager=poa._get_the_POAManager()
    poaManager.activate()

    #
    # Obtain reference to the Event Channel.
    # (from command-line argument or from the Naming Service).
    if len(args):
      action="convert URI from command line into object reference"
      obj=orb.string_to_object(args[0])
    else:
      #
      # Get Name Service root context.
      action="resolve initial reference 'NameService'"
      obj=orb.resolve_initial_references("NameService")
      rootContext=obj._narrow(CosNaming.NamingContext)
      if rootContext is None:
        raise CORBA.OBJECT_NOT_EXIST(0,CORBA.COMPLETED_NO)

      #
      # Obtain reference to the Event Channel.
      action="find Event Channel in naming service"
      obj=rootContext.resolve(str2name(channelName))

    action="narrow object reference to event channel"
    channel=obj._narrow(CosEventChannelAdmin.EventChannel)
    if channel is None:
      raise CORBA.OBJECT_NOT_EXIST(0,CORBA.COMPLETED_NO)

  except CORBA.ORB.InvalidName, ex: # resolve_initial_references()
     sys.stderr.write("Failed to %s. ORB::InvalidName\n"%action)
     sys.exit(1)
import sys
import threading
import time
import MateCORBA
import CORBA

## this should no longer be needed, but is here as workaround to
## http://bugzilla.mate.org/show_bug.cgi?id=323201
MateCORBA.load_file('./pyt.idl')

orb = CORBA.ORB_init(orb_id="matecorba-io-thread")

for num in [int(x) for x in sys.argv[1:]]:
    pyt = orb.string_to_object(open('ior%i' % num).read())
    t1 = threading.Thread(target=pyt.op)
    t1.start()

 def setUp(self):
     self._orb = CORBA.ORB_init()
     self._poa = self._orb.resolve_initial_references("RootPOA")
     outport = OpenRTM_aist.OutPort("out", RTC.TimedLong(RTC.Time(0, 0), 0),
                                    OpenRTM_aist.RingBuffer(8))
     self._dop = DataOutPort("out", outport, None)
示例#24
0
def main(args):
    orb = CORBA.ORB_init(args)
    poa = orb.resolve_initial_references("RootPOA")
    poa._get_the_POAManager().activate()

    orb.register_value_factory(CORBA.id(ValueTest.Three), Three_i)

    obj = orb.string_to_object(args[1])
    obj = obj._narrow(ValueTest.Test)

    v1 = ValueTest.One("hello", 123)
    v2 = ValueTest.One("test", 42)
    v3 = ValueTest.Two(None, None)
    v4 = ValueTest.Two(v1, None)
    v5 = ValueTest.Two(v1, v2)
    v6 = ValueTest.Two(v1, v1)
    v7 = Derived.Five("abc", 456, "more")

    obj.show("Simple values")
    r1 = obj.op1(v1)
    r2 = obj.op1(v2)
    r3 = obj.op1(None)

    obj.show("Two different values")
    obj.op2(v1, v2)

    obj.show("Nil, value")
    obj.op2(None, v1)

    obj.show("Value, nil")
    obj.op2(v1, None)

    obj.show("Two nils")
    obj.op2(None, None)

    obj.show("Two references to the same value")
    obj.op2(v1, v1)

    obj.show("Value containing two nils")
    r4 = obj.op3(v3)

    obj.show("Value containing value, nil")
    r5 = obj.op3(v4)

    obj.show("Value containing val1, val2")
    r6 = obj.op3(v5)

    obj.show("Value containing two references to same value")
    r7 = obj.op3(v6)

    obj.show("Derived value (should be truncated)")
    r8 = obj.op1(v7)

    obj.show("Same derived value twice")
    obj.op2(v7, v7)

    obj.show("Base value, derived value")
    obj.op2(v1, v7)

    obj.show("Derived value, base value")
    obj.op2(v7, v1)

    obj.show("String in valuebox")
    r9 = obj.op4("Hello")

    obj.show("Empty value box")
    r10 = obj.op4(None)

    obj.show("Nil abstract interface")
    obj.op5(None)

    fi = Four_i()
    fo = fi._this()

    obj.show("Abstract interface set to object reference")
    obj.op5(fo)

    t = Three_i("experiment")
    obj.show("Abstract interface set to value")
    obj.op5(t)

    # Any tests
    a1 = CORBA.Any(ValueTest._tc_One, v1)
    a2 = CORBA.Any(Derived._tc_Five, v7)
    v8 = Derived.Six(1.234, "test")
    a3 = CORBA.Any(Derived._tc_Six, v8)
    a4 = CORBA.Any(ValueTest._tc_One, None)
    a5 = CORBA.Any(ValueTest._tc_One, v2)
    a6 = CORBA.Any(ValueTest._tc_One, v2)

    obj.show("Value in Any")
    obj.op6(a1)

    obj.show("Derived value in Any")
    obj.op6(a2)

    obj.show("Completely unknown value in any")
    obj.op6(a3)

    obj.show("Nil value in any")
    obj.op6(a4)

    obj.show("Two anys")
    obj.op7(a1, a5)

    obj.show("Same any twice")
    obj.op7(a1, a1)

    obj.show("Different anys containing same value")
    obj.op7(a5, a6)

    obj.show("Same derived value twice")
    obj.op7(a2, a2)

    obj.show("Any and value")
    obj.op8(a1, v2)

    obj.show("Any and same value")
    obj.op8(a1, v1)

    obj.show("Any and derived")
    obj.op8(a1, v7)

    obj.show("Same derived value in any and value")
    obj.op8(a2, v7)

    obj.show("Value and any")
    obj.op9(v2, a1)

    obj.show("Value and same value in any")
    obj.op9(v1, a1)

    obj.show("Derived value and any")
    obj.op9(v7, a1)

    obj.show("Same derived value as value and in any")
    obj.op9(v7, a2)

    obj.show("Empty value")
    e1 = ValueTest.Empty()
    e2 = ValueTest.Empty()
    obj.op10(e1)

    obj.show("Different empty values")
    obj.op11(e1, e2)

    obj.show("Same empty values")
    obj.op11(e1, e1)

    obj.show("Empty value, None")
    obj.op11(e1, None)

    obj.show("None, empty value")
    obj.op11(None, e1)

    obj.show("None, None")
    obj.op11(None, None)

    obj.show("Container of empty values")
    c1 = ValueTest.Container(e1, e2)
    obj.op12(c1)

    orb.destroy()
示例#25
0
from flask import Flask
from flask import request, render_template, url_for, redirect
import CORBA, Bank
orb = CORBA.ORB_init()

app = Flask(__name__)


@app.route('/', methods=['GET'])
def index_redirect():
    return redirect(url_for('index'))


@app.route('/account')
def index():
    return render_template('index.html', title='E-banking New Account Service')


@app.route('/account', methods=['POST'])
def create_account():
    try:
        email = str(request.form['email'])
        password = str(request.form['password'])
        account = str(request.form['account'])

        f = open("ild_key.txt", "r")
        idl_key = f.read()
        f.close()

        server_req = orb.string_to_object(idl_key)
        server_req = server_req._narrow(Bank.BankingServer)
        ]
        a = CORBA.Any(tc, seq)
        b = CORBA.Any(tc, seq)

        assert a == b

    def test28_typecode(self):
        '''TypeCodes'''
        objref = factory.getAnyServer()

        inarg = CORBA.TypeCode('IDL:matecorba/test/ArrayUnion:1.0')
        inoutarg = CORBA.TypeCode('IDL:matecorba/test/AnyServer:1.0')
        retn, inout, out = objref.opTypeCode(inarg, inoutarg)

        assert retn == CORBA.TypeCode(
            'IDL:matecorba/test/VariableLengthStruct:1.0')
        assert inout == CORBA.TypeCode('IDL:matecorba/test/TestException:1.0')
        assert out == CORBA.TypeCode('IDL:matecorba/test/AnEnum:1.0')


if __name__ == '__main__':
    orb = CORBA.ORB_init(sys.argv, 'matecorba-local-orb')

    filename = os.environ.get('TEST_SERVER_IORFILE',
                              '../../../MateCORBA2/test/everything/iorfile')
    ior = file(filename, 'r').read()
    factory = orb.string_to_object(ior)
    del filename, ior

    unittest.main()
import MateCORBA
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.mate.org/show_bug.cgi?id=323201
## you also need to use this if the server is not MateCORBA2 based
MateCORBA.load_file("./echo.idl")
#import Test  # use this if the server is not MateCORBA2 based

orb = CORBA.ORB_init(sys.argv)

ior = file('iorfile').read()
echo = orb.string_to_object(
    ior)  #._narrow(Test.Echo) # _narrow not needed with MateCORBA2 servers

if sys.argv[1] == 'quit':
    echo.quit()
else:

    def callback(retval, exc_type, exc_value, user_data):
        assert user_data == "hello"
        print "async callback", retval
        orb.shutdown(0)

    echo.echo. async ([sys.argv[1]], callback, "hello")
示例#28
0
import CORBA
import CosNaming

orb = CORBA.ORB_init([''], CORBA.ORB_ID)
print orb
name = orb.resolve_initial_references('NameService')._narrow(
    CosNaming.NamingContext)
print name
namelist = name.list(1000)
print namelist
for n in namelist[0]:
    print n.binding_name[0].id
示例#29
0
import sys
#Importa as implementações dos módulos CORBA e PortableServer
import CORBA, PortableServer
#Importa os stubs-client e os skeletons-server
import Fortune, Fortune__POA


class Echo_i(Example__POA.Echo):
    def echoString(self, mesg):
        print("echoString() called with message:", mesg)
        return mesg


#inicializando o orb chamando a função ORB_init onde é passado uma lista de argumentos de
#linhas de comando e um identificador ORB
orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID)
#ativando o objeto de serviço
poa = orb.resolve_initial_references("RootPOA")

#criando uma instância do objeto
ei = Echo_i()
#obtendo a referência retornada do objeto
eo = ei._this()

#
poaManager = poa._get_the_POAManager()
poaManager.activate()

message = "Hello"
result = eo.echoString(message)
示例#30
0
def main():
    result = 1

    #
    # Start orb.
    orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID)

    # Process Options
    ecName = str2name("EventChannel")

    try:
        opts, args = getopt.getopt(sys.argv[1:], "n:h")
    except getopt.error:
        # print help information and exit:
        usage()
        sys.exit(-1)
    for option, optarg in opts:
        if option == '-n':
            ecName = str2name(optarg)
        elif option == '-h':
            usage()
            sys.exit(0)
        else:
            usage()
            sys.exit(-1)

    # Use one big try...catch block.
    # 'action' variable keeps track of what we're doing.
    action = "start"
    try:

        #
        # Obtain reference to the Event Channel.
        # (from command-line argument or from the Naming Service).
        if len(args):
            action = "convert URI from command line into object reference"
            obj = orb.string_to_object(args[0])
        else:
            #
            # Get Name Service root context.
            action = "resolve initial reference 'NameService'"
            obj = orb.resolve_initial_references("NameService")
            rootContext = obj._narrow(CosNaming.NamingContext)
            if rootContext is None:
                raise CORBA.OBJECT_NOT_EXIST(0, CORBA.COMPLETED_NO)

            #
            # Obtain reference to the Event Channel.
            action = "find Event Channel in naming service"
            obj = rootContext.resolve(ecName)

            #
            # Unbind the Channel's reference in the naming service.
            action = "unbind Event Channel from naming service"
            rootContext.unbind(ecName)

        action = "narrow object reference to event channel"
        channel = obj._narrow(CosEventChannelAdmin.EventChannel)
        if channel is None:
            raise CORBA.OBJECT_NOT_EXIST(0, CORBA.COMPLETED_NO)

        #
        # Destroy the EventChannel.
        action = "destroy Event Channel"
        channel.destroy()

        #
        # Clean up nicely.
        action = "destroy orb"
        orb.destroy()

        #
        # If we get here, then everything has worked OK.
        result = 0

    except CORBA.ORB.InvalidName, ex:  # resolve_initial_references()
        sys.stderr.write("Failed to %s. ORB::InvalidName\n" % action)