public static PythonFile OpenPipedCommand(ICallerContext context, string command, string mode, int bufsize) { if (String.IsNullOrEmpty(mode)) { mode = "r"; } ProcessStartInfo psi = GetProcessInfo(command); Process p; PythonFile res; switch (mode) { case "r": psi.RedirectStandardOutput = true; p = Process.Start(psi); res = new POpenFile(context, command, p, p.StandardOutput.BaseStream, "r"); break; case "w": psi.RedirectStandardInput = true; p = Process.Start(psi); res = new POpenFile(context, command, p, p.StandardInput.BaseStream, "w"); break; default: throw Ops.ValueError("expected 'r' or 'w' for mode, got {0}", mode); } return(res); }
public static PythonFile popen(CodeContext/*!*/ context, string command, string mode, int bufsize) { if (String.IsNullOrEmpty(mode)) mode = "r"; ProcessStartInfo psi = GetProcessInfo(command); psi.CreateNoWindow = true; // ipyw shouldn't create a new console window Process p; PythonFile res; try { switch (mode) { case "r": psi.RedirectStandardOutput = true; p = Process.Start(psi); res = new POpenFile(context, command, p, p.StandardOutput.BaseStream, "r"); break; case "w": psi.RedirectStandardInput = true; p = Process.Start(psi); res = new POpenFile(context, command, p, p.StandardInput.BaseStream, "w"); break; default: throw PythonOps.ValueError("expected 'r' or 'w' for mode, got {0}", mode); } } catch (Exception e) { throw ToPythonException(e); } return res; }
public static PythonFile OpenPipedCommand(ICallerContext context, string command, string mode, int bufsize) { if (String.IsNullOrEmpty(mode)) mode = "r"; ProcessStartInfo psi = GetProcessInfo(command); Process p; PythonFile res; try { switch (mode) { case "r": psi.RedirectStandardOutput = true; p = Process.Start(psi); res = new POpenFile(context, command, p, p.StandardOutput.BaseStream, "r"); break; case "w": psi.RedirectStandardInput = true; p = Process.Start(psi); res = new POpenFile(context, command, p, p.StandardInput.BaseStream, "w"); break; default: throw Ops.ValueError("expected 'r' or 'w' for mode, got {0}", mode); } } catch (Exception e) { throw ToPythonException(e); } return res; }