コード例 #1
0
void R3DSurfaceGenProcess::runSingleCommand()
{
	if(!cmds_.IsEmpty())
	{
		Redirect();	// Redirect I/O, hide console window

		wxString cmdLine = cmds_[0];
		cmds_.RemoveAt(0);
		wxString progressText = progressTexts_[0];
		progressTexts_.RemoveAt(0);
		pMainFrame_->sendUpdateProgressBarEvent(-1.0f, progressText);

		// Cleanup
		if(GetInputStream() != NULL)
			delete GetInputStream();
		if(GetErrorStream() != NULL)
			delete GetErrorStream();
		if(GetOutputStream() != NULL)
			delete GetOutputStream();
		SetPipeStreams(NULL, NULL, NULL);
#if wxCHECK_VERSION(2, 9, 0)
		processId_ = wxExecute(cmdLine, wxEXEC_ASYNC, this, &env_);
#else
		processId_ = wxExecute(cmdLine, wxEXEC_ASYNC, this);
#endif
	}
}
コード例 #2
0
ファイル: pipedprocess.cpp プロジェクト: 469306621/Languages
bool PipedProcess::HasInput()
{
    if (IsErrorAvailable())
    {
        cbTextInputStream serr(*GetErrorStream());

        wxString msg;
        msg << serr.ReadLine();

		CodeBlocksEvent event(cbEVT_PIPEDPROCESS_STDERR, m_Id);
        event.SetString(msg);
		wxPostEvent(m_Parent, event);
// 		m_Parent->ProcessEvent(event);

        return true;
    }

    if (IsInputAvailable())
    {
        cbTextInputStream sout(*GetInputStream());

        wxString msg;
        msg << sout.ReadLine();

		CodeBlocksEvent event(cbEVT_PIPEDPROCESS_STDOUT, m_Id);
        event.SetString(msg);
		wxPostEvent(m_Parent, event);
// 		m_Parent->ProcessEvent(event);

        return true;
    }

    return false;
}
コード例 #3
0
void CPyProcess::HandleInput(void) {
	wxInputStream *m_in, *m_err;

	m_in = GetInputStream();
	m_err = GetErrorStream();

	if (m_in) {
		wxString s;
		while (m_in->CanRead()) {
			char buffer[4096];
			m_in->Read(buffer, sizeof(buffer));
			s += wxString::From8BitData(buffer, m_in->LastRead());
		}
		if (s.Length() > 0) {
			wxLogMessage(_T("> %s"), s.c_str());
		}
	}
	if (m_err) {
		wxString s;
		while (m_err->CanRead()) {
			char buffer[4096];
			m_err->Read(buffer, sizeof(buffer));
			s += wxString::From8BitData(buffer, m_err->LastRead());
		}
		if (s.Length() > 0) {
			wxLogMessage(_T("! %s"), s.c_str());
		}
	}
}
コード例 #4
0
ファイル: process.cpp プロジェクト: zinnjonas/MarkdownGui
bool MarkdownProcess::HasInput()
{
    bool hasInput = false;

    if ( IsInputAvailable() )
    {
        wxTextInputStream tis(*GetInputStream());

        // this assumes that the output is always line buffered
		m_file << tis.ReadLine() << wxT("\n");

//        m_parent->GetLogListBox()->Append(msg);

        hasInput = true;
    }

    if ( IsErrorAvailable() )
    {
        wxTextInputStream tis(*GetErrorStream());

        // this assumes that the output is always line buffered
		wxMessageBox(tis.ReadLine());
        hasInput = true;
    }

    return hasInput;
}
コード例 #5
0
void R3DSurfaceGenProcess::readConsoleOutput()
{
	wxInputStream *pIn = GetInputStream();
	if(pIn != NULL)
	{
		std::string buf;
		while(pIn->CanRead())
		{
			int curc = pIn->GetC();
			if(curc != wxEOF)
				buf.push_back( static_cast<char>(curc) );
		}

		MLOG << buf.c_str();
	}
	wxInputStream *pErr = GetErrorStream();
	if(pErr != NULL)
	{
		std::string buf;
		while(pErr->CanRead())
		{
			int curc = pErr->GetC();
			if(curc != wxEOF)
				buf.push_back( static_cast<char>(curc) );
		}

		MLOG << buf.c_str();
	}
}
コード例 #6
0
ファイル: pipedprocess.cpp プロジェクト: 05storm26/codelite
bool PipedProcess::ReadAll(wxString &input)
{
	bool hasInput = false;
	bool cont1(true), cont2(true);

	wxTextInputStream tis(*GetInputStream());
	wxTextInputStream tie(*GetErrorStream());
	while(cont1 || cont2){
		cont1 = false;
		cont2 = false;
		while( IsInputAvailable() )
		{
			// this assumes that the output is always line buffered
			wxChar ch = tis.GetChar();
			input << ch;
			hasInput = true;
			cont1 = true;
		}

		while( IsErrorAvailable() )
		{
			// this assumes that the output is always line buffered
			wxChar ch = tie.GetChar();
			input << ch;
			hasInput = true;
			cont2 = true;
		}
	}
	return hasInput;
}
コード例 #7
0
ファイル: camprocess.cpp プロジェクト: Amadiro/xara-cairo
/********************************************************************************************

>	void CamLaunchProcess::ProcessStdErr()

	Author:		Phil_Martin (Xara Group Ltd) <*****@*****.**>
				Gerry_Iles (Xara Group Ltd) <*****@*****.**>
	Created:	19/May/2006
	Inputs:		-
	Outputs:	-
	Returns:	-
	Purpose:	Process anything the process writes to the error stream

********************************************************************************************/
void CamLaunchProcess::ProcessStdErr()
{
	if (IsErrorAvailable())
	{
		wxTextInputStream tis(*GetErrorStream());

		// This assumes that the output is always line buffered
		while (!GetErrorStream()->Eof())
		{
			wxString line;
			line << tis.ReadLine();
			TRACEUSER("Phil", _T("(stderr):%s\n"), line.c_str());
		}

		m_ReturnCode = 42;		// Signal failure
	}
}
コード例 #8
0
    void OnTerminate(int WXUNUSED(pid), int status)
    {
        wxStringOutputStream out, err;
        if (GetInputStream()) out.Write(*GetInputStream());
        if (GetErrorStream()) err.Write(*GetErrorStream());

        //wxPrintf("%s\n", stdout.GetString());
        //wxPrintf("%s\n", stderr.GetString());

        // when wx programs assert on wxGTK/wxMac, they put on stderr a message like:
        //    [Debug] date somefilename.pp(nnnn): assert "xxxxx" failed in yyyy
        // but then the assert dialog pop-ups and thus the app doesn't exit
        // FIXME: make assertion detection work also under other platforms
        //        see http://trac.wxwidgets.org/ticket/10697
        m_crashed = out.GetString().Contains("assert") ||
                    err.GetString().Contains("assert");
        m_exitCode = status;
    }
