This file is indexed.

/usr/lib/salome/bin/SALOME_ComponentPy.py is in salome-kernel 6.5.0-7ubuntu2.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
#! /usr/bin/env python
#  -*- coding: iso-8859-1 -*-
# Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
#
# Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License.
#
# 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 : webmaster.salome@opencascade.com
#

#  SALOME Container : implementation of container and engine for Kernel
#  File   : SALOME_ComponentPy.py
#  Author : Paul RASCLE, EDF
#  Module : SALOME
#  $Header: /home/server/cvs/KERNEL/KERNEL_SRC/src/Container/SALOME_ComponentPy.py,v 1.11.2.5.14.4.12.1 2012-04-12 14:05:03 vsr Exp $

## @package SALOME_ComponentPy
# \brief python implementation of component interface for Kernel
#

import os
import sys
import time
import string
import signal
from omniORB import CORBA, PortableServer, any
import Engines, Engines__POA
import Registry
from Utils_Identity import *
from SALOME_NamingServicePy import *
from libNOTIFICATION import *

from SALOME_utilities import *

from thread import *

#=============================================================================

_Sleeping = 0

## define an implementation of the component interface Engines::Component
#
#  
class SALOME_ComponentPy_i (Engines__POA.EngineComponent):
    _orb = None
    _poa = None
    _fieldsDict = []
    _studyId = -1
    
    #-------------------------------------------------------------------------

    def __init__ (self, orb, poa, contID, containerName,
                  instanceName, interfaceName, notif=0):
        # Notif for notification services
        # NOT YET IMPLEMENTED
        MESSAGE(  "SALOME_ComponentPy_i::__init__" + " " + str (containerName) + " " + str(instanceName) + " " + str(interfaceName) )
        self._orb = orb
        self._poa = poa
        self._instanceName = instanceName
        self._interfaceName = interfaceName
        self._containerName = containerName
        self._notif = notif
        self._myConnexionToRegistry = 0
        self._graphName = ''
        self._nodeName = ''
        self._serviceName = ''
        self._ThreadId = 0
        self._StartUsed = 0
        self._ThreadCpuUsed = 0
        self._Executed = 0
        self._contId = contID

        naming_service = SALOME_NamingServicePy_i(self._orb)
        myMachine=getShortHostName()
        Component_path = self._containerName + "/" + self._instanceName
        MESSAGE(  'SALOME_ComponentPy_i Register' + str( Component_path ) )
        id_o = poa.activate_object(self)
        compo_o = poa.id_to_reference(id_o)
        naming_service.Register(compo_o, Component_path)

        # Add componentinstance to registry
        obj = naming_service.Resolve('/Registry')
        if obj is None:
            MESSAGE(  "Registry Reference is invalid" )
        else:
            regist = obj._narrow(Registry.Components)
            if regist is None:
                MESSAGE(  "Registry Reference is invalid" )
            else:
                ior = orb.object_to_string(contID)
                MESSAGE(  ior )

                lesInfos = Identity(self._instanceName)
                infos = Registry.Infos(lesInfos._name,
                                       lesInfos._pid,
                                       lesInfos._machine,
                                       lesInfos._adip,
                                       lesInfos._uid,
                                       lesInfos._pwname,
                                       int(lesInfos._tc_start),
                                       0,0,0,
                                       lesInfos._cdir,
                                       -1,
                                       ior)

                res = regist.add(infos)

        self._notifSupplier = NOTIFICATION_Supplier_Swig(instanceName, notif)

    #-------------------------------------------------------------------------

    def _get_instanceName(self):
        MESSAGE(  "SALOME_ComponentPy_i::_get_instanceName" )
        return self._instanceName
    
    #-------------------------------------------------------------------------

    def _get_interfaceName(self):
        MESSAGE(  "SALOME_ComponentPy_i::_get_interfaceName" )
        return self._interfaceName

    #-------------------------------------------------------------------------

    def ping(self):
        MESSAGE(  "SALOME_ComponentPy_i::ping() pid " + str(os.getpid()) )
        
    #-------------------------------------------------------------------------

    def setProperties(self, dico):
        self._fieldsDict = dico
    
    #-------------------------------------------------------------------------

    def getProperties(self):
        return self._fieldsDict

    #-------------------------------------------------------------------------

    def destroy(self):
        MESSAGE(  "SALOME_ComponentPy_i::destroy" )
        id = self._poa.servant_to_id(self)
        self._poa.deactivate_object(id)
        return
        
    #-------------------------------------------------------------------------

    def GetContainerRef(self):
        MESSAGE(  "SALOME_ComponentPy_i::GetContainerRef" )
        return self._contId._narrow(Engines.Container)
                
    #-------------------------------------------------------------------------

    def beginService(self , serviceName ):
        MESSAGE(  "Send BeginService notification for " + str(serviceName) + " for graph/node " + str(self._graphName) + " " + str(self._nodeName) )
        MESSAGE(  "Component instance : " + str ( self._instanceName ) )
        self._serviceName = str(serviceName)
        self._ThreadId = get_ident()
        self._StartUsed = 0
        self._StartUsed = self.CpuUsed_impl()
        self._ThreadCpuUsed = 0
        self._Executed = 1
        print "beginService for ",serviceName," Component instance : ",self._instanceName
        MESSAGE( "SALOME_ComponentPy_i::beginService _StartUsed " + str( self._ThreadId ) + " " + str( self._StartUsed ) )
        for e in self._fieldsDict:
          key=e.key
          value=any.from_any(e.value)
          if isinstance(value,str):
            os.environ[key]=value
        

    #-------------------------------------------------------------------------

    def endService(self , serviceName ):
        MESSAGE(  "Send EndService notification for " + str( self._ThreadId ) + " " + str(serviceName) + " for graph/node " + str(self._graphName) + " " + str(self._nodeName) + " CpuUsed " + str( self.CpuUsed_impl() ) )
        MESSAGE(  "Component instance : " + str(self._instanceName) )
        print "endService for",serviceName,"Component instance :",self._instanceName,"Cpu Used:",self.CpuUsed_impl()," (s) "


    #-------------------------------------------------------------------------

    def sendMessage(self , event_type , message ):
        self._notifSupplier.Send(self.graphName(), self.nodeName(), event_type, message)

    #-------------------------------------------------------------------------

    def Names(self , GraphName , NodeName ):
        MESSAGE(  "SALOME_ComponentPy_i::Names" + str(GraphName) + str(NodeName) )
        self._graphName = GraphName
        self._nodeName = NodeName
        
    #-------------------------------------------------------------------------

    def graphName(self):
        return self._graphName

    #-------------------------------------------------------------------------

    def nodeName(self):
        return self._nodeName

    #-------------------------------------------------------------------------

    def Killer(self, ThreadId, signum):
        #if ThreadId > 0:
            #if signum == 0:
                #if pthread_cancel(ThreadId): <- from C++
                #   return 0
                #else:
                #   MESSAGE()
            #else:
                #if pthread_kill(ThreadId): <- from C++
                #   return 0
                #else:
                #   MESSAGE()
        return 1                 
    
    #-------------------------------------------------------------------------

    def Kill_impl(self):
        MESSAGE(  "SALOME_ComponentPy_i::Kill_impl" )
        RetVal = 0
        if self._ThreadId > 0 & self._ThreadId != get_ident():
            RetVal = Killer(self._ThreadId,0)
            self._ThreadId = 0
        return RetVal

    #-------------------------------------------------------------------------

    def Stop_impl(self):
        MESSAGE(  "SALOME_ComponentPy_i::Stop_impl" )
        RetVal = 0
        if self._ThreadId > 0 & self._ThreadId != get_ident():
            RetVal = Killer(self._ThreadId,0)
            self._ThreadId = 0
        return RetVal

    #-------------------------------------------------------------------------

    def Suspend_impl(self):
        MESSAGE(  "SALOME_ComponentPy_i::Suspend_impl" )
        global _Sleeping
        RetVal = 0
        if self._ThreadId > 0 & self._ThreadId != get_ident():
            if _Sleeping > 0:
                return 0
            else:
                RetVal = Killer(self._ThreadId, signal.SIGINT)
                if RetVal > 0:
                    _Sleeping = 1
        return RetVal

    #-------------------------------------------------------------------------

    def Resume_impl(self):
        MESSAGE(  "SALOME_ComponentPy_i::Resume_impl" )
        global _Sleeping
        RetVal = 0
        if self._ThreadId > 0 & self._ThreadId != get_ident():
            if _Sleeping > 0:
                _Sleeping = 0
                RetVal = 1
            else:
                RetVal = 0
        return RetVal

    #-------------------------------------------------------------------------

    def CpuUsed_impl(self):
        if ( self._ThreadId | self._Executed ) :
            if self._ThreadId == get_ident() :
                cpu = time.clock()
                self._ThreadCpuUsed = cpu - self._StartUsed
                MESSAGE( "SALOME_ComponentPy_i::CpuUsed_impl " + self._serviceName + " " + str( int(cpu) ) + " - " + str( self._StartUsed ) + " = " + str( self._ThreadCpuUsed ) )
                return self._ThreadCpuUsed
            MESSAGE( "SALOME_ComponentPy_i::CpuUsed_impl " + self._serviceName + " " + str( self._ThreadCpuUsed ) )
            return self._ThreadCpuUsed
        MESSAGE( "SALOME_ComponentPy_i::CpuUsed_impl self._StartUsed " + self._serviceName + " " + str(self._StartUsed) )
        return 0

    #-------------------------------------------------------------------------
   
    def DumpPython(self, theStudy, isPublished, isMultiFile):
        aBuffer = "\0"
        if isMultiFile :
            aBuffer = "def RebuildData(theStudy): pass\n\0"
        return (aBuffer, 1)

    #-------------------------------------------------------------------------    

    def getStudyId(self):
        return self._studyId

    #-------------------------------------------------------------------------    

    def hasObjectInfo(self):
        return 0

    #-------------------------------------------------------------------------    

    def getObjectInfo(self, studyId, entry):
        return ""