예제 #1
0
 def _process_binding(self, binding, orb, filter):
     if filtered([URI.nameToString(binding.binding_name)], filter):
         # Do not pass anything which does not pass the filter
         return
     trimmed_filter = trim_filter(deepcopy(filter))
     with self._mutex:
         # Process a binding, creating the correct child type for it and
         # adding that child to this node's children.
         if binding.binding_type == CosNaming.nobject:
             # This is a leaf node; either a component or a manager.  The
             # specific type can be determined from the binding name kind.
             if binding.binding_name[0].kind == "mgr":
                 name = URI.nameToString(binding.binding_name)
                 obj = self._context.resolve(binding.binding_name)
                 if not obj:
                     leaf = Zombie(name, self)
                     return
                 obj = obj._narrow(RTM.Manager)
                 try:
                     leaf = Manager(name, self, obj, dynamic=self.dynamic)
                 except CORBA.OBJECT_NOT_EXIST:
                     # Manager zombie
                     leaf = Zombie(name, self)
                 except CORBA.TRANSIENT:
                     # Manager zombie
                     leaf = Zombie(name, self)
                 self._add_child(leaf)
             elif binding.binding_name[0].kind == "rtc":
                 name = URI.nameToString(binding.binding_name)
                 obj = self._context.resolve(binding.binding_name)
                 try:
                     obj = obj._narrow(RTC.RTObject)
                 except CORBA.TRANSIENT, e:
                     if e.args[0] == TRANSIENT_ConnectFailed:
                         self._add_child(Zombie(name, self))
                         return
                     else:
                         raise
                 except CORBA.OBJECT_NOT_EXIST:
                     self._add_child(Zombie(name, self))
                     return
                 try:
                     leaf = Component(name, self, obj, dynamic=self.dynamic)
                 except CORBA.OBJECT_NOT_EXIST:
                     # Component zombie
                     leaf = Zombie(name, self, dynamic=self.dynamic)
                 except CORBA.TRANSIENT, e:
                     if e.args[0] == TRANSIENT_ConnectFailed:
                         self._add_child(Zombie(name, self))
                         return
                     else:
                         raise
                 self._add_child(leaf)
예제 #2
0
파일: rtc_handle.py 프로젝트: openrtc/eSEAT
    def proc_bd(self, bd, name_context, parent) :
#        print '-------------------------------------------------------------------'
#        print 'bd= ', bd
#        print 'name_context= ', name_context
#        print 'parent= ', parent
        rslt = []
        pre = ""
        if parent :
            pre = parent + "/"
        nam = pre + URI.nameToString(bd.binding_name)
        if bd.binding_type == CosNaming.nobject :
            tmp = name_context.resolve(bd.binding_name)
            self.obj_list[nam]=tmp
            print 'objcet '+nam+' was listed.'
            try :
                tmp = tmp._narrow(RTC.RTObject)
            except :
                print nam+' is not RTC.'
                tmp = None
            try :
                if tmp :
                   rslt = [[nam, tmp]]
                   self.rtc_handles[nam]=RtcHandle(nam,self,tmp)
                   print 'handle for '+nam+' was created.'
                else :
                   pass
            except :
                print nam+' is not alive.' , sys.exc_info()[0]
                pass
        else :
            tmp = name_context.resolve(bd.binding_name)
            tmp = tmp._narrow(CosNaming.NamingContext)
            rslt = self.list_obj1(tmp, nam)
        return rslt
예제 #3
0
    def bind_context(self, n, nc, force=False):
        key = URI.nameToString(n)
        if not force and self.object_table.has_key(key) :
            raise CosNaming.NamingContext.AlreadyBound()

        self.object_table[key] = (nc, CosNaming.ncontext)
        return
예제 #4
0
 def proc_bd(self, bd, name_context, parent):
     #        print('-------------------------------------------------------------------')
     #        print('bd= ', bd)
     #        print('name_context= ', name_context)
     #        print('parent= ', parent)
     rslt = []
     pre = ""
     if parent:
         pre = parent + "/"
     nam = pre + URI.nameToString(bd.binding_name)
     if bd.binding_type == CosNaming.nobject:
         tmp = name_context.resolve(bd.binding_name)
         self.obj_list[nam] = tmp
         print('objcet ' + nam + ' was listed.')
         try:
             tmp = tmp._narrow(RTC.RTObject)
         except BaseException:
             print(nam + ' is not RTC.')
             tmp = None
         try:
             if tmp:
                 rslt = [[nam, tmp]]
                 self.rtc_handles[nam] = RtcHandle(nam, self, tmp)
                 print('handle for ' + nam + ' was created.')
             else:
                 pass
         except BaseException:
             print(nam + ' is not alive.')
             pass
     else:
         tmp = name_context.resolve(bd.binding_name)
         tmp = tmp._narrow(CosNaming.NamingContext)
         rslt = self.list_obj1(tmp, nam)
     return rslt
