process.cpp
changeset 825 1ad892c1a709
parent 429 69a4c16bd85b
     1.1 --- a/process.cpp	Thu Feb 25 11:03:52 2010 +0000
     1.2 +++ b/process.cpp	Tue Mar 02 13:59:19 2010 +0000
     1.3 @@ -1,5 +1,10 @@
     1.4  #include "process.h"
     1.5  
     1.6 +#include <QMessageBox>
     1.7 +#include <QDebug>
     1.8 +
     1.9 +extern bool debug;
    1.10 +
    1.11  /////////////////////////////////////////////////////////////////
    1.12  // Process
    1.13  /////////////////////////////////////////////////////////////////
    1.14 @@ -22,6 +27,40 @@
    1.15  	stdOut="";
    1.16  }
    1.17  
    1.18 +void Process::runScript(QString spath, QString fpath)
    1.19 +{
    1.20 +	spath.replace ("%f",fpath);
    1.21 +	QStringList args=QStringList::split (' ',spath,false);
    1.22 +	spath=args.takeFirst();
    1.23 +		
    1.24 +	if (debug)
    1.25 +		qDebug()<<"Process::runScript : " + spath+" "+args.join(" ");	
    1.26 +
    1.27 +	start (spath,args);
    1.28 +	if (!waitForStarted() )
    1.29 +	{
    1.30 +		QMessageBox::critical( 0, tr( "Critical Error" ),
    1.31 +					   tr("Could not start %1").arg(spath) );
    1.32 +	} else
    1.33 +	{
    1.34 +		if (!waitForFinished())
    1.35 +			QMessageBox::critical( 0, tr( "Critical Error" ),
    1.36 +			   tr("%1 didn't exit normally").arg(spath) +
    1.37 +			   getErrout() );
    1.38 +	//	else
    1.39 +	//		if (exitStatus()>0) showOutput=true;
    1.40 +			
    1.41 +	}	
    1.42 +	/* FIXME-3	output for Process::runScript
    1.43 +	qDebug()<<readAllStandardOutput();
    1.44 +	qDebug()<<getStdout();
    1.45 +	qDebug()<<getErrout();
    1.46 +	addOutput ("\n");
    1.47 +	addOutput (getErrout());
    1.48 +	addOutput (getStdout());
    1.49 +	*/
    1.50 +}
    1.51 +
    1.52  void Process::readProcErrout()
    1.53  {
    1.54  	errOut+=readAllStandardError();