Exemple #1
0
        private async Task <ProcessOutputResult> RunPythonScript(string interpreterPath, string script, string parameters, bool showWindow = false)
        {
            ProcessOutput output    = null;
            var           arguments = string.Format("\"{0}\" {1}", script, parameters);

            if (showWindow)
            {
                output = ProcessOutput.RunVisible(interpreterPath, arguments);
            }
            else
            {
                output = ProcessOutput.RunHiddenAndCapture(interpreterPath, arguments);
            }

            using (output) {
                await output;

                var r = new ProcessOutputResult()
                {
                    ExeFileName         = interpreterPath,
                    ExitCode            = output.ExitCode,
                    StandardOutputLines = output.StandardOutputLines.ToArray(),
                    StandardErrorLines  = output.StandardErrorLines.ToArray(),
                };

                // All our python scripts will return 0 if successful
                if (r.ExitCode != 0)
                {
                    throw new ProcessException(r);
                }

                return(r);
            }
        }
Exemple #2
0
        private static async Task <ProcessOutputResult> RunPythonScript(string interpreterPath, string script, string parameters, bool showWindow = false)
        {
            ProcessOutput output    = null;
            var           arguments = string.Format("\"{0}\" {1}", script, parameters);

            if (showWindow)
            {
                output = ProcessOutput.RunVisible(interpreterPath, arguments);
            }
            else
            {
                output = ProcessOutput.RunHiddenAndCapture(interpreterPath, arguments);
            }

            return(await WaitForOutput(interpreterPath, output));
        }