-# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
+# Copyright (C) 2007-2019 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.
+# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
import PYHELLO_ORB__POA
import SALOME_ComponentPy
import SALOME_DriverPy
-
-from PYHELLO_utils import *
+import SALOMEDS
+from PYHELLO_utils import findOrCreateComponent, objectID, moduleName, getStudy
class PYHELLO(PYHELLO_ORB__POA.PYHELLO_Gen,
SALOME_ComponentPy.SALOME_ComponentPy_i,
Engines::EngineComponent CORBA interface - SALOME component) and SALOME_DriverPy_i
(implementation of SALOMEDS::Driver CORBA interface - SALOME module's engine).
"""
- def __init__ ( self, orb, poa, contID, containerName, instanceName,
+ def __init__ ( self, orb, poa, contID, containerName, instanceName,
interfaceName ):
SALOME_ComponentPy.SALOME_ComponentPy_i.__init__(self, orb, poa,
- contID, containerName, instanceName, interfaceName, 0)
+ contID, containerName, instanceName, interfaceName, False)
SALOME_DriverPy.SALOME_DriverPy_i.__init__(self, interfaceName)
#
self._naming_service = SALOME_ComponentPy.SALOME_NamingServicePy_i( self._orb )
banner = "Hello %s!" % name
return banner
+ """
+ Intentionnally raises an exception for test purposes.
+ """
+ def raiseAnException( self ):
+ import SALOME
+ exData = SALOME.ExceptionStruct( SALOME.BAD_PARAM, "Test exception in raiseAnException()",'',0)
+ raise SALOME.SALOME_Exception( exData )
+
"""
Create object.
"""
- def createObject( self, study, name ):
+ def createObject( self, name ):
+ study = getStudy()
builder = study.NewBuilder()
- father = findOrCreateComponent( study )
- object = builder.NewObject( father )
- attr = builder.FindOrCreateAttribute( object, "AttributeName" )
+ father = findOrCreateComponent()
+ obj = builder.NewObject( father )
+ attr = builder.FindOrCreateAttribute( obj, "AttributeName" )
attr.SetValue( name )
- attr = builder.FindOrCreateAttribute( object, "AttributeLocalID" )
+ attr = builder.FindOrCreateAttribute( obj, "AttributeLocalID" )
attr.SetValue( objectID() )
pass
"""
Dump module data to the Python script.
"""
- def DumpPython( self, study, isPublished ):
+ def DumpPython( self, isPublished, isMultiFile ):
abuffer = []
- abuffer.append( "def RebuildData( theStudy ):" )
names = []
+ study = getStudy()
father = study.FindComponent( moduleName() )
if father:
- iter = study.NewChildIterator( father )
- while iter.More():
- name = iter.Value().GetName()
+ iterator = study.NewChildIterator(father)
+ while iterator.More():
+ name = iterator.Value().GetName()
if name: names.append( name )
- iter.Next()
+ iterator.Next()
pass
pass
if names:
- abuffer += [ " from batchmode_salome import lcc" ]
- abuffer += [ " import PYHELLO_ORB" ]
- abuffer += [ " " ]
- abuffer += [ " pyhello = lcc.FindOrLoadComponent( 'FactoryServerPy', '%s' )" % moduleName() ]
- abuffer += [ " " ]
- abuffer += [ " pyhello.createObject( theStudy, '%s' )" % name for name in names ]
+ abuffer += [ "import salome" ]
+ abuffer += [ "import PYHELLO_ORB" ]
+ abuffer += [ "" ]
+ abuffer += [ "pyhello = salome.lcc.FindOrLoadComponent( 'FactoryServerPy', '%s' )" % moduleName() ]
+ abuffer += [ "" ]
+ abuffer += [ "pyhello.createObject( '%s')" % name for name in names ]
+ abuffer += [ "" ]
pass
- abuffer += [ " " ]
- abuffer.append( " pass" )
- abuffer.append( "\0" )
- return ("\n".join( abuffer ), 1)
+ if isMultiFile:
+ abuffer = [ " " + s for s in abuffer ]
+ abuffer[0:0] = [ "def RebuildData():" ]
+ abuffer += [ " pass" ]
+ abuffer += [ "\0" ]
+ res = "\n".join( abuffer )
+ return (res.encode(), 1)