X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d14a1e28567de23c586bc80017073d0c39f8d18f..e17b6377be593ce71d722beb3cdcffb67baccf00:/wxPython/src/_process.i diff --git a/wxPython/src/_process.i b/wxPython/src/_process.i index eb08b3f1ea..1156a96784 100644 --- a/wxPython/src/_process.i +++ b/wxPython/src/_process.i @@ -39,6 +39,13 @@ enum wxKillError wxKILL_ERROR // another, unspecified error }; +enum wxKillFlags +{ + wxKILL_NOCHILDREN = 0, // don't kill children + wxKILL_CHILDREN = 1 // kill children +}; + + enum wxSignal { wxSIGNONE = 0, // verify if the process exists under Unix @@ -71,10 +78,13 @@ IMP_PYCALLBACK_VOID_INTINT( wxPyProcess, wxProcess, OnTerminate); %} -%name(Process)class wxPyProcess : public wxEvtHandler { +%rename(Process) wxPyProcess; +class wxPyProcess : public wxEvtHandler { public: // kill the process with the given PID - static wxKillError Kill(int pid, wxSignal sig = wxSIGTERM); + static wxKillError Kill(int pid, + wxSignal sig = wxSIGTERM, + int flags = wxKILL_NOCHILDREN); // test if the given process exists static bool Exists(int pid); @@ -89,13 +99,14 @@ public: static wxPyProcess *Open(const wxString& cmd, int flags = wxEXEC_ASYNC); - %addtofunc wxPyProcess "self._setCallbackInfo(self, Process)" + %pythonAppend wxPyProcess "self._setCallbackInfo(self, Process)" wxPyProcess(wxEvtHandler *parent = NULL, int id = -1); void _setCallbackInfo(PyObject* self, PyObject* _class); - void base_OnTerminate(int pid, int status); - + void OnTerminate(int pid, int status); + %MAKE_BASE_FUNC(Process, OnTerminate); + // call Redirect before passing the object to wxExecute() to redirect the // launched process stdin/stdout, then use GetInputStream() and // GetOutputStream() to get access to them @@ -113,12 +124,20 @@ public: void CloseOutput(); - // return TRUE if the child process stdout is not closed + // return True if the child process stdout is not closed bool IsInputOpened() const; - // return TRUE if any input is available on the child process stdout/err + // return True if any input is available on the child process stdout/err bool IsInputAvailable() const; bool IsErrorAvailable() const; + + %property(ErrorStream, GetErrorStream, doc="See `GetErrorStream`"); + %property(InputStream, GetInputStream, doc="See `GetInputStream`"); + %property(OutputStream, GetOutputStream, doc="See `GetOutputStream`"); + + %property(InputOpened, IsInputOpened); + %property(InputAvailable, IsInputAvailable); + %property(ErrorAvailable, IsErrorAvailable); }; //--------------------------------------------------------------------------- @@ -130,6 +149,9 @@ public: int GetPid(); int GetExitCode(); int m_pid, m_exitcode; + + %property(ExitCode, GetExitCode, doc="See `GetExitCode`"); + %property(Pid, GetPid, doc="See `GetPid`"); }; @@ -155,15 +177,38 @@ enum // under Unix, if the process is the group leader then killing -pid kills // all children as well as pid - wxEXEC_MAKE_GROUP_LEADER = 4 + wxEXEC_MAKE_GROUP_LEADER = 4, + + // by default synchronous execution disables all program windows to avoid + // that the user interacts with the program while the child process is + // running, you can use this flag to prevent this from happening + wxEXEC_NODISABLE = 8 }; +MustHaveApp(wxExecute); + long wxExecute(const wxString& command, int flags = wxEXEC_ASYNC, wxPyProcess *process = NULL); + +%typemap(in,numinputs=0) wxKillError* rc ( wxKillError temp ) { $1 = &temp; } +%typemap(argout) wxKillError* rc +{ + PyObject* o; + o = PyInt_FromLong((long) (*$1)); +#if SWIG_VERSION < 0x010328 + $result = t_output_helper($result, o); +#else + $result = SWIG_Python_AppendOutput($result, o); +#endif +} + +int wxKill(long pid, wxSignal sig = wxSIGTERM, wxKillError* rc, int flags = wxKILL_NOCHILDREN); + + //--------------------------------------------------------------------------- %init %{ wxPyPtrTypeMap_Add("wxProcess", "wxPyProcess");