コード例 #1
0
ファイル: ifrconnection.py プロジェクト: omniorb/omniifr
 def __init__(self, orb=None, ifr=None, argv=None):
     """Supply AT MOST ONE of the three optional arguments."""
     self.orb = orb
     self.ifr = ifr
     if (not self.ifr):
         if (not self.orb):
             if (argv):
                 self.orb = CORBA.ORB_init(argv, CORBA.ORB_ID)
             else:
                 self.orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID)
         obj = self.orb.resolve_initial_references("InterfaceRepository")
         self.ifr = obj._narrow(CORBA.Repository)
コード例 #2
0
def corbaClient(objectClass, iorDir=None, iorFile=None):
    """
    Creates reference to interface object running in the servant processes.
    Arguments are:
        servantClass - a class implementing the interface
        iorDir - path to the directory where ior files are existing 
                   (exact ior file name is concluded from objectClass name)
        iorFile - direct path the the ior file with reference to the object"""
    logger.info('starting corba client')
    if not iorDir and not iorFile:
        logger.error("iorDir or iorFile must be specified!")
        raise CorbaException("Corba client wrong configuration")

    try:
        orb = CORBA.ORB_init([], CORBA.ORB_ID)
        if not iorFile:
            #concluding the name of ior file from interface object class name
            iorFile = iorDir + '/%s.ior' % objectClass.__name__
        ior = file(iorFile).readline()
        obj = orb.string_to_object(ior)
        objectReference = obj._narrow(objectClass)
        # reference to the remote object is available
        return objectReference
    except:
        traceback.print_exc()
        logger.error("Exception" + traceback.format_exc())
        raise CorbaException("Corba connection to %s failed!" %
                             objectClass.__name__)
コード例 #3
0
    def __init__(self):
        self.simulationitem = []
        self.modelitem = []
        self.collisionpairitem = []
        self.orb = None
        self.ns = None
        self.sim = None
        self.viewer = None
        self.modelloader = None
        
        # initialize CORBA
        self.orb = CORBA.ORB_init([sys.argv[0],
                                   "-ORBInitRef",
                                   "NameService=corbaloc::localhost:2809/NameService"],
                                   CORBA.ORB_ID)

        # find CORBA name server
        nsobj = self.orb.resolve_initial_references("NameService")
        self.ns = nsobj._narrow(CosNaming.NamingContext)
        
        # find simulator service from the name server
        try:
            obj = self.ns.resolve([CosNaming.NameComponent("DynamicsSimulator","")])
            self.sim = obj._narrow(OpenHRP.DynamicsSimulator)
        except CosNaming.NamingContext.NotFound:
            pass
コード例 #4
0
ファイル: __init__.py プロジェクト: koonihc/framework-core
def GetSCAFileContents(url):
    fileContents = None
    scheme, netloc, path, params, query, fragment = urlparse.urlparse(url)
    if scheme == "sca":
        queryAsDict = dict([x.split("=") for x in query.split("&")])
        try:
            ## RESOLVE ORB
            orb = CORBA.ORB_init()
            fileSys = orb.string_to_object(queryAsDict["fs"])
        except KeyError:
            logging.warning("sca URI missing fs query parameter")
        except:
            logging.warning("Unable to get ORB reference")
        else:
            if fileSys == None:
                logging.warning("Failed to lookup file system")
            else:
                try:
                    scaFile = fileSys.open(path, True)
                    fileSize = scaFile.sizeOf()
                    fileContents = scaFile.read(fileSize)
                    scaFile.close()
                finally:
                    pass
    return fileContents
