]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
Bug fix: running scripts in embedded python console V7_5_0b1
authorCédric Aguerre <cedric.aguerre@edf.fr>
Mon, 27 Oct 2014 11:09:02 +0000 (12:09 +0100)
committerCédric Aguerre <cedric.aguerre@edf.fr>
Mon, 27 Oct 2014 11:09:02 +0000 (12:09 +0100)
bin/runSalome.py
bin/salomeContextUtils.py.in

index f66b12939db0978ef6d421c82984cd02abe28040..0c64fbcd9b783174337b39d51a30137c8ac1a322 100755 (executable)
@@ -33,6 +33,7 @@ from launchConfigureParser import verbose
 from server import process_id, Server
 import json
 import subprocess
+from salomeContextUtils import ScriptAndArgsObjectEncoder
 
 # -----------------------------------------------------------------------------
 
@@ -287,7 +288,7 @@ class SessionServer(Server):
                     pass
                 pass
                 if self.args.has_key('pyscript') and len(self.args['pyscript']) > 0:
-                    msg = json.dumps(self.args['pyscript'])
+                    msg = json.dumps(self.args['pyscript'], cls=ScriptAndArgsObjectEncoder)
                     self.SCMD2+=['--pyscript=%s'%(msg)]
                     pass
                 pass
index 810d6ee797f82e09f9aec2c682047f7a453cce09..3ff44603e3c57d0ff7913cb3782222bce14e0973 100644 (file)
@@ -25,6 +25,7 @@ import glob
 import subprocess
 import re
 import socket
+import json
 
 """
 Define a specific exception class to manage exceptions related to SalomeContext
@@ -111,6 +112,15 @@ class ScriptAndArgs:
     self.args = args
     self.out = out
 #
+class ScriptAndArgsObjectEncoder(json.JSONEncoder):
+  def default(self, obj):
+    if isinstance(obj, ScriptAndArgs):
+      # to be easily parsed in GUI module (SalomeApp_Application)
+      # Do not export output arguments
+      return {obj.script:obj.args or []}
+    else:
+      return json.JSONEncoder.default(self, obj)
+#
 
 # Return an array of ScriptAndArgs objects
 def getScriptsAndArgs(args=None, searchPathList=None):