adding commnds to execute
This commit is contained in:
45
UpdatePTUDevCtrl/process/update_command.cpp
Normal file
45
UpdatePTUDevCtrl/process/update_command.cpp
Normal file
@@ -0,0 +1,45 @@
|
||||
#include "update_command.h"
|
||||
#include "worker.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QProcess>
|
||||
|
||||
UpdateCommand::UpdateCommand(QString const &command,
|
||||
Worker *worker,
|
||||
int start_timeout,
|
||||
int finish_timeout)
|
||||
: Command(command, start_timeout, finish_timeout) {
|
||||
setWorker(worker);
|
||||
}
|
||||
|
||||
bool UpdateCommand::stopUpdateOnFailure() {
|
||||
return true;
|
||||
}
|
||||
|
||||
void UpdateCommand::finished(int exitCode, QProcess::ExitStatus exitStatus) {
|
||||
|
||||
qCritical() << __func__ << ":" << __LINE__ << m_command
|
||||
<< "exitCode" << exitCode
|
||||
<< "exitStatus" << exitStatus;
|
||||
|
||||
QProcess *p = (QProcess *)sender();
|
||||
if (p) {
|
||||
// read all remaining data sent to the process, just in case
|
||||
m_commandResult += p->readAllStandardOutput();
|
||||
|
||||
disconnect(p, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(readyReadStandardOutput()));
|
||||
disconnect(p, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(readyReadStandardError()));
|
||||
disconnect(p, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(finished(int,QProcess::ExitStatus)));
|
||||
}
|
||||
|
||||
if (!m_worker->workList().empty()) {
|
||||
if (exitCode == 0 && exitStatus == QProcess::ExitStatus::NormalExit) {
|
||||
if (m_worker->workList().nextExec()) {
|
||||
m_worker->workList().exec();
|
||||
}
|
||||
} else {
|
||||
bool execShowStatus = true;
|
||||
m_worker->workList().exec(execShowStatus);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user