コード例 #5
0
    def __init__(self, servantClass, data, iorDir, iorName=None):
        """
        Constructor of the class with arguments:
            servantClass - a class implementing the interface
            dataModels - object containing data
            iorDir - path to the directory where ior file will be created
            iorName - ior filename - otherwise IDL interface name is used
        """
        Thread.__init__(self)
        self.servantClass = servantClass
        self.interfaceName = iorName or servantClass.__name__
        self.data = data
        logger.info('initializing corba enviroment for %s' %
                    self.interfaceName)
        try:
            self.orb = CORBA.ORB_init([], CORBA.ORB_ID)
            rootPoa = self.orb.resolve_initial_references("RootPOA")
            poaManager = rootPoa._get_the_POAManager()
            poaManager.activate()
            self.iorFile = iorDir + '/%s.ior' % self.interfaceName

            servantInstance = self.servantClass(self.data)
            servantObject = servantInstance._this()
            #logger.debug("Look at servant %s", servantObject)
            self.servantObject = servantObject
            self.ior = self.orb.object_to_string(servantObject)
        except:
            logger.error("Exception" + traceback.format_exc())
            raise CorbaException("Corba enviroment initialization failed" +
                                 traceback.format_exc())
コード例 #6
0
def main(argv):

    print 'Initialising the ORB...'

    # Initialise the ORB.
    orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID)

    # Read the server's stringified IOR from a file (this is just a 'cheap and
    # cheerful' way of locating the server - in practise the client would use
    # the naming or trader services).
    stringified_ior = open('server.ref').read()

    # Convert the stringified IOR into an active object reference.
    server_obj = orb.string_to_object(stringified_ior)

    # Narrow the reference, to make it active
    server = server_obj._narrow(HelloWorld.Hello)

    # Make sure that the server is not a 'nil object reference' (represented
    # in Python by the value 'None').
    if server is None:
        print "Object is not a Hello|World.Hello server"
        raise 'Nil object reference!'

    # Call the server.
    print server.hello_world()

    return 0
コード例 #7
0
ファイル: SALOME_Trace.py プロジェクト: Sunqia/salome-kernel
    def __init__(self):
        self.m_pInterfaceLogger = None
        if trace=="logger":
            ok = 0
            steps = 40
            while steps > 0 and ok == 0:

              try:
                orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID)
                theObj = orb.resolve_initial_references("NameService")
                inc = theObj._narrow(CosNaming.NamingContext)
                name = [CosNaming.NameComponent("Logger","")]
                obj = inc.resolve(name);

                self.m_pInterfaceLogger = obj._narrow(SALOME_Logger.Logger)

                if not self.m_pInterfaceLogger is None:
                  ok = 1

              except CosNaming.NamingContext.NotFound, e :
                    if steps == 1: print "Caught exception: Naming Service can't found Logger"
              except (CORBA.TRANSIENT,CORBA.OBJECT_NOT_EXIST,CORBA.COMM_FAILURE):
                    if steps == 1: print "Caught CORBA::SystemException CommFailure"
              except CORBA.SystemException, e:
                    if steps == 1: print "Caught CORBA::SystemException."
コード例 #8
0
ファイル: rtmstart.py プロジェクト: yuki-shark/rtmros_common
def start_cosname(cosnames, port_number):
    p = None
    pid = None
    start_naming = True

    for p in psutil.process_iter():
        try:
            # find process using port_number
            if filter(lambda c: c.local_address[1] == port_number,
                      p.get_connections()):
                print "\033[31m[rtmlaunch]", p.name, "is already started with port", port_number, "\033[0m"

                try:
                    orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID)
                    nameserver = orb.resolve_initial_references("NameService")
                    rootnc = nameserver._narrow(CosNaming.NamingContext)

                    def findObject(name, kind="", rnc=None):
                        nc = CosNaming.NameComponent(name, kind)
                        if not rnc: rnc = rootnc
                        return rnc.resolve([nc])

                    cxt = findObject(socket.gethostname(), "host_cxt")
                    obj = findObject("manager", "mgr", cxt)
                    start_naming = False
                except CosNaming.NamingContext.NotFound, ex:
                    # this is ok since host_cxt, manager is not bind
                    start_naming = False
                    pass
                except:
                    print "\033[31m[rtmlaunch] name server is unreachable so kill process\033[0m"
                    print "\033[31m[rtmlaunch] kill ", cosnames, " of pid", p.pid, "\033[0m"
                    p.terminate()