コード例 #9
0
ファイル: xpoilflt.cpp プロジェクト: Amadiro/xara-cairo
void PluginFilterProcess::ProcessStdErr()
{
//	TRACEUSER("Gerry", _T("PluginFilterProcess::ProcessStdErr"));

	if (IsErrorAvailable())
	{
		wxTextInputStream tis(*GetErrorStream());

		// This assumes that the output is always line buffered
//		while (!GetErrorStream()->Eof())
		while (IsErrorAvailable())
		{
			wxString line;
			line << tis.ReadLine();
//			TRACEUSER("Gerry", _T("(stderr):%s"), line.c_str());

			if (!line.IsEmpty())
			{
				// If line begins "MESSAGE:" then it is a debug message and can be discarded
				wxString rest;
				if (line.StartsWith(_T("MESSAGE:"), &rest))
				{
//					TRACEUSER("Gerry", _T("XPFDebug:%s"), rest.c_str());
				}
				else if (line.StartsWith(_T("PROGRESS:"), &rest))
				{
//					TRACEUSER("Gerry", _T("XPFProgress:%s"), rest.c_str());
					if (m_pFilter)
					{
						unsigned long /*TYPENOTE: Correct*/ Val = wxStrtoul(rest.c_str(), NULL, 10);
						if (Val > 0)
						{
//							TRACEUSER("Gerry", _T("Setting progress to %d"), Val);
							m_pFilter->SetProgressBarCount((UINT32)Val);
						}
					}
				}
				else if (line.StartsWith(_T("WARNING:"), &rest))
				{
//					TRACEUSER("Gerry", _T("XPFWarning:%s"), rest.c_str());
					m_Warnings.Add(rest);
				}
				else if (line.StartsWith(_T("ERROR:"), &rest))
				{
//					TRACEUSER("Gerry", _T("XPFError:%s"), rest.c_str());
					m_Errors.Add(rest);
				}
				else
				{
//					TRACEUSER("Gerry", _T("Skipping stderr:%s"), line.c_str());
//					m_Errors.Add(line);
				}
			}
		}
	}
}
コード例 #10
0
ファイル: processManager.cpp プロジェクト: JimmyFarcy/I-Simpa
void processManager::LogOutput(bool &hasOutput, const wxString &label,float *outputProgression)
{
    hasOutput = false;

    if ( IsInputAvailable() )
    {
        wxTextInputStream tis(*GetInputStream());

        // this assumes that the output is always line buffered
        wxString msg;
        wxString output= tis.ReadLine();
        if(!this->outlogs.empty())
        {
            for(std::vector<smart_ptr<InterfLogger> >::iterator itlogs=this->outlogs.begin(); itlogs!=this->outlogs.end(); itlogs++)
            {
                (*(*itlogs)).LogMessage(output);
            }
        }
        if(outputProgression==NULL || output.Left(1)!="#")
        {
            msg << label << output;
            msg.Replace("%","%%"); //si il y a un seul % alors un bug apparait wxString attend un format du type %s ou %i par exemple
            if(output.Left(1)=="!")
            {
                wxLogWarning(msg);
            } else {
                wxLogMessage(msg);
            }
        } else {
            wxString prog=output.Right(output.Len()-1).Strip();
            *outputProgression=Convertor::ToFloat(prog);
        }

        hasOutput = true;
    }

    while ( IsErrorAvailable() )
    {
        wxTextInputStream tis(*GetErrorStream());
        const wxString& errMsg(tis.ReadLine());
        if(!this->outlogs.empty())
        {
            for(std::vector<smart_ptr<InterfLogger> >::iterator itlogs=this->outlogs.begin(); itlogs!=this->outlogs.end(); itlogs++)
            {
                (*(*itlogs)).LogError(errMsg);
            }
        }
        // this assumes that the output is always line buffered
        wxString msg;
        msg << _("Erreur exécutable :") << errMsg;
        msg.Replace("%","%%"); //si il y a un seul % alors un bug apparait wxString attend un format du type %s ou %i par exemple
        wxLogError(msg);

        hasOutput = true;
    }
}
コード例 #11
0
ファイル: nwxProcess.cpp プロジェクト: ncbi/osiris
size_t nwxProcess::ProcessIO(size_t nLimit)
{
  size_t nRtn = 0;
  bool bInputClosed = false;
  if(!m_bPaused)
  {
    if(!IsInputOpened())
    {
      if(m_sBuffer.Len())
      {
        m_sBuffer += "\n";
        ProcessLine(m_sBuffer.utf8_str(),m_sBuffer.Len(),false);
        m_sBuffer.Empty();
      }
      bInputClosed = true;
    }
    else 
    {
      while(IsInputAvailable() && (nRtn < nLimit))
      {
        nRtn += ProcessIO(GetInputStream(),m_sBuffer,false);
      }
    }
    if(!IsErrorOpened())
    {
      if(m_sBufferError.Len())
      {
        m_sBufferError += "\n";
        ProcessLine(m_sBufferError.utf8_str(),m_sBufferError.Len(),true);
        m_sBufferError.Empty();
      }
      if(bInputClosed && m_bRunning)
      {
    	  m_bRunning = false;
    	      // we are sometimes not notified when process ends
#ifndef __WXMSW__
    	  // need to clean up zombie because wx sometimes
    	  // fails to do this on the macintosh
    	  int nStatLoc;
    	  pid_t nPID;
    	  nPID = waitpid((pid_t)m_nPID,&nStatLoc,0);
    	  OnTerminate(m_nPID,nStatLoc);
#endif
      }
    }
    else 
    {
      while(IsErrorAvailable() && (nRtn < nLimit))
      {
        nRtn += ProcessIO(GetErrorStream(),m_sBufferError,true);
      }
    }
  }
  return nRtn;
}
コード例 #12
0
ファイル: camprocess.cpp プロジェクト: Amadiro/xara-cairo
void CamProcess::ProcessStdErr()
{
	if (IsErrorAvailable())
	{
		wxTextInputStream tis(*GetErrorStream());

		// This assumes that the output is always line buffered
		while (IsErrorAvailable())
		{
			wxString line;
			line << tis.ReadLine();
//			TRACEUSER("Gerry", _T("(stderr):%s"), line.c_str());
		}
	}
}
コード例 #13
0
ファイル: pipedprocess.cpp プロジェクト: 469306621/Languages
void PipedProcess::ForfeitStreams()
{
    char buf[4096];
    if (IsErrorAvailable())
    {
        wxInputStream *in = GetErrorStream();
        while(in->Read(&buf, sizeof(buf)).LastRead())
            ;
    }
    if (IsInputAvailable())
    {
        wxInputStream *in = GetInputStream();
        while(in->Read(&buf, sizeof(buf)).LastRead())
            ;
    }
}
コード例 #14
0
ファイル: axprocess.cpp プロジェクト: DDMAL/aruspix
bool AxProcess::HasEnded( )
{
	wxString msg;

	// redirect in now disabled (see constructor)
	// nothing will happen
	wxTextInputStream tis(*GetInputStream());
	wxTextInputStream tes(*GetErrorStream());
	
	// we don't know where Error is going to be output
    while ( IsInputAvailable() )
	{
		msg = tis.ReadLine();
		if ( msg.StartsWith("$ Success!") )
		{
			return true;
		}
		else if ( msg.StartsWith("$ Error: ") )
		{
			m_status = 255;
			return true;
		}
		if ( !msg.IsEmpty() && m_log )
			m_log->WriteString( msg + "\n" );
	}
    while ( IsErrorAvailable() )
	{
		msg = tes.ReadLine();
		if ( msg.StartsWith("$ Error: ") )
		{
			m_status = 255;
			return true;
		}
		if ( !msg.IsEmpty() && m_log )
			m_log->WriteString( msg + "\n" );
    }


    return false;
}
コード例 #15
0
ファイル: gexecute.cpp プロジェクト: eraso/poedit
        bool HasInput()
        {
            bool hasInput = false;

            wxInputStream* is = GetInputStream();
            if (is && is->CanRead() && !is->Eof()) 
            {
                wxTextInputStream tis(*is);
                m_data->Stdout.Add(tis.ReadLine());
                hasInput = true;
            }

            wxInputStream* es = GetErrorStream();
            if (es && es->CanRead() && !es->Eof()) 
            {
                wxTextInputStream tis(*es);
                m_data->Stderr.Add(tis.ReadLine());
                hasInput = true;
            }

            return hasInput;
        }
