6 Copyright (C) 2009-2014 8 RT-Synthesis Research Group 9 Intelligent Systems Research Institute, 10 National Institute of Advanced Industrial Science and Technology (AIST), 13 Licensed under the Eclipse Public License -v 1.0 (EPL) 14 http://www.opensource.org/licenses/eclipse-1.0.txt 16 Object representing a directory node in the tree. 21 from copy
import deepcopy
23 from omniORB
import URI, CORBA, TRANSIENT_ConnectFailed
42 '''Node representing a naming context on a name server. 44 Name servers contain contexts (including the root context) and objects. For 45 us, contexts are directories and objects are managers and components. A 46 directory context may specialise as a name server context, in which case 47 it represents the root context of a name server. 50 def __init__(self, name=None, parent=None, children=None, filter=[], *args,
52 '''Constructor. Calls the TreeNode constructor.''' 53 super(Directory, self).
__init__(name=name, parent=parent,
54 children=children, filter=filter, *args, **kwargs)
57 '''Reparse all children of this directory. 59 This effectively rebuilds the tree below this node. 61 This operation takes an unbounded time to complete; if there are a lot 62 of objects registered below this directory's context, they will all 70 '''Unbind an object from the context represented by this directory. 72 Warning: this is a dangerous operation. You may unlink an entire 73 section of the tree and be unable to recover it. Be careful what you 76 The name should be in the format used in paths. For example, 77 'manager.mgr' or 'ConsoleIn0.rtc'. 81 id, sep, kind = name.rpartition(
'.')
85 name = CosNaming.NameComponent(id=str(id), kind=str(kind))
87 self.context.unbind([name])
88 except CosNaming.NamingContext.NotFound:
93 '''The object representing this naming context.''' 99 '''Is this node a directory?''' 107 bindings, bindings_it = context.list(
Options().\
108 get_option(
'max_bindings'))
109 for binding
in bindings:
114 remaining, bindings = bindings_it.next_n(
Options().\
115 get_option(
'max_bindings'))
117 for binding
in bindings:
119 remaining, binding = bindings_it.next_n(
Options().\
120 get_option(
'max_bindings'))
121 bindings_it.destroy()
131 if binding.binding_type == CosNaming.nobject:
134 if binding.binding_name[0].kind ==
'mgr':
136 obj = self._context.resolve(binding.binding_name)
140 obj = obj._narrow(RTM.Manager)
143 except CORBA.OBJECT_NOT_EXIST:
146 except CORBA.TRANSIENT:
150 elif binding.binding_name[0].kind ==
'rtc':
152 obj = self._context.resolve(binding.binding_name)
154 obj = obj._narrow(RTC.RTObject)
155 except CORBA.TRANSIENT, e:
156 if e.args[0] == TRANSIENT_ConnectFailed:
161 except CORBA.OBJECT_NOT_EXIST:
166 except CORBA.OBJECT_NOT_EXIST:
169 except CORBA.TRANSIENT, e:
170 if e.args[0] == TRANSIENT_ConnectFailed:
179 obj = self._context.resolve(binding.binding_name)
180 leaf =
Unknown(name, self, obj)
185 subdir =
Directory(subdir_name, self, filter=trimmed_filter,
187 subdir_context = self._context.resolve(binding.binding_name)
188 subdir_context = subdir_context._narrow(CosNaming.NamingContext)
189 subdir._parse_context(subdir_context, orb,
190 filter=trimmed_filter)
195 '''Convert a CORBA CosNaming.Name to a string.''' 197 if type(name)
is not list
and type(name)
is not tuple:
198 raise NotCORBANameError(name)
200 raise NotCORBANameError(name)
206 parts.append(
'{0}.{1}'.format(nc.id, nc.kind))
207 return '/'.join(parts)
def __init__(self, name=None, parent=None, children=None, filter=[], args, kwargs)
def corba_name_to_string(name)
def trim_filter(filter, levels=1)
def _remove_all_children(self)
def filtered(path, filter)
def _add_child(self, new_child)
def _parse_context(self, context, orb, filter=[])
def _process_binding(self, binding, orb, filter)