From 715c83f124af61e88aec999ad006c386f762f4d5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?C=C3=A9dric=20Aguerre?= Date: Mon, 27 Oct 2014 12:09:02 +0100 Subject: [PATCH] Bug fix: running scripts in embedded python console --- bin/runSalome.py | 3 ++- bin/salomeContextUtils.py.in | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) 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): -- 2.39.2