コード例 #9
0
def main(argv):

    print 'Starting the Server...'

    # Initialise the ORB.
    orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID)

    # Initialise the POA.
    poa = orb.resolve_initial_references("RootPOA")

    # Create an instance of the server and get its reference
    # this will also implicitly activate the object in the POA
    ei = HelloWorldServer()
    eo = ei._this()

    # Initialise and activate the POA MAnager
    poaManager = poa._get_the_POAManager()
    poaManager.activate()

    # Write the stringified object reference to a file (this is just a 'cheap
    # and cheerful' way of making the object reference available to the
    # client!).
    f = open('server.ref', 'w')
    f.write(orb.object_to_string(eo))
    f.flush()

    print 'Server created and accepting requests...'

    # Start the event loop.
    orb.run()
コード例 #10
0
 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)
     self._error = False
     self._ref = self._this()
     self._eclist = []
コード例 #11
0
def main(argv):
    # Initialize the ORB
    orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID)

    # Get a reference to the Naming service
    ns = orb.resolve_initial_references("NameService")
    rootContext = ns._narrow(CosNaming.NamingContext)

    if rootContext == None:
        print "Failed to narrow the root naming context"
        sys.exit(1)

# resolve the Count object in the Naming service
    countName = [CosNaming.NameComponent("countName", "")]
    counter = rootContext.resolve(countName)

    #Set sum to initial value of 0
    print "Setting sum to 0"

    counter._set_sum(0)

    # Calculate Start time
    startTime = time()

    # Increment 1000 times
    print "Incrementing"
    for i in range(1000):
        counter.increment()

# Calculate stop time   print out statistics
    stopTime = time()
    print "Avg Ping = ", stopTime - startTime, " msecs"
    print "Sum = ", counter._get_sum()
コード例 #12
0
    def __init__(self, orb=None):
        """
        Standard Constructor, with ORB reference.
 
        Initializes the naming service root context
        """
        #MESSAGE ( "SALOME_NamingServicePy_i::__init__" )
        if orb is None:
            orb = CORBA.ORB_init([''], CORBA.ORB_ID)
        self._orb = orb
        # initialize root context and current context
        ok = 0
        steps = 240
        while steps > 0 and ok == 0:
            try:
                obj = self._orb.resolve_initial_references("NameService")
                self._root_context = obj._narrow(CosNaming.NamingContext)
                self._current_context = self._root_context

                if self._root_context is None:
                    #MESSAGE ( "Name Service Reference is invalid" )
                    #sys.exit(1)
                    MESSAGE(" Name service not found")
                else:
                    ok = 1
            except (CORBA.TRANSIENT, CORBA.OBJECT_NOT_EXIST,
                    CORBA.COMM_FAILURE):
                MESSAGE(" Name service not found")
            time.sleep(0.25)
            steps = steps - 1
        if steps == 0 and self._root_context is None:
            MESSAGE("Name Service Reference is invalid")
            sys.exit(1)
コード例 #13
0
def main():
    orb = CORBA.ORB_init(sys.argv)
    poa = orb.resolve_initial_references("RootPOA")
    poa._get_the_POAManager().activate()
    naming = OpenRTM_aist.CorbaNaming(orb, "localhost")
    servant = ComponentObserver_i()
    oid = poa.servant_to_id(servant)
    provider = poa.id_to_reference(oid)

    rtc = naming.resolve("COCTestRTC0.rtc")._narrow(RTC.RTObject)
    config = rtc.get_configuration()
    properties = [
        OpenRTM_aist.NVUtil.newNV("heartbeat.enable", "YES"),
        OpenRTM_aist.NVUtil.newNV("heartbeat.interval", "10"),
        OpenRTM_aist.NVUtil.newNV("observed_status", "ALL")
    ]

    id = OpenRTM_aist.toTypename(servant)
    sprof = SDOPackage.ServiceProfile("test_id", id, properties, provider)

    ret = config.add_service_profile(sprof)
    flag = True
    print("If you exit program, please input 'q'.")
    sys.stdin.readline()
    ret = config.remove_service_profile("test_id")
    print("test program end. ret : ", ret)
    return