예제 #5
0
파일: rtcmd.py 프로젝트: haraisao/eSEAT
  def resolveBindings(self, bind, name_context, parent):
    res = []
    prefix=parent

    if parent :
      prefix += "/"

    name = prefix + URI.nameToString(bind.binding_name)
    if bind.binding_type == CosNaming.nobject:
      if bind.binding_name[0].kind == "rtc":
        obj = name_context.resolve(bind.binding_name)
        try:
          obj._non_existent()
          obj = obj._narrow(RTObject)
          res = [[name, obj]]
          self.object_list[name] = obj
        except:
          obj = None
          res = [[name, obj]]
      else:
        pass
        #self.object_list[name] = None
    else:
      ctx = name_context.resolve(bind.binding_name)
      ctx = ctx._narrow(CosNaming.NamingContext)
      parent = name
      res = self.getRTObjectList( ctx, parent)
    return res
예제 #6
0
 def rebind(self, name, object):
     uri = URI.nameToString(name)
     log.debug('Rebinding "%s" into virtual NamingContext', uri)
     self.__lock.acquire()
     try:
         self.__context[uri] = object
     finally:
         self.__lock.release()
예제 #7
0
 def bind(self, name, object):
     uri = URI.nameToString(name)
     self.__lock.acquire()
     try:
         if uri in self.__context:
             raise CosNaming.NamingContext.AlreadyBound()
         log.debug('Binding "%s" into virtual NamingContext', uri)
         self.__context[uri] = object
     finally:
         self.__lock.release()
예제 #8
0
    def bind_one(self, n, obj, force=False):
        if len(n) == 1:
            key = URI.nameToString(n)
            if not force and self.object_table.has_key(key):
                raise CosNaming.NamingContext.AlreadyBound()

            #print(obj)
            self.object_table[key] = (obj, CosNaming.nobject)
            return
        else:
            raise CosNaming.NamingContext.InvalidName()
        return
예제 #9
0
    def rebind_context(self, n, nc):
        key = URI.nameToString(n)
        if self.object_table.has_key(key) :
            try:
                self.object_table[key][1].destroy()
            except e:
                raise e

            self.object_table[key] = (obj, CosNaming.ncontext)
        else:
            raise CosNaming.NamingContext.NotFound(CosNaming.NamingContext.missing_node, n)
        return
예제 #10
0
 def unbind(self, n):
     if len(n) == 1:
         key = URI.nameToString(n)
         if self.object_table.has_key(key) :
             del self.object_table[key]
         else:
             pass
             #raise CosNaming.NamingContext.NotFound(CosNaming.NamingContext.missing_node, n)
     else:
         cxt = self.get_next_context(n)
         cxt.unbind(n[1:])
         pass
     return 
예제 #11
0
    def get_next_context(self, n, force=False):
        key = URI.nameToString([n[0]])

        if self.object_table.has_key(key) :
            if self.object_table[key][1] == CosNaming.ncontext :
                return self.object_table[key][0]
            else:
                raise CosNamingContext.InvalidName()

        else:
           if force :
               nc = NamingContext_i(None, self.names_poa)
               self.object_table[key] = (nc, CosNaming.ncontext)
               return nc
           else:
               raise CosNaming.NamingContext.NotFound(CosNaming.NamingContext.missing_node, n)            
예제 #12
0
 def resolve(self, n):
     if len(n) == 1:
         key = URI.nameToString(n)
         if self.object_table.has_key(key) :
             if self.object_table[key][1] == CosNaming.nobject:
                 return self.object_table[key][0]
             elif self.object_table[key][1] == CosNaming.ncontext:
                 return self.object_table[key][0]._this()
             else:
                 raise CosNaming.NamingContext.NotFound(CosNaming.NamingContext.missing_node, n)
         else:
             raise CosNaming.NamingContext.NotFound(CosNaming.NamingContext.missing_node, n)
     else:
         cxt = self.get_next_context(n)
         return cxt.resolve(n[1:])
     return None
예제 #13
0
 def to_string(self, n):
     return URI.nameToString(n)
예제 #14
0
                        return
                    try:
                        leaf = Component(name, self, obj, dynamic=self.dynamic)
                    except CORBA.OBJECT_NOT_EXIST:
                        # Component zombie
                        leaf = Zombie(name, self, dynamic=self.dynamic)
                    except CORBA.TRANSIENT, e:
                        if e.args[0] == TRANSIENT_ConnectFailed:
                            self._add_child(Zombie(name, self))
                            return
                        else:
                            raise
                    self._add_child(leaf)
                else:
                    # Unknown type - add a plain node
                    name = URI.nameToString(binding.binding_name)
                    obj = self._context.resolve(binding.binding_name)
                    leaf = Unknown(name, self, obj)
                    self._add_child(leaf)
            else:
                # This is a context, and therefore a subdirectory.
                subdir_name = URI.nameToString(binding.binding_name)
                subdir = Directory(subdir_name, self, filter=trimmed_filter, dynamic=self.dynamic)
                subdir_context = self._context.resolve(binding.binding_name)
                subdir_context = subdir_context._narrow(CosNaming.NamingContext)
                subdir._parse_context(subdir_context, orb, filter=trimmed_filter)
                self._add_child(subdir)


# vim: tw=79