CQtDeployer/Deploy/packing.cpp

68 lines
1.3 KiB
C++
Raw Normal View History

2020-01-04 16:39:25 +03:00
#include "Distributions/idistribution.h"
#include "packing.h"
#include "quasarapp.h"
#include <QDebug>
#include <QThread>
2020-01-04 16:39:25 +03:00
Packing::Packing() {
_proc = new QProcess();
2020-01-04 16:39:25 +03:00
connect(_proc, &QProcess::readyReadStandardError,
this, &Packing::handleOutputUpdate, Qt::QueuedConnection);
connect(_proc, &QProcess::readyReadStandardOutput,
this, &Packing::handleOutputUpdate, Qt::QueuedConnection);
moveToThread( new QThread(this));
2020-01-04 16:39:25 +03:00
}
Packing::~Packing() {
if (_pakage)
delete _pakage;
_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;
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;
}
void Packing::handleOutputUpdate() {
QString stdout = _proc->readAllStandardOutput();
QString errout = _proc->readAllStandardError();
if (stdout.size())
qInfo() << stdout;
if (errout.size())
qInfo() << errout;
}