]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
Load study with name given as command line argument in batch mode. akl/single_study
authorakl <alexander.kovalev@opencascade.com>
Thu, 25 Sep 2014 14:38:50 +0000 (18:38 +0400)
committerakl <alexander.kovalev@opencascade.com>
Thu, 25 Sep 2014 14:38:50 +0000 (18:38 +0400)
bin/runSalome.py
src/KERNEL_PY/salome_study.py

index c819b857c8513c044d2a650d8e4e63e69cbf26d6..f66b12939db0978ef6d421c82984cd02abe28040 100755 (executable)
@@ -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:
index 7bec020679c402be80f60df3622d3e11f43f68a7..24292820fc6f01997483fc6ed13aac2414e329db 100755 (executable)
@@ -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