From: Cédric Aguerre Date: Mon, 27 Oct 2014 11:09:02 +0000 (+0100) Subject: Bug fix: running scripts in embedded python console X-Git-Tag: V7_5_0b1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ae6ce5603cc3c70f574c1db61af7014b152ef027;p=modules%2Fkernel.git Bug fix: running scripts in embedded python console --- diff --git a/bin/runSalome.py b/bin/runSalome.py index f66b12939..0c64fbcd9 100755 --- a/bin/runSalome.py +++ b/bin/runSalome.py @@ -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 diff --git a/bin/salomeContextUtils.py.in b/bin/salomeContextUtils.py.in index 810d6ee79..3ff44603e 100644 --- a/bin/salomeContextUtils.py.in +++ b/bin/salomeContextUtils.py.in @@ -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):