2020-01-04 16:39:25 +03:00
|
|
|
#include "Distributions/idistribution.h"
|
|
|
|
#include "packing.h"
|
2020-01-05 13:58:38 +03:00
|
|
|
#include "quasarapp.h"
|
|
|
|
#include <QDebug>
|
2020-01-12 19:48:22 +03:00
|
|
|
#include <QProcess>
|
2020-01-05 13:58:38 +03:00
|
|
|
#include <QThread>
|
2020-01-04 16:39:25 +03:00
|
|
|
|
|
|
|
Packing::Packing() {
|
2020-01-05 13:58:38 +03:00
|
|
|
_proc = new QProcess();
|
2020-01-04 16:39:25 +03:00
|
|
|
|
2020-01-05 13:58:38 +03:00
|
|
|
connect(_proc, &QProcess::readyReadStandardError,
|
|
|
|
this, &Packing::handleOutputUpdate, Qt::QueuedConnection);
|
|
|
|
|
2020-01-05 14:55:57 +03:00
|
|
|
connect(_proc, &QProcess::readyReadStandardOutput,
|
2020-01-05 13:58:38 +03:00
|
|
|
this, &Packing::handleOutputUpdate, Qt::QueuedConnection);
|
|
|
|
|
|
|
|
moveToThread( new QThread(this));
|
2020-01-04 16:39:25 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
Packing::~Packing() {
|
|
|
|
if (_pakage)
|
|
|
|
delete _pakage;
|
2020-01-05 13:58:38 +03:00
|
|
|
|
|
|
|
_proc->kill();
|
|
|
|
|
|
|
|
delete _proc;
|
2020-01-04 16:39:25 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void Packing::setDistribution(iDistribution *pakage) {
|
|
|
|
_pakage = pakage;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Packing::create() {
|
|
|
|
|
|
|
|
if (!_pakage)
|
|
|
|
return false;
|
|
|
|
|
2020-01-05 13:58:38 +03:00
|
|
|
if (!_pakage->runCmd().size())
|
|
|
|
return true;
|
|
|
|
|
|
|
|
_proc->setProgram(_pakage->runCmd());
|
|
|
|
_proc->setEnvironment(_pakage->toolKitLocation().deployEnvironment());
|
|
|
|
_proc->setArguments(_pakage->runArg());
|
|
|
|
|
|
|
|
_proc->start();
|
|
|
|
|
|
|
|
if (_proc->waitForStarted(1000)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!_proc->waitForFinished(60000 * 10)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-01-04 16:39:25 +03:00
|
|
|
return true;
|
|
|
|
}
|
2020-01-05 13:58:38 +03:00
|
|
|
|
|
|
|
void Packing::handleOutputUpdate() {
|
2020-01-12 20:13:40 +03:00
|
|
|
QByteArray stdoutLog = _proc->readAllStandardOutput();
|
|
|
|
QByteArray erroutLog = _proc->readAllStandardError();
|
2020-01-05 13:58:38 +03:00
|
|
|
|
2020-01-12 20:13:40 +03:00
|
|
|
if (stdoutLog.size())
|
|
|
|
qInfo() << stdoutLog;
|
2020-01-05 13:58:38 +03:00
|
|
|
|
2020-01-12 20:13:40 +03:00
|
|
|
if (erroutLog.size())
|
|
|
|
qInfo() << erroutLog;
|
2020-01-05 13:58:38 +03:00
|
|
|
}
|
|
|
|
|