コード例 #16
0
ファイル: sysProcess.cpp プロジェクト: KrisShannon/pgadmin3
wxString sysProcess::ReadErrorStream()
{
	if (IsErrorAvailable())
		return ReadStream(GetErrorStream());
	return wxEmptyString;
}
コード例 #17
0
ファイル: nwxProcess.cpp プロジェクト: ncbi/osiris
bool nwxProcess::IsErrorOpened() const
{
  wxInputStream *pIn = GetErrorStream();
  bool bRtn = pIn && (pIn->GetLastError() != wxSTREAM_EOF);
  return bRtn;
}
bool piped_process::has_input()
{
    bool has_input = FALSE;

    // Open a stream to stderr. Note: "GetInputStream()" actually gets the stdout of 
    // the external program being executed "GetOutputStream()" would open a line to the 
    // external program being executed.
    wxInputStream* stderr_stream = GetErrorStream();
    if ( stderr_stream && ! stderr_stream->Eof() ) {
        wxTextInputStream text_istream_of_stderr_stream( *stderr_stream );

        // This assumes that the output is always line buffered
        wxString stderr_string;

        // Dump the stream into our string
        stderr_string << text_istream_of_stderr_stream.ReadLine();
        
        // Put the string in the listbox
        m_parent->get_listbox()->Append( stderr_string );        
        // Look for meaningful information in the string to update dialog gauges, etc.
        m_parent->extract_progress_from_stderr( stderr_string );
        
        /* TODO: this doesn't work any more, now that progress is in stderr.
        // Tell the parent dialog that an error occurred
        m_parent->set_error_occurred( TRUE );
        */        
        
        has_input = TRUE;
    }

#if ( setupUSE_CATCH_STDOUT_FROM_PLUCKER_BUILD )
// NOTE: stdout is currently unused, since new plucker-build now sends all the progress
// information to stderr, not stdout. This is just kept in as an example of how someone
// could also catch the stdout of a process and send it to the listbox.  Also useful
// if using the old Plucker 1.1.3 parser, which did write progress to stdout.

    wxInputStream* stdout_stream = GetInputStream();
    if ( stdout_stream && ! stdout_stream->Eof() ) {
        wxTextInputStream text_istream_of_stdout_stream( *stdout_stream );

        // This assumes that the output is always line buffered
        wxString stdout_string;
        // Assemble the string
        stdout_string << text_istream_of_stdout_stream.ReadLine();
        // Place the string in the listbox
        m_parent->get_listbox()->Append( stdout_string );
        m_parent->extract_progress_from_stderr( stdout_string );
        
        has_input = TRUE;
    }    
#endif  // setupUSE_CATCH_STDOUT_FROM_PLUCKER_BUILD 
    

/* Some attempts at refresh in GTK

wxLogDebug( "Top level yield in has input" ); 
#if ( GTK_TEST_OF_APPYIELD )
        wxLogDebug( " Calling wxTheApp()->Yield( TRUE )" );
        wxTheApp->Yield( TRUE );
#endif

*/
    
    return has_input;
}