コード例 #14
0
def main(argv):
    # Initialise the ORB.
    orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID)

    # Initialise the POA.
    poa = orb.resolve_initial_references("RootPOA")

    # Create an instance of the server and get its reference
    # this will also implicitly activate the object in the POA
    ei = CounterServer()
    eo = ei._this()

    # Initialise and activate the POA Manager
    poaManager = poa._get_the_POAManager()
    poaManager.activate()

    # Get a reference to the Naming service
    ns = orb.resolve_initial_references("NameService")
    rootContext = ns._narrow(CosNaming.NamingContext)

    if rootContext == None:
        print "Failed to narrow the root naming context"
        sys.exit(1)

    # bind the Count object in the Naming service
    countName = [CosNaming.NameComponent("countName", "")]
    rootContext.rebind(countName, eo)

    print 'Server created and accepting requests...'

    # Start the event loop.
    orb.run()
コード例 #15
0
    def setup_component_connection(self):
        ''' Mostly contains CORBA stuff.
            Will create self.PortHandle.  
            This is an outbound connection.'''

        self.CORBA_being_used = False

        if True:		
         self.CORBA_being_used = True
         self.orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID)
         obj = self.orb.resolve_initial_references("NameService")
         rootContext = obj._narrow(CosNaming.NamingContext)
         if rootContext is None:
             print "Failed to narrow the root naming context"
             sys.exit(1)
         name = [CosNaming.NameComponent(self.component_name[0],""),
         CosNaming.NameComponent(self.component_name[1],""),
         CosNaming.NameComponent(self.component_name[2],"")]
     
         try:
             ResourceRef = rootContext.resolve(name)
     
         except:
             print "Required resource not found"
             sys.exit(1)
     
         #connect to an existing port
         ResourceHandle = ResourceRef._narrow(CF.Resource)
         PortReference = ResourceHandle.getPort(self.port_name)
         if PortReference is None:
             print "Failed to get Port reference"
         self.PortHandle = PortReference._narrow(standardInterfaces__POA.complexShort)
コード例 #16
0
    def __init__(self, clients=defaultClients, url=None, host=None):
        """
    Initialize CORBA and create default clients.
    :param url: URL in the IOR, corbaloc, corbalocs, and corbanames formats.
                For a remote corba server, use
                url = "corbaloc:iiop:<host>:<port>/NameService".
                If None, url is initialized with param host, or alternatively with _getIIOPurl
    :param host: if not None, url is set to = "corbaloc:iiop:" + str(host) + "/NameService"
    """
        if host is not None:
            url = "corbaloc:iiop:" + str(host) + "/NameService"
        elif url is None:
            url = _getIIOPurl()
        import sys
        self.orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID)
        obj = self.orb.string_to_object(url)
        self.rootContext = obj._narrow(CosNaming.NamingContext)
        if self.rootContext is None:
            raise CorbaError('failed to narrow the root context')

        for client in clients:
            self.makeClient(client)

        # In the python interpreter of gepetto-gui, gui.createWindow
        # crashes for an obscure reason. This hack makes it work.
        try:
            from PythonQt.gepetto import MainWindow
            # At this point, we are in the python interpreter of gepetto-gui
            self.gui.createWindow = lambda x: MainWindow.instance().createView(
                x).windowID()
        except ImportError:
            # At this point, we are NOT in the python interpreter of gepetto-gui
            pass
コード例 #17
0
 def getObject(self,
               ns="localhost",
               context="fred",
               object="ZoneGenerator"):
     try:
         # Initialise the ORB
         orb = CORBA.ORB_init([
             "-ORBnativeCharCodeSet", "UTF-8", "-ORBInitRef",
             "NameService=corbaname::" + ns
         ], CORBA.ORB_ID)
         # Obtain a reference to the root naming context
         obj = orb.resolve_initial_references("NameService")
         rootContext = obj._narrow(CosNaming.NamingContext)
         if rootContext is None:
             raise ZoneException("Failed to narrow the root naming context")
         # Resolve the name "fred.context/ZoneGenerator.Object"
         name = [
             CosNaming.NameComponent(context, "context"),
             CosNaming.NameComponent(object, "Object")
         ]
         obj = rootContext.resolve(name)
         # Narrow the object to an fred::ZoneGenerator
         zone_orb_object = obj._narrow(ccReg.ZoneGenerator)
         if (zone_orb_object is None):
             raise ZoneException("Obtained object reference is not "
                                 "ccReg::ZoneGenerator")
         return zone_orb_object
     except CORBA.TRANSIENT, e:
         raise ZoneException("Is nameservice running? (%s)" % e)
