X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FKERNEL_PY%2F__init__.py;h=9c78533a928ebd85c6d974dc7b957636d5e8f2bc;hb=dc4b16b9dd53dd42139fd22ef26556861db58989;hp=7c779f2ff42143be0da077ec71311d6d8fe160c4;hpb=f790e0e9159968707d985595eae9fe61740912fe;p=modules%2Fkernel.git diff --git a/src/KERNEL_PY/__init__.py b/src/KERNEL_PY/__init__.py index 7c779f2ff..9c78533a9 100755 --- a/src/KERNEL_PY/__init__.py +++ b/src/KERNEL_PY/__init__.py @@ -1,5 +1,5 @@ # -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE +# Copyright (C) 2007-2016 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 @@ -26,7 +26,7 @@ # Module : SALOME # """ -Module salome gives access to Salome ressources. +Module salome gives access to Salome resources. variables: @@ -45,9 +45,7 @@ variables: - salome.sg : salome object to communicate with the graphical user interface (if any) - methods: - - updateObjBrowser(bool): - - getActiveStudyId(): - - getActiveStudyName(): + - updateObjBrowser(): - SelectedCount(): returns number of selected objects - getSelected(i): returns entry of selected object number i @@ -65,20 +63,18 @@ variables: - IDToObject(Entry): returns CORBA reference from entry - salome.myStudyName : active Study Name - - salome.myStudyId : active Study Id - salome.myStudy : the active Study itself (CORBA ior) - methods : defined in SALOMEDS.idl """ ## @package salome -# Module salome gives access to Salome ressources. +# Module salome gives access to Salome resources. # # \param salome.orb : CORBA orb object # \param salome.naming_service : instance of naming Service class (SALOME_NamingServicePy::SALOME_NamingServicePy_i) # \param salome.lcc : instance of lifeCycleCORBA class (SALOME_LifeCycleCORBA) # \param salome.sg : Salome object to communicate with the graphical user interface, if running (see interface in salome_iapp::SalomeOutsideGUI) # \param salome.myStudyName : active Study Name -# \param salome.myStudyId : active Study Id # \param salome.myStudy : the active Study (interface SALOMEDS::Study) # @@ -110,13 +106,13 @@ MATCH_ENDING_PATTERN="site-packages" + os.path.sep + "salome" def extend_path(pname): for dir in sys.path: - if not isinstance(dir, basestring) or not os.path.isdir(dir) or not dir.endswith(MATCH_ENDING_PATTERN): + if not isinstance(dir, str) or not os.path.isdir(dir) or not dir.endswith(MATCH_ENDING_PATTERN): continue subdir = os.path.join(dir, pname) # XXX This may still add duplicate entries to path on # case-insensitive filesystems if os.path.isdir(subdir) and subdir not in __path__: - if verbose(): print "INFO - The directory %s is appended to sys.path" % subdir + if verbose(): print("INFO - The directory %s is appended to sys.path" % subdir) __path__.append(subdir) extend_path(ROOT_PYTHONPACKAGE_NAME) @@ -166,90 +162,58 @@ if not flags: # pass orb, lcc, naming_service, cm,sg=None,None,None,None,None -myStudyManager, myStudyId, myStudy, myStudyName=None,None,None,None - -def setCurrentStudy(theStudy): - """ - Change current study : an existing one given by a study object. - - :param theStudy: the study CORBA object to set as current study - """ - global myStudyId, myStudy, myStudyName - myStudyId, myStudy, myStudyName =salome_study.setCurrentStudy(theStudy) - -def setCurrentStudyId(theStudyId=0): - """ - Change current study : an existing or new one given by Id. - - :param theStudyId: the study Id (optional argument) - 0 : create a new study (default). - n (>0) : try connection to study with Id = n, or create a new one - if study not found. - """ - global myStudyId, myStudy, myStudyName - myStudyId, myStudy, myStudyName =salome_study.setCurrentStudyId(theStudyId) +myStudy, myStudyName=None,None salome_initial=1 -def salome_init(theStudyId=0,embedded=0): +def salome_init(embedded=0): """ - Performs only once SALOME general purpose intialisation for scripts. - optional argument : theStudyId - When in embedded interpreter inside IAPP, theStudyId is not used - When used without GUI (external interpreter) - 0 : create a new study (default). - n (>0) : try connection to study with Id = n, or create a new one - if study not found. - If study creation, its Id may be different from theStudyId ! + Performs only once SALOME general purpose initialisation for scripts. Provides: orb reference to CORBA lcc a LifeCycleCorba instance naming_service a naming service instance cm reference to the container manager sg access to SALOME GUI (when linked with IAPP GUI) - myStudyManager the study manager - myStudyId active study identifier myStudy active study itself (CORBA reference) myStudyName active study name """ global salome_initial global orb, lcc, naming_service, cm global sg - global myStudyManager, myStudyId, myStudy, myStudyName + global myStudy, myStudyName try: if salome_initial: salome_initial=0 sg = salome_iapp_init(embedded) orb, lcc, naming_service, cm = salome_kernel_init() - myStudyManager, myStudyId, myStudy, myStudyName = salome_study_init(theStudyId) + myStudy, myStudyName = salome_study_init() pass pass - except RuntimeError, inst: + except RuntimeError as inst: # wait a little to avoid trace mix import time time.sleep(0.2) x = inst - print "salome.salome_init():", x - print """ + print("salome.salome_init():", x) + print(""" ============================================ May be there is no running SALOME session - salome.salome_init() is intented to be used + salome.salome_init() is intended to be used within an already running session ============================================ - """ + """) raise def salome_close(): - global salome_initial, myStudy, myStudyId, myStudyName + global salome_initial, myStudy, myStudyName try: - # study can be closed either from GUI or directly with salome.myStudy.Close() - myStudy.Close() + # study can be clear either from GUI or directly with salome.myStudy.Clear() + myStudy.Clear() except: pass salome_initial=1 salome_iapp_close() - salome_study_close() - myStudyId, myStudy, myStudyName=None,None,None pass