示例#1
0
        private void doProcess(string filename, string arguments, string workingDir, AppendLine output)
        {
            var process = Process.Start(new ProcessStartInfo
            {
                FileName               = filename,
                Arguments              = arguments,
                WorkingDirectory       = workingDir,
                UseShellExecute        = false,
                RedirectStandardError  = true,
                RedirectStandardOutput = true,
                CreateNoWindow         = true,
            });

            process.OutputDataReceived += (sender, args) => output(string.IsNullOrEmpty(args.Data) ? "" : args.Data);
            process.ErrorDataReceived  += (sender, args) => output(string.IsNullOrEmpty(args.Data) ? "" : args.Data);
            process.BeginOutputReadLine();
            process.BeginErrorReadLine();
            _processes.Add(process);
            var pids = new List <string>();

            if (File.Exists(_pidsFile))
            {
                pids = File.ReadAllLines(_pidsFile).ToList();
            }
            pids.Add(process.Id.ToString());
            File.WriteAllLines(_pidsFile, pids.ToArray());
        }
示例#2
0
        private Process python(string script, AppendLine output)
        {
            var workingDir = Path.GetDirectoryName(script);

            Environment.SetEnvironmentVariable("PYTHONHOME", _pythonDir);
            var filename = Path.Combine(_pythonDir, "python.exe");

            return(doProcess(filename, $"\"{script}\"", workingDir, output));
        }
示例#3
0
        private Process exec(string exe, AppendLine output)
        {
            var workingDir = Path.GetDirectoryName(exe);

            return(doProcess(exe, "", workingDir, output));
        }
示例#4
0
        private void exec(string exe, AppendLine output)
        {
            var workingDir = Path.GetDirectoryName(exe);

            doProcess(exe, "", workingDir, output);
        }