From 1fff0384f4e73798bae1fe1ee555f986c625ddd6 Mon Sep 17 00:00:00 2001 From: Laura Nervo <laura.nervo@esrf.fr> Date: Fri, 8 Nov 2013 15:52:29 +0100 Subject: [PATCH] gtPythonCommand : now it's possible to run python scripts from matlab without the need of using the executable. Added the flag 'use_exec' for that purpose. Signed-off-by: Laura Nervo <laura.nervo@esrf.fr> --- zUtil_Python/gtPythonCommand.m | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/zUtil_Python/gtPythonCommand.m b/zUtil_Python/gtPythonCommand.m index cc380600..ffd7c657 100644 --- a/zUtil_Python/gtPythonCommand.m +++ b/zUtil_Python/gtPythonCommand.m @@ -1,27 +1,32 @@ -function [status, msg, ver] = gtPythonCommand(args, use_fable) -% GTPYTHONCOMMAND Call python witht the proper command +function [status, msg, ver] = gtPythonCommand(args, use_fable, use_exec) +% GTPYTHONCOMMAND Calls python with the proper command % -% [status, msg, ver] = gtPythonCommand(args[, use_fable]) -% ------------------------------------------------------------------------ +% [status, msg, ver] = gtPythonCommand(args, [use_fable], [use_exec]) +% ------------------------------------------------------------------- % INPUT: -% args = <string> Argumants passed to the python invocation -% -% OPTIONAL INPUT: -% use_fable = <logical> Source fable configuration file before {false} +% args = <string> Arguments passed to the python invocation +% use_fable = <logical> Source fable configuration file before {false} +% use_exec = <logical> Use the python command before the script {true} % % OUTPUT: -% status = <int> System command return code -% msg = <string> Python command output +% status = <int> System command return code +% msg = <string> Python command output +% ver = <int> Version of python % -% OPTIONAL OUTPUT: -% ver = <int> Version of python +% Version 002 08-11-2013 by LNervo +% Added option to use or not the python executable % % Version 001 08-02-2013 by YGuilhem + % Default paramater value if ~exist('use_fable', 'var') || isempty(use_fable) use_fable = false; end +if ~exist('use_exec', 'var') || isempty(use_exec) + use_exec = true; +end + pythonExes = {'python', 'python26'}; % Loop over each python executables @@ -51,6 +56,9 @@ if use_fable end % Run command +if ~use_exec + pythonExe = ''; +end [status, msg] = system([fableSet pythonExe ' ' args]); % Add version output if asked -- GitLab