public JProcess(JLanguageVersion languageVersion, string exe, string args, string dir, string env, string interpreterOptions, JDebugOptions options = JDebugOptions.None, List<string[]> dirMapping = null) : this(languageVersion) { ListenForConnection(); if (dir.EndsWith("\\")) { dir = dir.Substring(0, dir.Length - 1); } _dirMapping = dirMapping; var processInfo = new ProcessStartInfo(exe); processInfo.CreateNoWindow = (options & JDebugOptions.CreateNoWindow) != 0; processInfo.UseShellExecute = false; processInfo.RedirectStandardOutput = false; processInfo.RedirectStandardInput = (options & JDebugOptions.RedirectInput) != 0; processInfo.Arguments = (String.IsNullOrWhiteSpace(interpreterOptions) ? "" : (interpreterOptions + " ")) + "\"" + Path.Combine(GetJToolsInstallPath(), "visualstudio_py_launcher.py") + "\" " + "\"" + dir + "\" " + " " + DebugConnectionListener.ListenerPort + " " + " " + _processGuid + " " + (((options & JDebugOptions.WaitOnAbnormalExit) != 0) ? " --wait-on-exception " : "") + (((options & JDebugOptions.WaitOnNormalExit) != 0) ? " --wait-on-exit " : "") + (((options & JDebugOptions.RedirectOutput) != 0) ? " --redirect-output " : "") + (((options & JDebugOptions.BreakOnSystemExitZero) != 0) ? " --break-on-systemexit-zero " : "") + (((options & JDebugOptions.DebugStdLib) != 0) ? " --debug-stdlib " : "") + (((options & JDebugOptions.DjangoDebugging) != 0) ? " --django-debugging " : "") + args; if (env != null) { string[] envValues = env.Split('\0'); foreach (var curValue in envValues) { string[] nameValue = curValue.Split(new[] { '=' }, 2); if (nameValue.Length == 2 && !String.IsNullOrWhiteSpace(nameValue[0])) { processInfo.EnvironmentVariables[nameValue[0]] = nameValue[1]; } } } Debug.WriteLine(String.Format("Launching: {0} {1}", processInfo.FileName, processInfo.Arguments)); _process = new Process(); _process.StartInfo = processInfo; _process.EnableRaisingEvents = true; _process.Exited += new EventHandler(_process_Exited); }
/// <summary> /// Creates a new JProcess object for debugging. The process does not start until Start is called /// on the returned JProcess object. /// </summary> public JProcess CreateProcess(JLanguageVersion langVersion, string exe, string args, string dir, string env, string interpreterOptions = null, JDebugOptions debugOptions = JDebugOptions.None) { return new JProcess(langVersion, exe, args, dir, env, interpreterOptions, debugOptions); }