From a3e06c48edff8fe9786ac7a2330d3ed5bad2f905 Mon Sep 17 00:00:00 2001 From: akl Date: Thu, 25 Sep 2014 18:38:50 +0400 Subject: [PATCH] Load study with name given as command line argument in batch mode. --- bin/runSalome.py | 12 ++++++++---- src/KERNEL_PY/salome_study.py | 13 +++++++++++-- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/bin/runSalome.py b/bin/runSalome.py index c819b857c..f66b12939 100755 --- a/bin/runSalome.py +++ b/bin/runSalome.py @@ -738,11 +738,15 @@ def useSalome(args, modules_list, modules_root_dir): # run python scripts, passed as command line arguments toimport = [] - if args.has_key('pyscript'): - if args.has_key('gui') and args.has_key('session_gui'): - if not args['gui'] or not args['session_gui']: + if args.has_key('gui') and args.has_key('session_gui'): + if not args['gui'] or not args['session_gui']: + if args.has_key('study_hdf'): + toopen = args['study_hdf'] + if toopen: + import salome + salome.salome_init(toopen) + if args.has_key('pyscript'): toimport = args['pyscript'] - from salomeContextUtils import formatScriptsAndArgs command = formatScriptsAndArgs(toimport) if command: diff --git a/src/KERNEL_PY/salome_study.py b/src/KERNEL_PY/salome_study.py index 7bec02067..24292820f 100755 --- a/src/KERNEL_PY/salome_study.py +++ b/src/KERNEL_PY/salome_study.py @@ -345,6 +345,7 @@ def salome_study_init(theStudyId=0): 0 : create a new study (default). n (>0) : try connection to study with Id = n, or create a new one if study not found. + n (str): try open study with the given file name. """ global salome_study_initial global myStudyManager, myStudyId, myStudy, myStudyName @@ -362,11 +363,19 @@ def salome_study_init(theStudyId=0): if verbose(): print "studyManager found" # get active study Id, ref and name + myStudy = None myStudyId = getActiveStudy(theStudyId) if myStudyId == None : - myStudyId = createNewStudy() + import types + if theStudyId and type(theStudyId) == types.StringType: + myStudy = myStudyManager.Open(theStudyId) + myStudyId = myStudy._get_StudyId() + else: + myStudyId = createNewStudy() if verbose(): print "myStudyId",myStudyId - myStudy = myStudyManager.GetStudyByID(myStudyId) + + if myStudy == None: + myStudy = myStudyManager.GetStudyByID(myStudyId) myStudyName = myStudy._get_Name() return myStudyManager, myStudyId, myStudy, myStudyName -- 2.39.2