m_process->execute(programName,params);
m_process->execute(programName,params);
To copy to clipboard, switch view to plain text mode
gobletthread
::gobletthread(QObject * parent
):{
}
void gobletthread::run()
{
qDebug() << "Start of Run";
connect(m_process,SIGNAL(finished(int)),this,SLOT(programExited(int)));
connect(m_process,SIGNAL(readyReadStandardOutput()),this,SLOT(readData()));
m_process->setWorkingDirectory("/data/cquiros/projects/ILRI-MARIO/software/nile");
int pos;
for (pos = 0; pos <= m_programs.count()-1;pos++)
{
m_programID = pos;
//Run the program
runProgram(m_programs[pos].description,m_programs[pos].name,m_programs[pos].params);
}
qDebug() << "End of Run";
}
{
QString gobletPath
= settings.
value("GOBLETPath",
"").
toString();
if (!gobletPath.isEmpty())
{
programName = gobletPath + "/" + program;
qDebug() << "Runing:" << program;
if (QFile::exists(programName
)) {
if ((program == "goblet-importdataset") ||
(program == "goblet-importshape"))
catchSubprocess = true; //Both import programs generate progress report in the stdout
else
catchSubprocess = false;
emit processing(description);
m_process->execute(programName,params); //Executes the program waiting until finish
}
else
{
qDebug() << program << "Does not exists!!!";
}
}
else
{
qDebug() << "Goblet path does not exists";
}
}
void gobletthread::setPrograms(QList<TprogramInfo> programs)
{
m_programs.append(programs);
}
void gobletthread::programExited(int exitCode)
{
emit programFinished(m_programID,exitCode);
}
void gobletthread::readData()
{
if (!catchSubprocess)
{
//Intents to capture the total output after the end of execution
QString data
(m_process
->readAll
());
if (!data.isEmpty())
emit readyRead(m_programID,data);
}
else
{
// Intents to capture the output each time the the program writes in the stdout
// Here we try to get the percentage processed by the program
QString data
(m_process
->readLine
(14));
qDebug() << data;
data = data.replace("%","");
data = data.replace("inserted","");
data = data.simplified();
int perc;
perc = data.toInt();
if (perc > 0)
emit subprocess(perc);
}
}
gobletthread::gobletthread(QObject * parent):
QThread(parent)
{
}
void gobletthread::run()
{
qDebug() << "Start of Run";
m_process = new QProcess();
connect(m_process,SIGNAL(finished(int)),this,SLOT(programExited(int)));
connect(m_process,SIGNAL(readyReadStandardOutput()),this,SLOT(readData()));
m_process->setWorkingDirectory("/data/cquiros/projects/ILRI-MARIO/software/nile");
int pos;
for (pos = 0; pos <= m_programs.count()-1;pos++)
{
m_programID = pos;
//Run the program
runProgram(m_programs[pos].description,m_programs[pos].name,m_programs[pos].params);
}
qDebug() << "End of Run";
}
void gobletthread::runProgram(QString description,QString program, QStringList params)
{
QSettings settings("ILRI", "NILE");
QString gobletPath = settings.value("GOBLETPath","").toString();
QString programName;
if (!gobletPath.isEmpty())
{
programName = gobletPath + "/" + program;
qDebug() << "Runing:" << program;
if (QFile::exists(programName))
{
if ((program == "goblet-importdataset") ||
(program == "goblet-importshape"))
catchSubprocess = true; //Both import programs generate progress report in the stdout
else
catchSubprocess = false;
emit processing(description);
m_process->execute(programName,params); //Executes the program waiting until finish
}
else
{
qDebug() << program << "Does not exists!!!";
}
}
else
{
qDebug() << "Goblet path does not exists";
}
}
void gobletthread::setPrograms(QList<TprogramInfo> programs)
{
m_programs.append(programs);
}
void gobletthread::programExited(int exitCode)
{
emit programFinished(m_programID,exitCode);
}
void gobletthread::readData()
{
if (!catchSubprocess)
{
//Intents to capture the total output after the end of execution
QString data(m_process->readAll());
if (!data.isEmpty())
emit readyRead(m_programID,data);
}
else
{
// Intents to capture the output each time the the program writes in the stdout
// Here we try to get the percentage processed by the program
QString data(m_process->readLine(14));
qDebug() << data;
data = data.replace("%","");
data = data.replace("inserted","");
data = data.simplified();
int perc;
perc = data.toInt();
if (perc > 0)
emit subprocess(perc);
}
}
To copy to clipboard, switch view to plain text mode
Any idea is much appreciated.
Bookmarks