Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/kernel.git] / bin / waitContainers.py
1 #!/usr/bin/env python
2 import sys
3 import time
4 import orbmodule
5 import CosNaming
6 clt = orbmodule.client()
7 clt.waitNS("/ContainerManager")
8 obj = clt.orb.resolve_initial_references("NameService")
9 rootContext = obj._narrow(CosNaming.NamingContext)
10 cname = []
11 cname.append(CosNaming.NameComponent('Containers', 'dir'))
12
13 while(1):
14   try:
15     ccontext = rootContext.resolve(cname)
16     break
17   except CosNaming.NamingContext.NotFound, ex:
18     time.sleep(1)
19   except CosNaming.NamingContext.InvalidName, ex:
20     time.sleep(1)
21   except CosNaming.NamingContext.CannotProceed, ex:
22     time.sleep(1)
23   except (CORBA.TRANSIENT,CORBA.OBJECT_NOT_EXIST,CORBA.COMM_FAILURE):
24     time.sleep(1)
25
26 def waitContainer(mycont):
27   while(1):
28     bl,bi=ccontext.list(0)
29     if bi is not None:
30       ok,b=bi.next_one()
31       while(ok):
32         for s in b.binding_name :
33           if s.kind == "dir":
34             obj=ccontext.resolve([s])
35             scontext = obj._narrow(CosNaming.NamingContext)
36             bll,bii=scontext.list(0)
37             if bii is not None:
38               ok,bb=bii.next_one()
39               while(ok):
40                 for s in bb.binding_name :
41                    if s.id == mycont:
42                      print s.id
43                      return
44                 ok,bb=bii.next_one()
45         ok,b=bi.next_one()
46     sys.stdout.write('+')
47     sys.stdout.flush()
48     time.sleep(1)
49
50 for cont in sys.argv:
51   if cont != sys.argv[0]:
52     waitContainer(cont)
53