コード例 #18
0
ファイル: jackhammer.py プロジェクト: koonihc/framework-core
 def __init__(self):
     args = ["-ORBoneCallPerConnection", "0"]
     self.orb = CORBA.ORB_init(args, CORBA.ORB_ID)
     self.inc = self.orb.resolve_initial_references('NameService')._narrow(
         CosNaming.NamingContext)
     self.runThreads = threading.Event()
     self.threads = []
コード例 #19
0
def initialiseServer(c=None,l=None,block=0,controlName="Control"):
    """c is the control object
    l is a threading.Lock object (or soemthing with acquire and release methods
    block is whether to block here, or return.
    controlName is the darc prefix+Control.
    """
    # Initialise the ORB and find the root POA
    orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID)
    poa = orb.resolve_initial_references("RootPOA")
    # Create an instance of ControlServer and a Control object reference
    ei = ControlServer(c,l)
    eo = ei._this()
    # Obtain a reference to the root naming context
    obj         = orb.resolve_initial_references("NameService")
    try:
        rootContext = obj._narrow(CosNaming.NamingContext)
    except:
        print "Unable to connect the nameservice"
        return None
    if rootContext is None:
        print "Failed to narrow the root naming context"
        sys.exit(1)
    # Bind a context named "rtcServer.my_context" to the root context
    name = [CosNaming.NameComponent("darc", "control")]
    try:
        rtcServerContext = rootContext.bind_new_context(name)
        print "New rtcServer context bound"
    except CosNaming.NamingContext.AlreadyBound, ex:
        print "RtcControl context already exists"
        obj = rootContext.resolve(name)
        rtcServerContext = obj._narrow(CosNaming.NamingContext)
        if rtcServerContext is None:
            print "rtcServer.mycontext exists but is not a NamingContext"
            sys.exit(1)
コード例 #20
0
def GetObject(module_name, obj_name, context_name , poa_path = None):
    """
    def GetObject(module_name, obj_name, context_name , poa_path = None):
    Arguments:
    - `module_name`:
    - `context_name`: list of names to the object [("name1","context1"),("name2","context2"),...,("name","object")]
    - `obj_name`: typically "module.interface as" defined in idl file
    - `poa_path`: path to omniidl generated interface

    Example:
         loscli=corba_util.GetObject("robotviewer_corba","robotviewer_corba.Localstepper",[('robotviewer_corba','context'),('localstepper','object')])
    """
    if poa_path:
        sys.path = [poa_path] + sys.path

    exec("import %s"%module_name)

    # Initialise the ORB
    orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID)

    # Obtain a reference to the root naming context
    obj         = orb.resolve_initial_references("NameService")
    rootContext = obj._narrow(CosNaming.NamingContext)

    if context_name:
        try:
            name = [ CosNaming.NameComponent(component[0],component[1]) for component in context_name]
        except Exception,e:
            raise Exception("Failed to construct name %s"%str(context_name))
        else:
            obj =  rootContext.resolve(name)
コード例 #21
0
ファイル: controlCorba.py プロジェクト: david-jenkins/darc
def unbind(controlName="Control"):
    # Initialise the ORB and find the root POA
    orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID)
    poa = orb.resolve_initial_references("RootPOA")
    obj = orb.resolve_initial_references("NameService")
    try:
        rootContext = obj._narrow(CosNaming.NamingContext)
    except:
        print "Cannot unbind: Unable to connect the nameservice"
        return None
    if rootContext is None:
        print "Cannot unbind: Failed to narrow the root naming context"
        return None
    # Bind a context named "darc.server" to the root context
    name = [CosNaming.NameComponent("darc", "server")]
    try:
        rtcServerContext = rootContext.bind_new_context(name)
        print "New darc context bound"
    except CosNaming.NamingContext.AlreadyBound, ex:
        print "RtcControl context already exists"
        obj = rootContext.resolve(name)
        rtcServerContext = obj._narrow(CosNaming.NamingContext)
        if rtcServerContext is None:
            print "darc.server exists but is not a NamingContext"
            return None
