gmbouwer 0 Posted 4 hours ago Hi Apologies if this has an obvious answer but it seems I don't know what to search for. Please refer me to previous posts or any existing documentation. I need to get the exitcode (%errorlevel%) value of a python script. function ExecPython(lines: TStrings): integer begin try PythonEngine1.ExecStrings(lines); result := 0; // success except on E: Exception result := GetLastError() end end; I'm using older version of Delphi. Regards gmb Share this post Link to post
pyscripter 753 Posted 9 minutes ago PythonEngine1.ExecStrings(lines) will raise in exception (a subclass of EPyException) if an error occurs. If you redirecting the python output using for instance TPythonGUIInputOutput then error information is printed and you will be able to see where the error occurred including a traceback. You can also use the Traceback object to extract information about the error. If you want to handle the Exception you can use try PythonEngine1.ExecStrings(lines); except on E: EPyException // Do whatever you want. You can use the PythonEngine1.Traceback to get information about what went wrong end Share this post Link to post