コード例 #22
0
    def setUp(self):
        self.setContext()
        if self.srcData:
            self.seq = self.srcData
        else:
            self.seq = range(50)
            if self.ptype == 'Int8':
                self.seq = numpy.array(self.seq, numpy.int8).tostring()
            if self.ptype == 'UInt8':
                self.seq = numpy.array(self.seq, numpy.uint8).tostring()

        self.orb = CORBA.ORB_init()
        self.rootPOA = self.orb.resolve_initial_references("RootPOA")
        self.logger = logging.getLogger(self.ptype[0])
        self.logger.setLevel(logging.NOTSET)
        #self.logger.setLevel(logging.INFO)

        self.ip1 = self.bio_in_module("sink_1")
        self.ip1_oid = self.rootPOA.activate_object(self.ip1)
        self.ip2 = self.bio_in_module("sink_2")
        self.ip2_oid = self.rootPOA.activate_object(self.ip2)
        self.ip3 = self.bio_in_module("sink_3")
        self.ip3_oid = self.rootPOA.activate_object(self.ip3)
        self.ip4 = self.bio_in_module("sink_4")
        self.ip4_oid = self.rootPOA.activate_object(self.ip4)
        self.port = self.bio_out_module("multiout_source")
        self.port_oid = self.rootPOA.activate_object(self.port)
        self.setup_connection_table()
コード例 #23
0
def initCORBA():
    global rootnc, orb, nshost, nsport

    # from omniorb's document
    #  When CORBA::ORB_init() is called, the value for each configuration parameter is searched for in the following order:
    #  Command line arguments
    #  Environment variables
    # so init_CORBA will follow this order
    # first check command line argument
    try:
        n = sys.argv.index('-ORBInitRef')
        (nshost, nsport) = re.match(
            'NameService=corbaloc:iiop:(\w+):(\d+)/NameService',
            sys.argv[n + 1]).group(1, 2)
    except:
        if not nshost: nshost = socket.gethostname()
        if not nsport: nsport = 15005

    print "configuration ORB with ", nshost, ":", nsport
    os.environ[
        'ORBInitRef'] = 'NameService=corbaloc:iiop:{0}:{1}/NameService'.format(
            nshost, nsport)

    try:
        orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID)
        nameserver = orb.resolve_initial_references("NameService")
        rootnc = nameserver._narrow(CosNaming.NamingContext)
    except omniORB.CORBA.ORB.InvalidName, e:
        sys.exit('[ERROR] Invalide Name (hostname={0}).\n'.format(nshost) +
                 'Make sure the hostname is correct.\n' + str(e))
コード例 #24
0
ファイル: port.py プロジェクト: connectthefuture/HAWKEYE
 def _finish_init_(self):
     self._isStreaming = False
     self._greenletPeriodSec = 0.25
     
     if ('Uses' == self._obj._direction):
         datatype = self._obj._using.filename
     else:
         datatype = self._obj._interface.filename
     
     if ('bio_dataShort' == datatype):
         self._helper = StreamHelper_Short(self)
     elif('bio_dataUshort' == datatype):
         self._helper = StreamHelper_Ushort(self)
     elif('bio_dataOctet' == datatype):
         self._helper = StreamHelper_Octet(self)
     elif('bio_dataLong' == datatype):
         self._helper = StreamHelper_Long(self)
     elif('bio_dataUlong' == datatype):
         self._helper = StreamHelper_Ulong(self)
     elif('bio_dataFloat' == datatype):
         self._helper = StreamHelper_Float(self)
     elif('bio_dataDouble' == datatype):
         self._helper = StreamHelper_Double(self)
     else:
         # FIXME: Need more handlers...
         raise Port_BULKIO("No stream handler for this type: " + datatype)
     
     orb = CORBA.ORB_init()
     self._poa = orb.resolve_initial_references("RootPOA")
     self._poaManager = self._poa._get_the_POAManager()
     self._poaManager.activate()
     self._poa.activate_object(self._helper)
     
     self._connectionID = self.getID + "_stream"
コード例 #25
0
    def __init__(self, url=None):
        """
    Initialize CORBA and create default clients.
    :param url: URL in the IOR, corbaloc, corbalocs, and corbanames formats.
                For a remote corba server, use
                url = "corbaloc:iiop:<host>:<port>/NameService"
    """
        import sys
        self.orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID)
        if url is None:
            obj = self.orb.string_to_object(_getIIOPurl())
        else:
            obj = self.orb.string_to_object(url)
        self.rootContext = obj._narrow(CosNaming.NamingContext)
        if self.rootContext is None:
            raise CorbaError('failed to narrow the root context')

        # client of Graph interface
        name = [
            CosNaming.NameComponent("hpp", "corbaserver"),
            CosNaming.NameComponent("manipulation", "graph")
        ]

        try:
            obj = self.rootContext.resolve(name)
        except CosNaming.NamingContext.NotFound, ex:
            raise CorbaError('failed to find manipulation service.')
コード例 #26
0
ファイル: base.py プロジェクト: evanmccarter/redhawk-alpine
def scan(location=None):
    orb = _CORBA.ORB_init(_sys.argv, _CORBA.ORB_ID)

    if location:
        try:
            obj = orb.string_to_object('corbaname::' + location)
        except _CORBA.BAD_INV_ORDER:
            orb.destroy()
            orb = _CORBA.ORB_init(_sys.argv, _CORBA.ORB_ID)
            obj = orb.string_to_object('corbaname::' + location)
    else:
        try:
            obj = orb.resolve_initial_references("NameService")
        except _CORBA.BAD_INV_ORDER:
            orb.destroy()
            orb = _CORBA.ORB_init(_sys.argv, _CORBA.ORB_ID)
            obj = orb.resolve_initial_references("NameService")
    try:
        rootContext = obj._narrow(_CosNaming.NamingContext)
    except:
        raise RuntimeError('NameService not found')

    base_list = rootContext.list(100)
    domainsFound = []
    for entry in base_list[0]:
        if entry.binding_type != _CosNaming.ncontext:
            continue
        ctx = rootContext.resolve(entry.binding_name)
        objs = ctx.list(100)[0]
        foundDomain = False
        for obj in objs:
            if obj.binding_type == _CosNaming.nobject:
                if obj.binding_name[0].id == entry.binding_name[0].id:
                    tmpobj = ctx.resolve(obj.binding_name)
                    tmpDomainManager = tmpobj._narrow(_CF.DomainManager)
                    # Make sure Domain is alive
                    try:
                        fileManager = tmpDomainManager._get_fileMgr()
                    except:
                        continue
                    if tmpDomainManager:
                        foundDomain = True
                        break
        if foundDomain:
            domainsFound.append(entry.binding_name[0].id)

    return domainsFound
コード例 #27
0
ファイル: component.py プロジェクト: spirit0801/sca-jtnc
 def setAdditionalParameters(self, softwareProfile, application_registrar_ior, nic):
     super(Component,self).setAdditionalParameters(softwareProfile, application_registrar_ior, nic)
     orb = CORBA.ORB_init()
     obj = orb.string_to_object(application_registrar_ior)
     self._net = containers.NetworkContainer(nic)
     applicationRegistrar = obj._narrow(CF.ApplicationRegistrar)
     if applicationRegistrar != None:
         self._app = containers.ApplicationContainer(applicationRegistrar._get_app())
コード例 #28
0
ファイル: resource.py プロジェクト: spirit0801/core-framework
    def orbCreator():
        """
        A method to pass to callOmniorbpyWithTimeout.

        """

        orb = CORBA.ORB_init()
        queue.put(orb)
コード例 #29
0
    def setUp(self):
        self._orb = CORBA.ORB_init()
        self._poa = self._orb.resolve_initial_references("RootPOA")
        self._poa._get_the_POAManager().activate()

        self._com = CorbaObjectManager(self._orb, self._poa)

        self._obj = test_comp()
コード例 #30
0
 def setUp(self):
     self._domBooter, self._domMgr = self.launchDomainManager()
     # create listener interface
     orb = CORBA.ORB_init()
     self.chanMgr = ChannelManager(orb)
     self._app=None
     # Force creation
     self.channel1 = self.chanMgr.createEventChannel("TestChan", force=True)