Compare commits
No commits in common. "81c5f8ee7edb17f1b003a4581b55f2bc8f3ccd53" and "1d4f50fb9f328fe469b6028eecb8e3095306d581" have entirely different histories.
81c5f8ee7e
...
1d4f50fb9f
@ -39,11 +39,6 @@ DEFINES += QT_DEPRECATED_WARNINGS
|
|||||||
# Use 'git pull' instead of 'git fetch'.
|
# Use 'git pull' instead of 'git fetch'.
|
||||||
# Use 'git clone --filter=blob:none' instead of 'git clone' to speed
|
# Use 'git clone --filter=blob:none' instead of 'git clone' to speed
|
||||||
# up cloning of customer repository.
|
# up cloning of customer repository.
|
||||||
# 1.3.13: Fix: if the customer repository is corrupted, remove it and re-clone
|
|
||||||
# the repository (without checking the ISMAS-trigger (WAIT-)button.
|
|
||||||
# 1.3.14: Add additional check for sanity of customer repository using
|
|
||||||
# "git fsck".
|
|
||||||
# Stream-lined code of update process.
|
|
||||||
|
|
||||||
win32 {
|
win32 {
|
||||||
BUILD_DATE=$$system("date /t")
|
BUILD_DATE=$$system("date /t")
|
||||||
|
@ -68,11 +68,7 @@ bool GitClient::gitCloneCustomerRepository() {
|
|||||||
|
|
||||||
Note: git v2.18 does not support treeless clones: --filter=tree:0.
|
Note: git v2.18 does not support treeless clones: --filter=tree:0.
|
||||||
*/
|
*/
|
||||||
|
QString gitCommand("git clone --filter=blob:none ");
|
||||||
// Note: for some reason it is necessary to pass "--progress ---v",
|
|
||||||
// otherwise QProcess returns an error of 128 = 0x80 for the command.
|
|
||||||
|
|
||||||
QString gitCommand("git clone --progress -vvv --filter=blob:none ");
|
|
||||||
gitCommand += m_repositoryPath;
|
gitCommand += m_repositoryPath;
|
||||||
Command c(gitCommand);
|
Command c(gitCommand);
|
||||||
|
|
||||||
@ -83,32 +79,26 @@ bool GitClient::gitCloneCustomerRepository() {
|
|||||||
QString const result = c.getCommandResult();
|
QString const result = c.getCommandResult();
|
||||||
if (!result.isEmpty()) {
|
if (!result.isEmpty()) {
|
||||||
// Cloning into 'customer_281'...\n
|
// Cloning into 'customer_281'...\n
|
||||||
int customer = -1;
|
static QRegularExpression re("(^\\s*Cloning\\s+into\\s+[']\\s*)(.*)(\\s*['].*$)");
|
||||||
int cloning = result.indexOf("Cloning", 0, Qt::CaseInsensitive);
|
QRegularExpressionMatch match = re.match(result);
|
||||||
if (cloning != -1) {
|
if (match.hasMatch()) {
|
||||||
customer = result.indexOf("customer_", cloning, Qt::CaseInsensitive);
|
if (re.captureCount() == 3) { // start with full match (0), then the other 3 matches
|
||||||
if (customer != -1) {
|
QString const &customerNr = match.captured(2).trimmed();
|
||||||
QString customerNr = result.mid(customer);
|
if (customerNr == m_customerNr) {
|
||||||
static constexpr char const ch = '\'';
|
qInfo() << "CLONING" << m_repositoryPath << "OK";
|
||||||
int i = customerNr.indexOf(QChar(ch));
|
return true;
|
||||||
if (i != -1) {
|
|
||||||
if ((customerNr = customerNr.mid(0, i)) == m_customerNr) {
|
|
||||||
qInfo() << "CLONING" << m_repositoryPath << "OK";
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Utils::printCriticalErrorMsg(
|
|
||||||
QString("ERROR CLONE RESULT HAS WRONG CUSTOMER-NR. (%1 != %2) CLONE_RESULT=%3")
|
|
||||||
.arg(customerNr)
|
|
||||||
.arg(m_customerNr)
|
|
||||||
.arg(result));
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
Utils::printCriticalErrorMsg(
|
||||||
|
QString("ERROR CLONE RESULT HAS WRONG CUSTOMER-NR. rcc=%1 customer=%2 CLONE_RESULT=%3")
|
||||||
|
.arg(re.captureCount())
|
||||||
|
.arg(customerNr)
|
||||||
|
.arg(result));
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Utils::printCriticalErrorMsg(
|
Utils::printCriticalErrorMsg(
|
||||||
QString("ERROR CLONE RESULT HAS WRONG FORMAT. CLONING=%1 CUSTOMER=%2 CLONE_RESULT=%3")
|
QString("ERROR CLONE RESULT HAS WRONG FORMAT. rcc=%1 CLONE_RESULT=%2")
|
||||||
.arg(cloning)
|
.arg(re.captureCount())
|
||||||
.arg(customer)
|
|
||||||
.arg(result));
|
.arg(result));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -279,17 +269,6 @@ std::optional<QStringList> GitClient::gitDiff(QString const &commits) {
|
|||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GitClient::gitFsck() {
|
|
||||||
bool r = false;
|
|
||||||
if (QDir(m_customerRepository).exists()) {
|
|
||||||
Command c("git fsck");
|
|
||||||
if ((r = c.execute(m_customerRepository)) == false) {
|
|
||||||
QString const &s = c.getCommandResult().trimmed();
|
|
||||||
Utils::printCriticalErrorMsg(QString("GIT FSCK FAILED: %1").arg(s));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
/*
|
/*
|
||||||
Hat sich nichts geaendert, so werden auch keine Commits <>..<> angezeigt
|
Hat sich nichts geaendert, so werden auch keine Commits <>..<> angezeigt
|
||||||
*/
|
*/
|
||||||
|
@ -47,8 +47,6 @@ class GitClient : public QObject {
|
|||||||
std::optional<QStringList> gitDiff(QString const &commit);
|
std::optional<QStringList> gitDiff(QString const &commit);
|
||||||
std::optional<QStringList> gitMerge();
|
std::optional<QStringList> gitMerge();
|
||||||
|
|
||||||
bool gitFsck();
|
|
||||||
|
|
||||||
QString gitLastCommit(QString fileName);
|
QString gitLastCommit(QString fileName);
|
||||||
QStringList gitShowReason(QString branchName);
|
QStringList gitShowReason(QString branchName);
|
||||||
static QString gitBlob(QString fileName);
|
static QString gitBlob(QString fileName);
|
||||||
|
@ -56,12 +56,6 @@ void IsmasClient::printDebugMessage(int port,
|
|||||||
QString const &clientIP,
|
QString const &clientIP,
|
||||||
int clientPort,
|
int clientPort,
|
||||||
QString const &message) {
|
QString const &message) {
|
||||||
#if 1
|
|
||||||
Q_UNUSED(port);
|
|
||||||
Q_UNUSED(clientIP);
|
|
||||||
Q_UNUSED(clientPort);
|
|
||||||
Q_UNUSED(message);
|
|
||||||
#else
|
|
||||||
qDebug().noquote()
|
qDebug().noquote()
|
||||||
<< "\n"
|
<< "\n"
|
||||||
<< "SEND-REQUEST-RECEIVE-RESPONSE ..." << "\n"
|
<< "SEND-REQUEST-RECEIVE-RESPONSE ..." << "\n"
|
||||||
@ -70,19 +64,12 @@ void IsmasClient::printDebugMessage(int port,
|
|||||||
<< "local address ..." << clientIP << "\n"
|
<< "local address ..." << clientIP << "\n"
|
||||||
<< "local port ......" << clientPort << "\n"
|
<< "local port ......" << clientPort << "\n"
|
||||||
<< message;
|
<< message;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IsmasClient::printInfoMessage(int port,
|
void IsmasClient::printInfoMessage(int port,
|
||||||
QString const &clientIP,
|
QString const &clientIP,
|
||||||
int clientPort,
|
int clientPort,
|
||||||
QString const &message) {
|
QString const &message) {
|
||||||
#if 1
|
|
||||||
Q_UNUSED(port);
|
|
||||||
Q_UNUSED(clientIP);
|
|
||||||
Q_UNUSED(clientPort);
|
|
||||||
Q_UNUSED(message);
|
|
||||||
#else
|
|
||||||
qInfo().noquote()
|
qInfo().noquote()
|
||||||
<< "\n"
|
<< "\n"
|
||||||
<< "SEND-REQUEST-RECEIVE-RESPONSE ..." << "\n"
|
<< "SEND-REQUEST-RECEIVE-RESPONSE ..." << "\n"
|
||||||
@ -91,7 +78,6 @@ void IsmasClient::printInfoMessage(int port,
|
|||||||
<< "local address ..." << clientIP << "\n"
|
<< "local address ..." << clientIP << "\n"
|
||||||
<< "local port ......" << clientPort << "\n"
|
<< "local port ......" << clientPort << "\n"
|
||||||
<< message;
|
<< message;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IsmasClient::printErrorMessage(int port,
|
void IsmasClient::printErrorMessage(int port,
|
||||||
@ -390,18 +376,16 @@ QString IsmasClient::errorBackendNotConnected(QString const &info,
|
|||||||
version.toStdString().c_str());
|
version.toStdString().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
QString IsmasClient::errorGitClone(QString const &info,
|
QString IsmasClient::errorGitClone(int percent, QString const &info, QString const &version) {
|
||||||
QString const &version) {
|
|
||||||
return updateNewsToIsmas("U0003",
|
return updateNewsToIsmas("U0003",
|
||||||
m_progressInPercent,
|
percent,
|
||||||
RESULT_CODE::INSTALL_ERROR,
|
RESULT_CODE::INSTALL_ERROR,
|
||||||
"CLONE CUSTOMER REPOSITORY FAILED",
|
"CLONE CUSTOMER REPOSITORY FAILED",
|
||||||
info.toStdString().c_str(),
|
info.toStdString().c_str(),
|
||||||
version.toStdString().c_str());
|
version.toStdString().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
QString IsmasClient::backendConnected(QString const &info,
|
QString IsmasClient::backendConnected(QString const &info, QString const &version) {
|
||||||
QString const &version) {
|
|
||||||
return updateNewsToIsmas("U0010",
|
return updateNewsToIsmas("U0010",
|
||||||
m_progressInPercent,
|
m_progressInPercent,
|
||||||
RESULT_CODE::SUCCESS,
|
RESULT_CODE::SUCCESS,
|
||||||
@ -410,8 +394,7 @@ QString IsmasClient::backendConnected(QString const &info,
|
|||||||
version.toStdString().c_str());
|
version.toStdString().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
QString IsmasClient::execOpkgCommand(QString const &info,
|
QString IsmasClient::execOpkgCommand(QString const &info, QString const &version) {
|
||||||
QString const &version) {
|
|
||||||
return updateNewsToIsmas("U0010",
|
return updateNewsToIsmas("U0010",
|
||||||
m_progressInPercent,
|
m_progressInPercent,
|
||||||
RESULT_CODE::SUCCESS,
|
RESULT_CODE::SUCCESS,
|
||||||
|
@ -177,7 +177,7 @@ public:
|
|||||||
QString cloneAndCheckoutCustomerRepository(QString const &info, QString const &version = QString()); // clone and checkout customer repository
|
QString cloneAndCheckoutCustomerRepository(QString const &info, QString const &version = QString()); // clone and checkout customer repository
|
||||||
QString checkoutBranch(QString const &info, QString const &version = QString()); // checkout branch
|
QString checkoutBranch(QString const &info, QString const &version = QString()); // checkout branch
|
||||||
QString errorBackendNotConnected(QString const &info, QString const &version = QString()); // checkout branch
|
QString errorBackendNotConnected(QString const &info, QString const &version = QString()); // checkout branch
|
||||||
QString errorGitClone(QString const &info, QString const &version = QString());
|
QString errorGitClone(int percent, QString const &info, QString const &version = QString());
|
||||||
QString backendConnected(QString const &info, QString const &version = QString());
|
QString backendConnected(QString const &info, QString const &version = QString());
|
||||||
QString updateTriggerSet(QString const &info, QString const &version = QString());
|
QString updateTriggerSet(QString const &info, QString const &version = QString());
|
||||||
QString errorUpdateTrigger(QString const &info, QString const &version = QString());
|
QString errorUpdateTrigger(QString const &info, QString const &version = QString());
|
||||||
|
@ -96,7 +96,7 @@ MainWindow::MainWindow(hwinf *hw, Worker *worker, Update *update, QWidget *paren
|
|||||||
, m_worker(worker)
|
, m_worker(worker)
|
||||||
, m_width(70)
|
, m_width(70)
|
||||||
, m_progressRunning(false)
|
, m_progressRunning(false)
|
||||||
// , m_progressValue(0)
|
, m_progressValue(0)
|
||||||
, m_update(update)
|
, m_update(update)
|
||||||
, m_updateStep(UpdateDcEvent::UpdateStep::NONE) {
|
, m_updateStep(UpdateDcEvent::UpdateStep::NONE) {
|
||||||
|
|
||||||
@ -178,22 +178,22 @@ void MainWindow::customEvent(QEvent *event) {
|
|||||||
case START_PROGRESS_LOOP: {
|
case START_PROGRESS_LOOP: {
|
||||||
m_progressRunning = true;
|
m_progressRunning = true;
|
||||||
ui->updateProgress->reset();
|
ui->updateProgress->reset();
|
||||||
// m_progressValue = 10;
|
m_progressValue = 10;
|
||||||
QApplication::postEvent(this, new ProgressEvent(this, 1));
|
QApplication::postEvent(this, new ProgressEvent(this, m_progressValue));
|
||||||
} break;
|
} break;
|
||||||
case STOP_PROGRESS_LOOP: {
|
case STOP_PROGRESS_LOOP: {
|
||||||
m_progressRunning = false;
|
m_progressRunning = false;
|
||||||
// m_progressValue -= 10;
|
m_progressValue -= 10;
|
||||||
// m_worker->setProgress(m_progressValue/10);
|
m_worker->setProgress(m_progressValue/10);
|
||||||
} break;
|
} break;
|
||||||
default: {
|
default: {
|
||||||
if (m_progressRunning) {
|
if (m_progressRunning) {
|
||||||
// m_progressValue = progress;
|
m_progressValue = progress;
|
||||||
ui->updateProgress->setValue(progress);
|
ui->updateProgress->setValue(progress/10);
|
||||||
// ueberpruefen: hauptfenster schickt sich selber ein event
|
QApplication::postEvent(this, new ProgressEvent(this, progress+10));
|
||||||
// QApplication::postEvent(this, new ProgressEvent(this, progress));
|
QThread::msleep(500);
|
||||||
// QThread::msleep(500);
|
}
|
||||||
}}
|
}
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
if (sender == m_worker) {
|
if (sender == m_worker) {
|
||||||
|
@ -34,7 +34,7 @@ public:
|
|||||||
static const int BL_IS_UP_COUNT = 5;
|
static const int BL_IS_UP_COUNT = 5;
|
||||||
static const int BL_STOP_COUNT = 5;
|
static const int BL_STOP_COUNT = 5;
|
||||||
|
|
||||||
// int progressValue() const { return m_progressValue; }
|
int progressValue() const { return m_progressValue; }
|
||||||
hwinf *getPlugin() { return m_hw; }
|
hwinf *getPlugin() { return m_hw; }
|
||||||
hwinf const *getPlugin() const { return m_hw; }
|
hwinf const *getPlugin() const { return m_hw; }
|
||||||
Update *getUpdate() { return m_update; }
|
Update *getUpdate() { return m_update; }
|
||||||
@ -76,7 +76,7 @@ private:
|
|||||||
QTimer *m_startTimer;
|
QTimer *m_startTimer;
|
||||||
QTimer *m_exitTimer;
|
QTimer *m_exitTimer;
|
||||||
bool m_progressRunning;
|
bool m_progressRunning;
|
||||||
//int m_progressValue;
|
int m_progressValue;
|
||||||
Update *m_update;
|
Update *m_update;
|
||||||
UpdateDcEvent::UpdateStep m_updateStep;
|
UpdateDcEvent::UpdateStep m_updateStep;
|
||||||
};
|
};
|
||||||
|
@ -846,8 +846,8 @@ bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
|
|||||||
qCritical() << "UNKNOWN JSON FILE NAME" << fToWorkOn;
|
qCritical() << "UNKNOWN JSON FILE NAME" << fToWorkOn;
|
||||||
res = false;
|
res = false;
|
||||||
}
|
}
|
||||||
// m_worker->stopProgressLoop();
|
m_worker->stopProgressLoop();
|
||||||
// m_worker->setProgress(100);
|
m_worker->setProgress(100);
|
||||||
|
|
||||||
if (res == false) {
|
if (res == false) {
|
||||||
break;
|
break;
|
||||||
|
@ -68,12 +68,6 @@ void Utils::printUpdateStatusMsg(QStringList const &updateMsg) {
|
|||||||
qCritical() << QString(80, 'U');
|
qCritical() << QString(80, 'U');
|
||||||
}
|
}
|
||||||
|
|
||||||
void Utils::printUpdateStatusMsg(QString const &updateMsg) {
|
|
||||||
qCritical() << QString(80, 'U');
|
|
||||||
qCritical() << updateMsg;
|
|
||||||
qCritical() << QString(80, 'U');
|
|
||||||
}
|
|
||||||
|
|
||||||
void Utils::printInfoMsg(QString const &infoMsg) {
|
void Utils::printInfoMsg(QString const &infoMsg) {
|
||||||
qCritical() << QString(80, 'I');
|
qCritical() << QString(80, 'I');
|
||||||
qCritical() << infoMsg;
|
qCritical() << infoMsg;
|
||||||
|
1
utils.h
1
utils.h
@ -17,7 +17,6 @@ namespace Utils {
|
|||||||
void printInfoMsg(QString const &infoMsg);
|
void printInfoMsg(QString const &infoMsg);
|
||||||
void printInfoMsg(QStringList const &infoMsg);
|
void printInfoMsg(QStringList const &infoMsg);
|
||||||
void printUpdateStatusMsg(QStringList const &updateMsg);
|
void printUpdateStatusMsg(QStringList const &updateMsg);
|
||||||
void printUpdateStatusMsg(QString const &updateMsg);
|
|
||||||
void printLineEditInfo(QStringList const &lines);
|
void printLineEditInfo(QStringList const &lines);
|
||||||
QString getTariffLoadTime(QString fileName);
|
QString getTariffLoadTime(QString fileName);
|
||||||
QString rstrip(QString const &str);
|
QString rstrip(QString const &str);
|
||||||
|
634
worker.cpp
634
worker.cpp
@ -17,6 +17,8 @@
|
|||||||
#include <QJsonParseError>
|
#include <QJsonParseError>
|
||||||
#include <Qt>
|
#include <Qt>
|
||||||
|
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
#include "message_handler.h"
|
#include "message_handler.h"
|
||||||
#include "plugins/interfaces.h"
|
#include "plugins/interfaces.h"
|
||||||
#include "ismas/ismas_client.h"
|
#include "ismas/ismas_client.h"
|
||||||
@ -29,8 +31,6 @@ QString const Worker::UPDATE_STEP_DONE(" [done]");
|
|||||||
QString const Worker::UPDATE_STEP_FAIL(" [FAIL]");
|
QString const Worker::UPDATE_STEP_FAIL(" [FAIL]");
|
||||||
QString const Worker::UPDATE_STEP_SUCCESS(" [SUCCESS]");
|
QString const Worker::UPDATE_STEP_SUCCESS(" [SUCCESS]");
|
||||||
|
|
||||||
Worker const *Worker::instance = nullptr;
|
|
||||||
|
|
||||||
Worker::Worker(int customerNr,
|
Worker::Worker(int customerNr,
|
||||||
int machineNr,
|
int machineNr,
|
||||||
int zoneNr,
|
int zoneNr,
|
||||||
@ -73,12 +73,10 @@ Worker::Worker(int customerNr,
|
|||||||
, m_updateProcessRunning(true)
|
, m_updateProcessRunning(true)
|
||||||
, m_returnCode(0)
|
, m_returnCode(0)
|
||||||
, m_mainWindow(nullptr) /* contains plugin */
|
, m_mainWindow(nullptr) /* contains plugin */
|
||||||
|
, m_progressValue(0)
|
||||||
//, m_withoutIsmasDirectPort(true) /* useful for testing */ {
|
//, m_withoutIsmasDirectPort(true) /* useful for testing */ {
|
||||||
, m_withoutIsmasDirectPort(false) /* useful for testing */ {
|
, m_withoutIsmasDirectPort(false) /* useful for testing */ {
|
||||||
|
|
||||||
// TODO: turn object into singleton
|
|
||||||
instance = this;
|
|
||||||
|
|
||||||
this->setObjectName("worker-object");
|
this->setObjectName("worker-object");
|
||||||
QDir::setCurrent(m_workingDirectory);
|
QDir::setCurrent(m_workingDirectory);
|
||||||
|
|
||||||
@ -129,25 +127,19 @@ Worker::~Worker() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Worker::displayProgressInMainWindow(int progress) {
|
void Worker::setProgress(int progress) {
|
||||||
if (m_mainWindow) {
|
if (m_mainWindow) {
|
||||||
QApplication::postEvent(m_mainWindow,
|
m_progressValue = progress;
|
||||||
new ProgressEvent(this, progress));
|
QApplication::postEvent(m_mainWindow, new ProgressEvent(this, progress));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Worker::setProgress(int progress) {
|
|
||||||
m_ismasClient.setProgressInPercent(progress);
|
|
||||||
displayProgressInMainWindow(progress);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Worker::startProgressLoop() {
|
void Worker::startProgressLoop() {
|
||||||
displayProgressInMainWindow(MainWindow::START_PROGRESS_LOOP);
|
QApplication::postEvent(m_mainWindow, new ProgressEvent(this, MainWindow::START_PROGRESS_LOOP));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Worker::stopProgressLoop() {
|
void Worker::stopProgressLoop() {
|
||||||
displayProgressInMainWindow(MainWindow::STOP_PROGRESS_LOOP);
|
QApplication::postEvent(m_mainWindow, new ProgressEvent(this, MainWindow::STOP_PROGRESS_LOOP));
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::once_flag once;
|
static std::once_flag once;
|
||||||
@ -156,244 +148,6 @@ void Worker::update() {
|
|||||||
std::call_once(once, &Worker::privateUpdate, this);
|
std::call_once(once, &Worker::privateUpdate, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Worker::isRepositoryCorrupted() {
|
|
||||||
QDir customerRepository(m_customerRepository);
|
|
||||||
if (customerRepository.exists()) {
|
|
||||||
QDir customerRepositoryEtc(QDir::cleanPath(m_customerRepository + QDir::separator() + "etc/"));
|
|
||||||
QDir customerRepositoryOpt(QDir::cleanPath(m_customerRepository + QDir::separator() + "opt/"));
|
|
||||||
QDir customerRepositoryGit(QDir::cleanPath(m_customerRepository + QDir::separator() + ".git/"));
|
|
||||||
if (!m_gc.gitFsck()
|
|
||||||
// etc-directory inside git-repository does not exist, which means the
|
|
||||||
// git-repository is corrupted -> remove it and start from scratch
|
|
||||||
|| !customerRepositoryEtc.exists()
|
|
||||||
|| !customerRepositoryGit.exists()
|
|
||||||
|| !customerRepositoryOpt.exists()) {
|
|
||||||
// should never happen
|
|
||||||
Utils::printCriticalErrorMsg("CORRUPTED CUSTOMER REPOSITORY");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Worker::repairCorruptedRepository() {
|
|
||||||
QDir customerRepository(m_customerRepository);
|
|
||||||
if (!customerRepository.removeRecursively()) {
|
|
||||||
Utils::printCriticalErrorMsg("ERROR REMOVING CORR. CUST-REPOSITORY");
|
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::REMOVE_GIT_REPOSITORY_FAILED,
|
|
||||||
QString("REMOVAL OF GIT-REPOSITORY %1 FAILED").arg(m_customerRepository));
|
|
||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
|
||||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
|
||||||
m_ismasClient.sanityCheckFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
|
||||||
m_updateStatus.m_statusDescription));
|
|
||||||
emit showErrorMessage("apism sanity check", m_updateStatus.m_statusDescription);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Worker::sendCloneAndCheckoutFailure() {
|
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_CLONE_AND_CHECKOUT_FAILURE,
|
|
||||||
QString("CLONE OR CHECKOUT FAILED: ") + m_customerRepository);
|
|
||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
|
||||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
|
||||||
m_ismasClient.errorGitClone(m_updateStatus.m_statusDescription));
|
|
||||||
|
|
||||||
return CLONE_AND_CHECKOUT_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Worker::sendCloneAndCheckoutSuccess() {
|
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_CLONE_AND_CHECKOUT_SUCCESS,
|
|
||||||
QString("CLONED REPOSITORY %1 AND CHECKED OUT BRANCH %2")
|
|
||||||
.arg(m_customerRepository)
|
|
||||||
.arg(m_gc.branchName()));
|
|
||||||
|
|
||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
|
||||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
|
||||||
m_ismasClient.cloneAndCheckoutCustomerRepository(
|
|
||||||
m_updateStatus.m_statusDescription));
|
|
||||||
|
|
||||||
return CLONE_AND_CHECKOUT_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Worker::sendIsmasTriggerFailure() {
|
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_UPDATE_TRIGGER_SET_FAILURE,
|
|
||||||
QString("ISMAS update trigger wrong"));
|
|
||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
|
||||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
|
||||||
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
|
||||||
"CHECK-UPDATE-TRIGGER",
|
|
||||||
m_updateStatus.m_statusDescription));
|
|
||||||
return ISMAS_TRIGGER_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Worker::sendCustomerEnvironmentConfigurationFailed() {
|
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_CHECKOUT_BRANCH_FAILURE,
|
|
||||||
QString("Configuring customer environment failed"));
|
|
||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
|
||||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
|
||||||
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
|
||||||
"GIT-CHECKOUT-BRANCH",
|
|
||||||
m_updateStatus.m_statusDescription));
|
|
||||||
return ENVIRONMENT_CONFIG_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Worker::sendPullFailure() {
|
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_FETCH_UPDATES_REQUEST_FAILURE,
|
|
||||||
QString("No files to update"));
|
|
||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
|
||||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
|
||||||
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
|
||||||
"FETCH-FILES-TO-UPDATE",
|
|
||||||
m_updateStatus.m_statusDescription));
|
|
||||||
return GIT_PULL_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Worker::sendFileUpdateFailure() {
|
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::PSA_UPDATE_FILES_FAILED,
|
|
||||||
QString("Updating files failed"));
|
|
||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
|
||||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
|
||||||
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
|
||||||
"UPDATE-FILES",
|
|
||||||
m_updateStatus.m_statusDescription));
|
|
||||||
return UPDATE_FILES_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Worker::sendRsyncFailure() {
|
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::RSYNC_UPDATES_FAILURE,
|
|
||||||
QString("Syncing files to update failed"));
|
|
||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
|
||||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
|
||||||
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
|
||||||
"RSYNC-UPDATE-FILES",
|
|
||||||
m_updateStatus.m_statusDescription));
|
|
||||||
|
|
||||||
return RSYNC_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Worker::sendLastVersionFailure() {
|
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_SEND_LAST_VERSION_FAILED,
|
|
||||||
QString("Sending ISMAS last version failed"));
|
|
||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
|
||||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
|
||||||
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
|
||||||
"ISMAS-SEND-LAST-VERSION",
|
|
||||||
m_updateStatus.m_statusDescription));
|
|
||||||
return SEND_LAST_VERSION_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Worker::sendSaveLogFilesFailure() {
|
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::SAVE_LOG_FILES_FAILED,
|
|
||||||
QString("Saving log files failed"));
|
|
||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
|
||||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
|
||||||
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
|
||||||
"SAVE-LOG-FILES",
|
|
||||||
m_updateStatus.m_statusDescription));
|
|
||||||
return SAVE_LOG_FILES_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Worker::sendFoundFilesToUpdateSuccess() {
|
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_CHECK_FILES_TO_UPDATE_SUCCESS,
|
|
||||||
QString("Files to update: ") + m_filesToUpdate.join(','));
|
|
||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
|
||||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
|
||||||
m_ismasClient.updateOfPSAContinues("CHECK-FILES-TO-UPDATE",
|
|
||||||
m_updateStatus.m_statusDescription));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Worker::sendUpdateSucceededAndActivated() {
|
|
||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
|
||||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
|
||||||
m_ismasClient.updateOfPSASucceeded(""));
|
|
||||||
|
|
||||||
//m_ismasClient.setProgressInPercent(100);
|
|
||||||
|
|
||||||
// mark update as activated -> this resets the WAIT button
|
|
||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
|
||||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
|
||||||
m_ismasClient.updateOfPSAActivated());
|
|
||||||
|
|
||||||
return UPDATE_SUCCESS_AND_ACTIVATED;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Worker::sendFinalResult() {
|
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::UPDATE_PROCESS_SUCCESS,
|
|
||||||
QString("Update process succeeded. Reset WAIT."));
|
|
||||||
if (std::optional<QString> s = m_ismasClient.finalResult(IsmasClient::RESULT_CODE::SUCCESS,
|
|
||||||
m_updateStatus.m_statusDescription)) {
|
|
||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
|
||||||
QString("#M=APISM#C=CMD_EVENT#J=") + s.value());
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#if 0
|
|
||||||
void Worker::printProgress(UPDATE_STEP step) {
|
|
||||||
switch(step) {
|
|
||||||
case UPDATE_STEP::SANITY_CHECK:
|
|
||||||
Utils::printUpdateStatusMsg(
|
|
||||||
QStringList()
|
|
||||||
<< QString("STEP 1: CHECKED SANITY OF CUSTOMER REPOSITORY %1 DONE")
|
|
||||||
.arg(m_customerRepository)
|
|
||||||
<< QString("STEP 2: FETCH CUSTOMER REPOSITORY %1...")
|
|
||||||
.arg(m_customerRepository));
|
|
||||||
break;
|
|
||||||
case UPDATE_STEP::FETCH_REPOSITORY:
|
|
||||||
Utils::printUpdateStatusMsg(
|
|
||||||
QStringList()
|
|
||||||
<< QString("STEP 2: FETCHED CUSTOMER REPOSITORY %1 DONE")
|
|
||||||
.arg(m_customerRepository)
|
|
||||||
<< QString("STEP 3: CHECK ISMAS-UPDATE-TRIGGER FOR WAIT-STATUS..."));
|
|
||||||
break;
|
|
||||||
case UPDATE_STEP::CHECK_ISMAS_TRIGGER:
|
|
||||||
Utils::printUpdateStatusMsg(
|
|
||||||
QStringList()
|
|
||||||
<< QString("STEP 3: CHECKED ISMAS-UPDATE-TRIGGER FOR WAIT-STATUS. SUCCESS.")
|
|
||||||
<< QString("STEP 4: CHECK-OUT BRANCH %1...").arg(m_gc.branchName()));
|
|
||||||
break;
|
|
||||||
case UPDATE_STEP::CHECKED_OUT_BRANCH:
|
|
||||||
Utils::printUpdateStatusMsg(
|
|
||||||
QStringList()
|
|
||||||
<< QString("STEP 4: CHECKED-OUT BRANCH %1 DONE")
|
|
||||||
.arg(m_gc.branchName())
|
|
||||||
<< QString("STEP 5: COMPUTE FILES-TO-UPDATE..."));
|
|
||||||
break;
|
|
||||||
case UPDATE_STEP::COMPUTE_FILES_TO_UPDATE:
|
|
||||||
Utils::printUpdateStatusMsg(
|
|
||||||
QStringList()
|
|
||||||
<< QString("STEP 5: COMPUTE FILES-TO-UPDATE %1 DONE")
|
|
||||||
.arg(m_filesToUpdate.join(','))
|
|
||||||
<< QString("STEP 6: DOWNLOAD FILES-TO-DOWNLOAD %1 AND EXECUTE OPKG_COMMANDS...")
|
|
||||||
.arg(m_filesToDownload.join(',')));
|
|
||||||
break;
|
|
||||||
case UPDATE_STEP::DOWNLOAD_FILES_TO_UPDATE:
|
|
||||||
Utils::printUpdateStatusMsg(
|
|
||||||
QStringList()
|
|
||||||
<< QString("STEP 6: DOWNLOAD FILES-TO-DOWNLOAD %1 AND EXECUTE OPKG_COMMANDS DONE")
|
|
||||||
.arg(m_filesToDownload.join(','))
|
|
||||||
<< QString("STEP 7: SYNC CUSTOMER REPOSITORY %1 WITH FILESYSTEM...")
|
|
||||||
.arg(m_customerRepository));
|
|
||||||
break;
|
|
||||||
case UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY:
|
|
||||||
Utils::printUpdateStatusMsg(
|
|
||||||
QStringList()
|
|
||||||
<< QString("STEP 7: SYNC CUSTOMER REPOSITORY %1 WITH FILESYSTEM DONE")
|
|
||||||
.arg(m_customerRepository)
|
|
||||||
<< QString("STEP 8: SEND-LAST-VERSION TO ISMAS..."));
|
|
||||||
break;
|
|
||||||
case UPDATE_STEP::UPDATE_SUCCESS:
|
|
||||||
Utils::printUpdateStatusMsg(
|
|
||||||
QStringList()
|
|
||||||
<< QString("STEP 9: SAVE-LOG-FILES (FUTURE USE) DONE")
|
|
||||||
<< QString("STEP 10: MARK UPDATE AS SUCCESSFUL AND ACTIVE..."));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void Worker::privateUpdate() {
|
void Worker::privateUpdate() {
|
||||||
if (!m_mainWindow) {
|
if (!m_mainWindow) {
|
||||||
Utils::printCriticalErrorMsg("m_mainWindow NOT SET");
|
Utils::printCriticalErrorMsg("m_mainWindow NOT SET");
|
||||||
@ -406,134 +160,183 @@ void Worker::privateUpdate() {
|
|||||||
emit disableExit();
|
emit disableExit();
|
||||||
|
|
||||||
m_returnCode = -1;
|
m_returnCode = -1;
|
||||||
|
|
||||||
QDir customerRepository(m_customerRepository);
|
QDir customerRepository(m_customerRepository);
|
||||||
QDir customerRepositoryEtc(QDir::cleanPath(m_customerRepository + QDir::separator() + "etc/"));
|
if (!customerRepository.exists()) {
|
||||||
|
emit appendText("\nInitializing customer environment ...");
|
||||||
|
startProgressLoop();
|
||||||
|
if (m_gc.gitCloneAndCheckoutBranch()) {
|
||||||
|
stopProgressLoop();
|
||||||
|
emit replaceLast("Initializing customer environment", UPDATE_STEP_DONE);
|
||||||
|
|
||||||
Utils::printUpdateStatusMsg(
|
setProgress(5);
|
||||||
QStringList()
|
|
||||||
<< QString("STEP 1: CHECK SANITY OF CUSTOMER REPOSITORY %1...")
|
|
||||||
.arg(m_customerRepository));
|
|
||||||
|
|
||||||
bool initialClone = false; // the customer repository is cloned without
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_CLONE_AND_CHECKOUT_SUCCESS,
|
||||||
// checking the ISMAS-trigger (WAIT-)button.
|
QString("CLONED AND CHECKED OUT: ") + m_customerRepository);
|
||||||
// but if there was a sane repository
|
|
||||||
// available, then the trigger-button must
|
|
||||||
// have been activated in ISMAS.
|
|
||||||
|
|
||||||
bool continueUpdate = true; // check if git-clone command has timed-out,
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
// resulting in a corrupted git-repository, which
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
// does not contain an ./etc-directory
|
m_ismasClient.cloneAndCheckoutCustomerRepository(
|
||||||
if (isRepositoryCorrupted()) {
|
m_updateStatus.m_statusDescription));
|
||||||
QString s("CORRUPTED CUSTOMER REPOSITORY. REPAIRING...");
|
|
||||||
if ((continueUpdate = repairCorruptedRepository()) == true) {
|
setProgress(10);
|
||||||
Utils::printUpdateStatusMsg(
|
|
||||||
QStringList() << s <<
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
QString("CORRUPTED CUSTOMER REPOSITORY. REPAIRING...DONE"));
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
|
m_ismasClient.updateOfPSASucceeded(""));
|
||||||
|
|
||||||
|
setProgress(100);
|
||||||
|
m_ismasClient.setProgressInPercent(100);
|
||||||
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
|
QString("#M=APISM#C=CMD_EVENT#J=") + m_ismasClient.updateOfPSAActivated());
|
||||||
|
|
||||||
|
m_returnCode = 0;
|
||||||
} else {
|
} else {
|
||||||
Utils::printUpdateStatusMsg(
|
stopProgressLoop();
|
||||||
QStringList() << s <<
|
setProgress(0);
|
||||||
QString("CORRUPTED CUSTOMER REPOSITORY. REPAIRING...FAIL"));
|
|
||||||
|
emit replaceLast("Initializing customer environment", UPDATE_STEP_FAIL);
|
||||||
|
|
||||||
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_CLONE_AND_CHECKOUT_FAILURE,
|
||||||
|
QString("CLONE OR CHECKOUT FAILED: ") + m_customerRepository);
|
||||||
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
|
m_ismasClient.errorGitClone(100, m_updateStatus.m_statusDescription));
|
||||||
|
|
||||||
|
m_returnCode = -3;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (updateTriggerSet(5)) {
|
||||||
|
if (customerEnvironment(30)) {
|
||||||
|
m_ismasClient.setProgressInPercent(50);
|
||||||
|
if (filesToUpdate()) {
|
||||||
|
// send message to ISMAS about files which have been
|
||||||
|
// checked in into git repository
|
||||||
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_CHECK_FILES_TO_UPDATE_SUCCESS,
|
||||||
|
QString("Files to update: ") + m_filesToUpdate.join(','));
|
||||||
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
|
m_ismasClient.updateOfPSAContinues("CHECK-FILES-TO-UPDATE",
|
||||||
|
m_updateStatus.m_statusDescription));
|
||||||
|
if (updateFiles(60)) {
|
||||||
|
m_ismasClient.setProgressInPercent(70);
|
||||||
|
if (syncCustomerRepositoryAndFS()) {
|
||||||
|
m_ismasClient.setProgressInPercent(80);
|
||||||
|
if (sendIsmasLastVersionNotification()) {
|
||||||
|
m_ismasClient.setProgressInPercent(90);
|
||||||
|
sentIsmasLastVersionNotification = true;
|
||||||
|
if (saveLogFile()) {
|
||||||
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
|
m_ismasClient.updateOfPSASucceeded(""));
|
||||||
|
|
||||||
|
// mark update as activated -> this resets the WAIT button
|
||||||
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
|
m_ismasClient.updateOfPSAActivated());
|
||||||
|
|
||||||
|
m_returnCode = 0;
|
||||||
|
} else {
|
||||||
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::SAVE_LOG_FILES_FAILED,
|
||||||
|
QString("Saving log files failed"));
|
||||||
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
|
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
||||||
|
"SAVE-LOG-FILES",
|
||||||
|
m_updateStatus.m_statusDescription));
|
||||||
|
m_returnCode = -11;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_SEND_LAST_VERSION_FAILED,
|
||||||
|
QString("Sending ISMAS last version failed"));
|
||||||
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
|
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
||||||
|
"ISMAS-SEND-LAST-VERSION",
|
||||||
|
m_updateStatus.m_statusDescription));
|
||||||
|
m_returnCode = -10;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::RSYNC_UPDATES_FAILURE,
|
||||||
|
QString("Syncing files to update failed"));
|
||||||
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
|
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
||||||
|
"RSYNC-UPDATE-FILES",
|
||||||
|
m_updateStatus.m_statusDescription));
|
||||||
|
m_returnCode = -9;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::PSA_UPDATE_FILES_FAILED,
|
||||||
|
QString("Updating files failed"));
|
||||||
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
|
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
||||||
|
"UPDATE-FILES",
|
||||||
|
m_updateStatus.m_statusDescription));
|
||||||
|
m_returnCode = -8;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_FETCH_UPDATES_REQUEST_FAILURE,
|
||||||
|
QString("No files to update"));
|
||||||
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
|
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
||||||
|
"FETCH-FILES-TO-UPDATE",
|
||||||
|
m_updateStatus.m_statusDescription));
|
||||||
|
m_returnCode = -7;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_CHECKOUT_BRANCH_FAILURE,
|
||||||
|
QString("Configuring customer environment failed"));
|
||||||
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
|
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
||||||
|
"GIT-CHECKOUT-BRANCH",
|
||||||
|
m_updateStatus.m_statusDescription));
|
||||||
|
m_returnCode = -6;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_UPDATE_TRIGGER_SET_FAILURE,
|
||||||
|
QString("ISMAS update trigger wrong"));
|
||||||
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
|
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
||||||
|
"CHECK-UPDATE-TRIGGER",
|
||||||
|
m_updateStatus.m_statusDescription));
|
||||||
|
m_returnCode = -5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (continueUpdate) {
|
m_ismasClient.setProgressInPercent(100);
|
||||||
// qDebug() << UPDATE_STEP::SANITY_CHECK;
|
setProgress(100);
|
||||||
if ((continueUpdate = customerRepository.exists()) == false) {
|
|
||||||
emit appendText("\nInitializing customer environment ...");
|
|
||||||
startProgressLoop();
|
|
||||||
for (int i = 0; i < 5; ++i) { // try to checkout git repository
|
|
||||||
setProgress(i); // and switch to branch
|
|
||||||
if (m_gc.gitCloneAndCheckoutBranch()) {
|
|
||||||
if (!isRepositoryCorrupted()) {
|
|
||||||
emit replaceLast("Initializing customer environment", UPDATE_STEP_DONE);
|
|
||||||
m_returnCode = sendCloneAndCheckoutSuccess();
|
|
||||||
continueUpdate = true;
|
|
||||||
initialClone = true;
|
|
||||||
Utils::printInfoMsg("INITIAL CLONE DONE");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
QThread::sleep(1); // maybe git needs more time
|
|
||||||
}
|
|
||||||
if (continueUpdate == false) {
|
|
||||||
emit replaceLast("Initializing customer environment", UPDATE_STEP_FAIL);
|
|
||||||
m_returnCode = sendCloneAndCheckoutFailure();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!initialClone) {
|
if (m_returnCode != 0) {
|
||||||
// qDebug() << UPDATE_STEP::FETCH_REPOSITORY;
|
stopProgressLoop();
|
||||||
} else {
|
emit appendText(QString("UPDATE "), UPDATE_STEP_FAIL);
|
||||||
Utils::printUpdateStatusMsg(
|
|
||||||
QString("STEP 2: FETCHED CUSTOMER REPOSITORY %1 DONE")
|
|
||||||
.arg(m_customerRepository));
|
|
||||||
} // repository is neither not existent nor
|
|
||||||
} // corrupted. check now if the ISMAS-trigger
|
|
||||||
if (continueUpdate) { // (WAIT-BUTTON) is activated even in case of
|
|
||||||
// initial checkout
|
|
||||||
if ((continueUpdate = updateTriggerSet(10)) == false) {
|
|
||||||
m_returnCode = sendIsmasTriggerFailure();
|
|
||||||
}
|
|
||||||
if (continueUpdate) { // configure customer environment -> checkout
|
|
||||||
// branch in case someone has change the zone_nr
|
|
||||||
//qDebug() << UPDATE_STEP::CHECK_ISMAS_TRIGGER;
|
|
||||||
if ((continueUpdate = customerEnvironment(30)) == false) {
|
|
||||||
m_returnCode = sendCustomerEnvironmentConfigurationFailed();
|
|
||||||
} // determine which files has to be updated:
|
|
||||||
} // either sent to the hardware or rsynced with
|
|
||||||
if (continueUpdate) { // the filesystem in case of tariff-files
|
|
||||||
//qDebug() << UPDATE_STEP::CHECKED_OUT_BRANCH;
|
|
||||||
if ((continueUpdate = filesToUpdate(50)) == false) {
|
|
||||||
m_returnCode = sendPullFailure();
|
|
||||||
}
|
|
||||||
} // send message to ISMAS about files which have
|
|
||||||
if (continueUpdate) { // been checked in into git repository
|
|
||||||
//qDebug() << UPDATE_STEP::COMPUTE_FILES_TO_UPDATE;
|
|
||||||
sendFoundFilesToUpdateSuccess();
|
|
||||||
if ((continueUpdate = updateFiles(60)) == false) {
|
|
||||||
m_returnCode = sendFileUpdateFailure();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (continueUpdate) { // rsync (changed) files to file system
|
|
||||||
//qDebug() << UPDATE_STEP::DOWNLOAD_FILES_TO_UPDATE;
|
|
||||||
// TODO: rsync das komplette repository
|
|
||||||
if ((continueUpdate = syncCustomerRepositoryAndFS(70)) == false) {
|
|
||||||
m_returnCode = sendRsyncFailure();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (continueUpdate) { // send message to ISMAS about installed versions
|
|
||||||
//qDebug() << UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY;
|
|
||||||
if ((continueUpdate = sendIsmasLastVersionNotification(80)) == false) {
|
|
||||||
m_returnCode = sendLastVersionFailure();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (continueUpdate) { // future use: save logs of update process
|
|
||||||
sentIsmasLastVersionNotification = true;
|
|
||||||
if ((continueUpdate = saveLogFile(90)) == false) {
|
|
||||||
m_returnCode = sendSaveLogFilesFailure();
|
|
||||||
}
|
|
||||||
} // send message to ISMAS that update process
|
|
||||||
if (continueUpdate) { // succeeded
|
|
||||||
//qDebug() << UPDATE_STEP::UPDATE_SUCCESS;
|
|
||||||
sendUpdateSucceededAndActivated();
|
|
||||||
m_returnCode = UPDATE_SUCCESS_AND_ACTIVATED;
|
|
||||||
}
|
|
||||||
|
|
||||||
setProgress(100);
|
// m_updateStatus = UpdateStatus(UPDATE_STATUS::UPDATE_PROCESS_FAILURE,
|
||||||
|
// QString("Update process failed"));
|
||||||
|
// if (std::optional<QString> s = m_ismasClient.finalResult(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
||||||
|
// m_updateStatus.m_statusDescription)) {
|
||||||
|
// IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
|
// QString("#M=APISM#C=CMD_EVENT#J=") + s.value());
|
||||||
|
// }
|
||||||
|
|
||||||
if (m_returnCode != 0) {
|
} else {
|
||||||
stopProgressLoop();
|
emit appendText(QString("UPDATE "), UPDATE_STEP_SUCCESS);
|
||||||
emit appendText(QString("UPDATE "), UPDATE_STEP_FAIL);
|
|
||||||
} else {
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::UPDATE_PROCESS_SUCCESS,
|
||||||
emit appendText(QString("UPDATE "), UPDATE_STEP_SUCCESS);
|
QString("Update process succeeded. Reset WAIT."));
|
||||||
sendFinalResult();
|
if (std::optional<QString> s = m_ismasClient.finalResult(IsmasClient::RESULT_CODE::SUCCESS,
|
||||||
|
m_updateStatus.m_statusDescription)) {
|
||||||
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
|
QString("#M=APISM#C=CMD_EVENT#J=") + s.value());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sentIsmasLastVersionNotification) {
|
if (!sentIsmasLastVersionNotification) {
|
||||||
// try even if the backend is not connected
|
// try even if the backend is not connected
|
||||||
sendIsmasLastVersionNotification(100);
|
sendIsmasLastVersionNotification();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_updateProcessRunning = false;
|
m_updateProcessRunning = false;
|
||||||
@ -637,7 +440,7 @@ bool Worker::updateTriggerSet(int progress) {
|
|||||||
= IsmasClient::sendRequestReceiveResponse(
|
= IsmasClient::sendRequestReceiveResponse(
|
||||||
IsmasClient::APISM::DIRECT_PORT, "#M=APISM#C=REQ_ISMASPARAMETER#J={}")) {
|
IsmasClient::APISM::DIRECT_PORT, "#M=APISM#C=REQ_ISMASPARAMETER#J={}")) {
|
||||||
stopProgressLoop();
|
stopProgressLoop();
|
||||||
// setProgress(m_mainWindow->progressValue()/10 + 11);
|
setProgress(m_mainWindow->progressValue()/10 + 11);
|
||||||
|
|
||||||
QString msg = result.value();
|
QString msg = result.value();
|
||||||
|
|
||||||
@ -648,7 +451,7 @@ bool Worker::updateTriggerSet(int progress) {
|
|||||||
if (parseError.error != QJsonParseError::NoError) {
|
if (parseError.error != QJsonParseError::NoError) {
|
||||||
qCritical() << "(2) INVALID JSON MSG: PARSING FAILED (msg=" << msg << "):"
|
qCritical() << "(2) INVALID JSON MSG: PARSING FAILED (msg=" << msg << "):"
|
||||||
<< parseError.error << parseError.errorString();
|
<< parseError.error << parseError.errorString();
|
||||||
//setProgress(100);
|
setProgress(100);
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::JSON_PARSE_FAILURE,
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::JSON_PARSE_FAILURE,
|
||||||
QString("(2) INVALID JSON %1 %2 %3")
|
QString("(2) INVALID JSON %1 %2 %3")
|
||||||
.arg(msg)
|
.arg(msg)
|
||||||
@ -665,7 +468,7 @@ bool Worker::updateTriggerSet(int progress) {
|
|||||||
}
|
}
|
||||||
if (!document.isObject()) {
|
if (!document.isObject()) {
|
||||||
qCritical() << "FILE IS NOT A JSON OBJECT!";
|
qCritical() << "FILE IS NOT A JSON OBJECT!";
|
||||||
//setProgress(100);
|
setProgress(100);
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::JSON_PARSE_FAILURE,
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::JSON_PARSE_FAILURE,
|
||||||
QString("NOT A JSON-OBJECT %1").arg(msg));
|
QString("NOT A JSON-OBJECT %1").arg(msg));
|
||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
@ -676,13 +479,13 @@ bool Worker::updateTriggerSet(int progress) {
|
|||||||
emit replaceLast(CHECK_UPDATE_TRIGGER_SET, UPDATE_STEP_FAIL);
|
emit replaceLast(CHECK_UPDATE_TRIGGER_SET, UPDATE_STEP_FAIL);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// setProgress(m_mainWindow->progressValue()/10 + 11);
|
setProgress(m_mainWindow->progressValue()/10 + 11);
|
||||||
|
|
||||||
QJsonObject obj = document.object();
|
QJsonObject obj = document.object();
|
||||||
|
|
||||||
// always look for an 'error' first
|
// always look for an 'error' first
|
||||||
if (obj.contains("error")) {
|
if (obj.contains("error")) {
|
||||||
// setProgress(m_mainWindow->progressValue()/10 + 11);
|
setProgress(m_mainWindow->progressValue()/10 + 11);
|
||||||
QString value = obj.value("error").toString();
|
QString value = obj.value("error").toString();
|
||||||
emit showErrorMessage("check update trigger", QString("REPEAT %1 error=<").arg(repeat) + value + ">");
|
emit showErrorMessage("check update trigger", QString("REPEAT %1 error=<").arg(repeat) + value + ">");
|
||||||
qInfo() << "REPEAT" << repeat << "In updateTriggerSet() error=<"
|
qInfo() << "REPEAT" << repeat << "In updateTriggerSet() error=<"
|
||||||
@ -703,7 +506,7 @@ bool Worker::updateTriggerSet(int progress) {
|
|||||||
int customerNr = c.toInt(-1);
|
int customerNr = c.toInt(-1);
|
||||||
int machineNr = m.toInt(-1);
|
int machineNr = m.toInt(-1);
|
||||||
if (customerNr != m_customerNr) {
|
if (customerNr != m_customerNr) {
|
||||||
//setProgress(100);
|
setProgress(100);
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_FAILURE,
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_FAILURE,
|
||||||
QString("CUSTOMER-NR (%1) != LOCAL CUSTOMER-NR (%2)")
|
QString("CUSTOMER-NR (%1) != LOCAL CUSTOMER-NR (%2)")
|
||||||
.arg(customerNr).arg(m_customerNr));
|
.arg(customerNr).arg(m_customerNr));
|
||||||
@ -716,6 +519,7 @@ bool Worker::updateTriggerSet(int progress) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (machineNr != m_machineNr) {
|
if (machineNr != m_machineNr) {
|
||||||
|
setProgress(100);
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_FAILURE,
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_FAILURE,
|
||||||
QString("MACHINE-NR (%1) != LOCAL MACHINE-NR (%2)")
|
QString("MACHINE-NR (%1) != LOCAL MACHINE-NR (%2)")
|
||||||
.arg(machineNr).arg(m_machineNr));
|
.arg(machineNr).arg(m_machineNr));
|
||||||
@ -731,6 +535,7 @@ bool Worker::updateTriggerSet(int progress) {
|
|||||||
qInfo() << "MACHINE-AND-CUSTOMER-CHECK" << m_updateStatus.m_statusDescription;
|
qInfo() << "MACHINE-AND-CUSTOMER-CHECK" << m_updateStatus.m_statusDescription;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
setProgress(100);
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_FAILURE,
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_FAILURE,
|
||||||
"Dev_ID DOES NOT CONTAIN Custom_ID AND/OR Device_ID");
|
"Dev_ID DOES NOT CONTAIN Custom_ID AND/OR Device_ID");
|
||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
@ -742,6 +547,7 @@ bool Worker::updateTriggerSet(int progress) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
setProgress(100);
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_FAILURE,
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_FAILURE,
|
||||||
"Dev_ID KEY NOT A JSON-OBJECT");
|
"Dev_ID KEY NOT A JSON-OBJECT");
|
||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
@ -753,6 +559,7 @@ bool Worker::updateTriggerSet(int progress) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
setProgress(100);
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_FAILURE,
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_FAILURE,
|
||||||
"Dev_ID KEY NOT AVAILABLE");
|
"Dev_ID KEY NOT AVAILABLE");
|
||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
@ -763,7 +570,7 @@ bool Worker::updateTriggerSet(int progress) {
|
|||||||
emit replaceLast(CHECK_UPDATE_TRIGGER_SET, UPDATE_STEP_FAIL);
|
emit replaceLast(CHECK_UPDATE_TRIGGER_SET, UPDATE_STEP_FAIL);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// setProgress(m_mainWindow->progressValue()/10 + 11);
|
setProgress(m_mainWindow->progressValue()/10 + 11);
|
||||||
|
|
||||||
if (obj.contains("Fileupload")) {
|
if (obj.contains("Fileupload")) {
|
||||||
QJsonValue v = obj.value("Fileupload");
|
QJsonValue v = obj.value("Fileupload");
|
||||||
@ -777,6 +584,7 @@ bool Worker::updateTriggerSet(int progress) {
|
|||||||
<< triggerValue << ">";
|
<< triggerValue << ">";
|
||||||
|
|
||||||
if (triggerValue == "WAIT") {
|
if (triggerValue == "WAIT") {
|
||||||
|
setProgress(100);
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_SANITY_CHECK_OK,
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_SANITY_CHECK_OK,
|
||||||
QString("MACHINE-NR (%1) AND CUST-NR (%2) OK")
|
QString("MACHINE-NR (%1) AND CUST-NR (%2) OK")
|
||||||
.arg(m_machineNr).arg(m_customerNr));
|
.arg(m_machineNr).arg(m_customerNr));
|
||||||
@ -802,12 +610,13 @@ bool Worker::updateTriggerSet(int progress) {
|
|||||||
} else
|
} else
|
||||||
if (QRegExp("\\s*").exactMatch(triggerValue)) { // check for whitespace
|
if (QRegExp("\\s*").exactMatch(triggerValue)) { // check for whitespace
|
||||||
stopProgressLoop();
|
stopProgressLoop();
|
||||||
// setProgress(m_mainWindow->progressValue()/10 + 11);
|
setProgress(m_mainWindow->progressValue()/10 + 11);
|
||||||
emit showErrorMessage("check update trigger", "empty update-trigger");
|
emit showErrorMessage("check update trigger", "empty update-trigger");
|
||||||
QThread::sleep(6);
|
QThread::sleep(6);
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
// if the download-button once has the wrong value, it will never recover
|
// if the download-button once has the wrong value, it will never recover
|
||||||
|
setProgress(100);
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_FAILURE,
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_FAILURE,
|
||||||
QString("TRIGGER-VALUE=<") + triggerValue + "> NOT 'WAIT'");
|
QString("TRIGGER-VALUE=<") + triggerValue + "> NOT 'WAIT'");
|
||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
@ -819,6 +628,7 @@ bool Worker::updateTriggerSet(int progress) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
setProgress(100);
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_FAILURE,
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_FAILURE,
|
||||||
"TRG KEY NOT AVAILABLE");
|
"TRG KEY NOT AVAILABLE");
|
||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
@ -830,6 +640,7 @@ bool Worker::updateTriggerSet(int progress) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
setProgress(100);
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_FAILURE,
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_FAILURE,
|
||||||
"Fileupload NOT A JSON-OBJECT");
|
"Fileupload NOT A JSON-OBJECT");
|
||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
@ -841,6 +652,7 @@ bool Worker::updateTriggerSet(int progress) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
setProgress(100);
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_FAILURE,
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_FAILURE,
|
||||||
"Fileupload KEY NOT AVAILABLE");
|
"Fileupload KEY NOT AVAILABLE");
|
||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
@ -853,12 +665,13 @@ bool Worker::updateTriggerSet(int progress) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
stopProgressLoop();
|
stopProgressLoop();
|
||||||
//setProgress(m_mainWindow->progressValue()/10 + 11);
|
setProgress(m_mainWindow->progressValue()/10 + 11);
|
||||||
emit showErrorMessage("check update trigger", "no ISMAS response");
|
emit showErrorMessage("check update trigger", "no ISMAS response");
|
||||||
QThread::sleep(6);
|
QThread::sleep(6);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setProgress(100);
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_UPDATE_TRIGGER_NOT_SET_OR_WRONG,
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_UPDATE_TRIGGER_NOT_SET_OR_WRONG,
|
||||||
QString("ISMAS_UPDATE-TRIGGER-NOT-SET-OR-WRONG: VALUE=(") +
|
QString("ISMAS_UPDATE-TRIGGER-NOT-SET-OR-WRONG: VALUE=(") +
|
||||||
triggerValue + ")");
|
triggerValue + ")");
|
||||||
@ -874,7 +687,7 @@ bool Worker::customerEnvironment(int progress) {
|
|||||||
emit appendText("\nPrepare customer environment ...");
|
emit appendText("\nPrepare customer environment ...");
|
||||||
if (QDir(m_customerRepository).exists()) {
|
if (QDir(m_customerRepository).exists()) {
|
||||||
startProgressLoop();
|
startProgressLoop();
|
||||||
// setProgress(m_mainWindow->progressValue()/10 + 11);
|
setProgress(m_mainWindow->progressValue()/10 + 11);
|
||||||
if (m_gc.gitCheckoutBranch()) {
|
if (m_gc.gitCheckoutBranch()) {
|
||||||
stopProgressLoop();
|
stopProgressLoop();
|
||||||
m_ismasClient.setProgressInPercent(progress);
|
m_ismasClient.setProgressInPercent(progress);
|
||||||
@ -886,6 +699,7 @@ bool Worker::customerEnvironment(int progress) {
|
|||||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
m_ismasClient.checkoutBranch(m_updateStatus.m_statusDescription, ""));
|
m_ismasClient.checkoutBranch(m_updateStatus.m_statusDescription, ""));
|
||||||
|
|
||||||
|
setProgress(100);
|
||||||
emit replaceLast("Prepare customer environment ...", UPDATE_STEP_DONE);
|
emit replaceLast("Prepare customer environment ...", UPDATE_STEP_DONE);
|
||||||
qInfo() << "PREPARE CUSTOMER ENVIRONMENT DONE";
|
qInfo() << "PREPARE CUSTOMER ENVIRONMENT DONE";
|
||||||
return true;
|
return true;
|
||||||
@ -902,13 +716,12 @@ bool Worker::customerEnvironment(int progress) {
|
|||||||
Utils::printCriticalErrorMsg(m_customerRepository + " DOES NOT EXIST");
|
Utils::printCriticalErrorMsg(m_customerRepository + " DOES NOT EXIST");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setProgress(100);
|
||||||
emit replaceLast("Prepare customer environment ...", UPDATE_STEP_FAIL);
|
emit replaceLast("Prepare customer environment ...", UPDATE_STEP_FAIL);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Worker::filesToUpdate(int progress) {
|
bool Worker::filesToUpdate() {
|
||||||
m_ismasClient.setProgressInPercent(progress);
|
|
||||||
|
|
||||||
emit appendText("\nFetch changes files ...");
|
emit appendText("\nFetch changes files ...");
|
||||||
startProgressLoop();
|
startProgressLoop();
|
||||||
|
|
||||||
@ -916,11 +729,17 @@ bool Worker::filesToUpdate(int progress) {
|
|||||||
m_filesToUpdate << "etc/psa_update/opkg_commands";
|
m_filesToUpdate << "etc/psa_update/opkg_commands";
|
||||||
|
|
||||||
if (std::optional<QString> changes = m_gc.gitPull()) {
|
if (std::optional<QString> changes = m_gc.gitPull()) {
|
||||||
|
stopProgressLoop();
|
||||||
|
int progress = (m_mainWindow->progressValue()/10) + 10;
|
||||||
|
setProgress(progress);
|
||||||
|
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_FETCH_UPDATES,
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_FETCH_UPDATES,
|
||||||
QString("FETCHING OF ") + m_customerRepositoryPath +
|
QString("FETCHING OF ") + m_customerRepositoryPath +
|
||||||
QString(" INTO ") + m_customerRepository);
|
QString(" INTO ") + m_customerRepository);
|
||||||
|
|
||||||
|
setProgress(progress + 10);
|
||||||
if (std::optional<QStringList> changedFileNames = m_gc.gitDiff(changes.value())) {
|
if (std::optional<QStringList> changedFileNames = m_gc.gitDiff(changes.value())) {
|
||||||
|
setProgress(progress + 20);
|
||||||
if (m_gc.gitPull()) {
|
if (m_gc.gitPull()) {
|
||||||
emit replaceLast(QString("Fetch changes files ..."), UPDATE_STEP_DONE);
|
emit replaceLast(QString("Fetch changes files ..."), UPDATE_STEP_DONE);
|
||||||
m_filesToUpdate << changedFileNames.value();
|
m_filesToUpdate << changedFileNames.value();
|
||||||
@ -929,6 +748,10 @@ bool Worker::filesToUpdate(int progress) {
|
|||||||
Utils::printCriticalErrorMsg("PULLING FILES FAILED");
|
Utils::printCriticalErrorMsg("PULLING FILES FAILED");
|
||||||
|
|
||||||
emit replaceLast(QString("Fetch changes files ..."), UPDATE_STEP_FAIL);
|
emit replaceLast(QString("Fetch changes files ..."), UPDATE_STEP_FAIL);
|
||||||
|
|
||||||
|
stopProgressLoop();
|
||||||
|
setProgress(100);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -946,13 +769,15 @@ bool Worker::filesToUpdate(int progress) {
|
|||||||
emit appendText("Found 1 file to update :", UPDATE_STEP_DONE);
|
emit appendText("Found 1 file to update :", UPDATE_STEP_DONE);
|
||||||
emit appendText(QString("\n ") + m_filesToUpdate.at(0));
|
emit appendText(QString("\n ") + m_filesToUpdate.at(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setProgress(progress + 30);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Worker::updateFiles(int percent) {
|
bool Worker::updateFiles(quint8 percent) {
|
||||||
m_filesToDownload.clear();
|
QStringList filesToDownload;
|
||||||
m_displayIndex = 0;
|
m_displayIndex = 0;
|
||||||
startProgressLoop();
|
startProgressLoop();
|
||||||
for (int i = 0; i < m_filesToUpdate.size(); ++i) {
|
for (int i = 0; i < m_filesToUpdate.size(); ++i) {
|
||||||
@ -1005,6 +830,8 @@ bool Worker::updateFiles(int percent) {
|
|||||||
emit replaceLast(QString("(") + QString("%1").arg(m_displayIndex).rightJustified(3, ' ') + QString(")")
|
emit replaceLast(QString("(") + QString("%1").arg(m_displayIndex).rightJustified(3, ' ') + QString(")")
|
||||||
+ QString(" Update opkg pakets ... "), UPDATE_STEP_FAIL);
|
+ QString(" Update opkg pakets ... "), UPDATE_STEP_FAIL);
|
||||||
|
|
||||||
|
stopProgressLoop();
|
||||||
|
setProgress(100);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1015,21 +842,24 @@ bool Worker::updateFiles(int percent) {
|
|||||||
fName.contains("DC2C_device", Qt::CaseInsensitive) ||
|
fName.contains("DC2C_device", Qt::CaseInsensitive) ||
|
||||||
fName.contains("DC2C_conf", Qt::CaseInsensitive) ||
|
fName.contains("DC2C_conf", Qt::CaseInsensitive) ||
|
||||||
fName.contains("DC2C_cash", Qt::CaseInsensitive)) {
|
fName.contains("DC2C_cash", Qt::CaseInsensitive)) {
|
||||||
m_filesToDownload << fName; // download printer-config-files
|
filesToDownload << fName; // download printer-config-files
|
||||||
} else {
|
} else {
|
||||||
static const QRegularExpression version("^.*dc2c[.][0-9]{1,2}[.][0-9]{1,2}[.]bin.*$");
|
static const QRegularExpression version("^.*dc2c[.][0-9]{1,2}[.][0-9]{1,2}[.]bin.*$");
|
||||||
if (fName.contains(version)) {
|
if (fName.contains(version)) {
|
||||||
m_filesToDownload << fName; // download device controller
|
filesToDownload << fName; // download device controller
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_filesToDownload.size() > 0) {
|
stopProgressLoop();
|
||||||
Utils::printInfoMsg(QString("FILES_TO_DOWNLOAD_TO_PSA_HW ") + m_filesToDownload.join(','));
|
setProgress(100);
|
||||||
|
|
||||||
|
if (filesToDownload.size() > 0) {
|
||||||
|
Utils::printInfoMsg(QString("FILES_TO_DOWNLOAD_TO_PSA_HW ") + filesToDownload.join(','));
|
||||||
|
|
||||||
Update *update = m_mainWindow->getUpdate();
|
Update *update = m_mainWindow->getUpdate();
|
||||||
if (update) {
|
if (update) {
|
||||||
return update->doUpdate(m_displayIndex, m_filesToDownload);
|
return update->doUpdate(m_displayIndex, filesToDownload);
|
||||||
} else {
|
} else {
|
||||||
Utils::printCriticalErrorMsg("UPDATE NOT SET");
|
Utils::printCriticalErrorMsg("UPDATE NOT SET");
|
||||||
}
|
}
|
||||||
@ -1040,9 +870,9 @@ bool Worker::updateFiles(int percent) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Worker::syncCustomerRepositoryAndFS(int progress) {
|
bool Worker::syncCustomerRepositoryAndFS() {
|
||||||
m_ismasClient.setProgressInPercent(progress);
|
|
||||||
// this step is currently needed only for updating tariff-files
|
// this step is currently needed only for updating tariff-files
|
||||||
|
setProgress(0);
|
||||||
emit appendText("\nSync customer environment with filesystem ...");
|
emit appendText("\nSync customer environment with filesystem ...");
|
||||||
if (QDir(m_customerRepository).exists()) {
|
if (QDir(m_customerRepository).exists()) {
|
||||||
if (QDir::setCurrent(m_customerRepository)) {
|
if (QDir::setCurrent(m_customerRepository)) {
|
||||||
@ -1051,6 +881,8 @@ bool Worker::syncCustomerRepositoryAndFS(int progress) {
|
|||||||
QStringList() << "-c" << "mkdir -p /etc/psa_config /etc/dc /etc/psa_tariff")) {
|
QStringList() << "-c" << "mkdir -p /etc/psa_config /etc/dc /etc/psa_tariff")) {
|
||||||
qCritical() << "COULD NOT EXECUTE '" << md.command() << "' exitCode=(" << md.exitCode() << ")";
|
qCritical() << "COULD NOT EXECUTE '" << md.command() << "' exitCode=(" << md.exitCode() << ")";
|
||||||
}
|
}
|
||||||
|
int progress = 10;
|
||||||
|
setProgress(progress);
|
||||||
QString const params("-vvv "
|
QString const params("-vvv "
|
||||||
"--recursive "
|
"--recursive "
|
||||||
"--progress "
|
"--progress "
|
||||||
@ -1073,6 +905,8 @@ bool Worker::syncCustomerRepositoryAndFS(int progress) {
|
|||||||
QString cmd;
|
QString cmd;
|
||||||
bool error = false;
|
bool error = false;
|
||||||
foreach (cmd, cmds) {
|
foreach (cmd, cmds) {
|
||||||
|
progress += 5;
|
||||||
|
setProgress(progress);
|
||||||
if (!error) {
|
if (!error) {
|
||||||
Command c("bash");
|
Command c("bash");
|
||||||
qInfo() << "EXECUTING CMD..." << cmd;
|
qInfo() << "EXECUTING CMD..." << cmd;
|
||||||
@ -1106,11 +940,14 @@ bool Worker::syncCustomerRepositoryAndFS(int progress) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
progress += 5;
|
||||||
|
setProgress(progress);
|
||||||
if (!error) {
|
if (!error) {
|
||||||
// now check tariff-files in etc and /etc/psa_tariff
|
// now check tariff-files in etc and /etc/psa_tariff
|
||||||
QDir dir1(QDir::cleanPath(m_customerRepository + QDir::separator() + "etc/psa_tariff"));
|
QDir dir1(QDir::cleanPath(m_customerRepository + QDir::separator() + "etc/psa_tariff"));
|
||||||
QDir dir2("/etc/psa_tariff");
|
QDir dir2("/etc/psa_tariff");
|
||||||
if (Utils::sameFilesInDirs(dir1, dir2)) {
|
if (Utils::sameFilesInDirs(dir1, dir2)) {
|
||||||
|
setProgress(100);
|
||||||
emit replaceLast(QString("Sync customer environment with filesystem ..."), UPDATE_STEP_DONE);
|
emit replaceLast(QString("Sync customer environment with filesystem ..."), UPDATE_STEP_DONE);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
@ -1119,12 +956,12 @@ bool Worker::syncCustomerRepositoryAndFS(int progress) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
setProgress(100);
|
||||||
emit replaceLast(QString("Sync customer environment with filesystem ..."), UPDATE_STEP_FAIL);
|
emit replaceLast(QString("Sync customer environment with filesystem ..."), UPDATE_STEP_FAIL);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Worker::sendIsmasLastVersionNotification(int progress) {
|
bool Worker::sendIsmasLastVersionNotification() {
|
||||||
m_ismasClient.setProgressInPercent(progress);
|
|
||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
QString("#M=APISM#C=CMD_SENDVERSION#J=") +
|
QString("#M=APISM#C=CMD_SENDVERSION#J=") +
|
||||||
m_ismasClient.updateOfPSASendVersion(getPSAInstalled()));
|
m_ismasClient.updateOfPSASendVersion(getPSAInstalled()));
|
||||||
@ -1132,8 +969,7 @@ bool Worker::sendIsmasLastVersionNotification(int progress) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Worker::saveLogFile(int progress) {
|
bool Worker::saveLogFile() {
|
||||||
m_ismasClient.setProgressInPercent(progress);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
QString Worker::getOsVersion() const {
|
QString Worker::getOsVersion() const {
|
||||||
@ -1312,8 +1148,8 @@ PSAInstalled Worker::getPSAInstalled() {
|
|||||||
psaInstalled.hw.cpuSerial = m_cpuSerial;
|
psaInstalled.hw.cpuSerial = m_cpuSerial;
|
||||||
|
|
||||||
psaInstalled.opkg.blob = m_gc.gitBlob(absPathNameRepositoryOpkg);
|
psaInstalled.opkg.blob = m_gc.gitBlob(absPathNameRepositoryOpkg);
|
||||||
// psaInstalled.opkg.size = getFileSize(absPathNameRepositoryOpkg);
|
psaInstalled.opkg.size = getFileSize(absPathNameRepositoryOpkg);
|
||||||
// psaInstalled.opkg.loadTime = Utils::getTariffLoadTime(absPathNameRepositoryOpkg);
|
psaInstalled.opkg.loadTime = Utils::getTariffLoadTime(absPathNameRepositoryOpkg);
|
||||||
psaInstalled.opkg.lastCommit = m_gc.gitLastCommit(absPathNameRepositoryOpkg);
|
psaInstalled.opkg.lastCommit = m_gc.gitLastCommit(absPathNameRepositoryOpkg);
|
||||||
|
|
||||||
psaInstalled.dc.versionHW = deviceControllerVersionHW;
|
psaInstalled.dc.versionHW = deviceControllerVersionHW;
|
||||||
@ -1373,7 +1209,6 @@ hwinf const *Worker::getPlugin() const {
|
|||||||
/************************************************************************************************
|
/************************************************************************************************
|
||||||
* operators
|
* operators
|
||||||
*/
|
*/
|
||||||
#if 0
|
|
||||||
QDebug operator<< (QDebug debug, UpdateStatus status) {
|
QDebug operator<< (QDebug debug, UpdateStatus status) {
|
||||||
switch(status.m_updateStatus) {
|
switch(status.m_updateStatus) {
|
||||||
case UPDATE_STATUS::ISMAS_SEND_LAST_VERSION_FAILED:
|
case UPDATE_STATUS::ISMAS_SEND_LAST_VERSION_FAILED:
|
||||||
@ -1492,10 +1327,6 @@ QDebug operator<< (QDebug debug, UpdateStatus status) {
|
|||||||
debug << QString("UPDATE_STATUS::EXEC_OPKG_COMMANDS: ")
|
debug << QString("UPDATE_STATUS::EXEC_OPKG_COMMANDS: ")
|
||||||
<< status.m_statusDescription;
|
<< status.m_statusDescription;
|
||||||
break;
|
break;
|
||||||
case UPDATE_STATUS::REMOVE_GIT_REPOSITORY_FAILED:
|
|
||||||
debug << QString("UPDATE_STATUS::REMOVE_GIT_REPOSITORY_FAILED: ")
|
|
||||||
<< status.m_statusDescription;
|
|
||||||
break;
|
|
||||||
// default:;
|
// default:;
|
||||||
}
|
}
|
||||||
return debug;
|
return debug;
|
||||||
@ -1619,12 +1450,7 @@ QString& operator<< (QString& str, UpdateStatus status) {
|
|||||||
str = QString("UPDATE_STATUS::RSYNC_FILE_SUCCESS: ");
|
str = QString("UPDATE_STATUS::RSYNC_FILE_SUCCESS: ");
|
||||||
str += status.m_statusDescription;
|
str += status.m_statusDescription;
|
||||||
break;
|
break;
|
||||||
case UPDATE_STATUS::REMOVE_GIT_REPOSITORY_FAILED:
|
|
||||||
str = QString("UPDATE_STATUS::REMOVE_GIT_REPOSITORY_FAILED: ");
|
|
||||||
str += status.m_statusDescription;
|
|
||||||
break;
|
|
||||||
//default:;
|
//default:;
|
||||||
}
|
}
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
295
worker.h
295
worker.h
@ -8,17 +8,13 @@
|
|||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include <QMap>
|
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <initializer_list>
|
|
||||||
|
|
||||||
#include "worker_thread.h"
|
#include "worker_thread.h"
|
||||||
#include "update.h"
|
#include "update.h"
|
||||||
#include "git/git_client.h"
|
#include "git/git_client.h"
|
||||||
#include "ismas/ismas_client.h"
|
#include "ismas/ismas_client.h"
|
||||||
#include "utils.h"
|
|
||||||
|
|
||||||
#ifdef PTU5
|
#ifdef PTU5
|
||||||
#define SERIAL_PORT "ttymxc2"
|
#define SERIAL_PORT "ttymxc2"
|
||||||
@ -56,8 +52,7 @@ enum class UPDATE_STATUS : quint8 {
|
|||||||
PSA_UPDATE_FILES_FAILED,
|
PSA_UPDATE_FILES_FAILED,
|
||||||
GIT_CHECK_FILES_TO_UPDATE_SUCCESS,
|
GIT_CHECK_FILES_TO_UPDATE_SUCCESS,
|
||||||
ISMAS_SEND_LAST_VERSION_FAILED,
|
ISMAS_SEND_LAST_VERSION_FAILED,
|
||||||
SAVE_LOG_FILES_FAILED,
|
SAVE_LOG_FILES_FAILED
|
||||||
REMOVE_GIT_REPOSITORY_FAILED
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct UpdateStatus {
|
struct UpdateStatus {
|
||||||
@ -69,6 +64,8 @@ struct UpdateStatus {
|
|||||||
: m_updateStatus(s), m_statusDescription(d) {}
|
: m_updateStatus(s), m_statusDescription(d) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
QDebug operator<<(QDebug debug, UpdateStatus status);
|
||||||
|
QString& operator<<(QString &str, UpdateStatus status);
|
||||||
|
|
||||||
#define ISMAS_UPDATE_REQUESTS (10)
|
#define ISMAS_UPDATE_REQUESTS (10)
|
||||||
|
|
||||||
@ -111,12 +108,12 @@ class Worker : public QObject {
|
|||||||
UpdateStatus m_updateStatus;
|
UpdateStatus m_updateStatus;
|
||||||
|
|
||||||
QStringList m_filesToUpdate;
|
QStringList m_filesToUpdate;
|
||||||
QStringList m_filesToDownload;
|
|
||||||
bool m_updateProcessRunning;
|
bool m_updateProcessRunning;
|
||||||
int m_displayIndex;
|
int m_displayIndex;
|
||||||
int m_returnCode;
|
int m_returnCode;
|
||||||
|
|
||||||
MainWindow *m_mainWindow;
|
MainWindow *m_mainWindow;
|
||||||
|
int m_progressValue;
|
||||||
bool m_withoutIsmasDirectPort;
|
bool m_withoutIsmasDirectPort;
|
||||||
QString m_apismVersion;
|
QString m_apismVersion;
|
||||||
|
|
||||||
@ -131,76 +128,6 @@ class Worker : public QObject {
|
|||||||
QStringList getDCVersion() const;
|
QStringList getDCVersion() const;
|
||||||
|
|
||||||
qint64 getFileSize(QString const &fileName) const;
|
qint64 getFileSize(QString const &fileName) const;
|
||||||
bool isRepositoryCorrupted();
|
|
||||||
bool repairCorruptedRepository();
|
|
||||||
|
|
||||||
int sendCloneAndCheckoutSuccess();
|
|
||||||
int sendCloneAndCheckoutFailure();
|
|
||||||
int sendIsmasTriggerFailure();
|
|
||||||
int sendPullFailure();
|
|
||||||
int sendFileUpdateFailure();
|
|
||||||
int sendRsyncFailure();
|
|
||||||
int sendLastVersionFailure();
|
|
||||||
int sendSaveLogFilesFailure();
|
|
||||||
int sendCustomerEnvironmentConfigurationFailed();
|
|
||||||
int sendFoundFilesToUpdateSuccess();
|
|
||||||
int sendUpdateSucceededAndActivated();
|
|
||||||
int sendFinalResult();
|
|
||||||
|
|
||||||
static constexpr const int UPDATE_SUCCESS_AND_ACTIVATED = 0;
|
|
||||||
static constexpr const int CLONE_AND_CHECKOUT_SUCCESS = 0;
|
|
||||||
static constexpr const int CLONE_AND_CHECKOUT_FAILURE = -3;
|
|
||||||
static constexpr const int ISMAS_TRIGGER_FAILURE = -5;
|
|
||||||
static constexpr const int ENVIRONMENT_CONFIG_FAILURE = -6;
|
|
||||||
static constexpr const int GIT_PULL_FAILURE = -7;
|
|
||||||
static constexpr const int UPDATE_FILES_FAILURE = -8;
|
|
||||||
static constexpr const int RSYNC_FAILURE = -9;
|
|
||||||
static constexpr const int SEND_LAST_VERSION_FAILURE = -10;
|
|
||||||
static constexpr const int SAVE_LOG_FILES_FAILURE = -11;
|
|
||||||
|
|
||||||
enum class UPDATE_STEP {
|
|
||||||
STARTED = 1,
|
|
||||||
CHECK_REPOSITORY = 2,
|
|
||||||
CHECK_SANITY = 3,
|
|
||||||
CHECK_SANITY_SUCCESS = 4,
|
|
||||||
CHECK_SANITY_FAILURE = 5,
|
|
||||||
CLONE_REPOSITORY = 6,
|
|
||||||
CLONE_REPOSITORY_SUCCESS = 7,
|
|
||||||
CLONE_REPOSITORY_FAILURE = 8,
|
|
||||||
SWITCH_BRANCH = 12,
|
|
||||||
SWITCH_BRANCH_SUCCESS = 13,
|
|
||||||
SWITCH_BRANCH_FAILURE = 14,
|
|
||||||
CHECK_ISMAS_TRIGGER = 15,
|
|
||||||
CHECK_ISMAS_TRIGGER_SUCCESS = 23,
|
|
||||||
CHECK_ISMAS_TRIGGER_FAILURE = 24,
|
|
||||||
UPDATE_REPOSITORY = 25,
|
|
||||||
UPDATE_REPOSITORY_SUCCESS = 28,
|
|
||||||
UPDATE_REPOSITORY_FAILURE = 29,
|
|
||||||
CHECK_FOR_REPOSITORY_CHANGES = 30,
|
|
||||||
CHECK_FOR_REPOSITORY_CHANGES_SUCCESS = 38,
|
|
||||||
CHECK_FOR_REPOSITORY_CHANGES_FAILURE = 39,
|
|
||||||
APPLY_REPOSITORY_CHANGES = 40,
|
|
||||||
DOWNLOAD_CONFIG_FILE = 41,
|
|
||||||
DOWNLOAD_CONFIG_FILE_SUCCESS = 63,
|
|
||||||
DOWNLOAD_CONFIG_FILE_FAILURE = 64,
|
|
||||||
DOWNLOAD_DEVICE_CONTROLLER = 65,
|
|
||||||
DOWNLOAD_DEVICE_CONTROLLER_SUCCESS = 86,
|
|
||||||
DOWNLOAD_DEVICE_CONTROLLER_FAILURE = 87,
|
|
||||||
APPLY_REPOSITORY_CHANGES_SUCCESS = 88,
|
|
||||||
APPLY_REPOSITORY_CHANGES_FAILURE = 89,
|
|
||||||
SYNC_CUSTOMER_REPOSITORY = 90,
|
|
||||||
SYNC_CUSTOMER_REPOSITORY_SUCCESS = 91,
|
|
||||||
SYNC_CUSTOMER_REPOSITORY_FAILURE = 92,
|
|
||||||
SAVE_LOGS = 94,
|
|
||||||
SAVE_LOGS_SUCCESS = 95,
|
|
||||||
SAVE_LOGS_FAILURE = 96,
|
|
||||||
SEND_LAST_VERSION = 97,
|
|
||||||
UPDATE_SUCCEEDED = 98,
|
|
||||||
UPDATE_FAILED = 99,
|
|
||||||
FINISHED = 100
|
|
||||||
};
|
|
||||||
|
|
||||||
static Worker const *instance;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static QString getATBUpdateToolYoctoVersion();
|
static QString getATBUpdateToolYoctoVersion();
|
||||||
@ -227,7 +154,6 @@ public:
|
|||||||
hwinf *getPlugin();
|
hwinf *getPlugin();
|
||||||
hwinf const *getPlugin() const;
|
hwinf const *getPlugin() const;
|
||||||
void setProgress(int progress);
|
void setProgress(int progress);
|
||||||
void displayProgressInMainWindow(int progress);
|
|
||||||
void startProgressLoop();
|
void startProgressLoop();
|
||||||
void stopProgressLoop();
|
void stopProgressLoop();
|
||||||
|
|
||||||
@ -246,6 +172,15 @@ public:
|
|||||||
MainWindow *mainWindow() { return m_mainWindow; }
|
MainWindow *mainWindow() { return m_mainWindow; }
|
||||||
MainWindow const *mainWindow() const { return m_mainWindow; }
|
MainWindow const *mainWindow() const { return m_mainWindow; }
|
||||||
|
|
||||||
|
//friend QDebug operator<<(QDebug debug, Worker const &w) {
|
||||||
|
// Q_UNUSED(w);
|
||||||
|
// return debug;
|
||||||
|
//}
|
||||||
|
//friend QString& operator<<(QString &str, Worker const &w) {
|
||||||
|
// Q_UNUSED(w);
|
||||||
|
// return str;
|
||||||
|
//}
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void appendText(QString, QString suffix = "");
|
void appendText(QString, QString suffix = "");
|
||||||
void replaceLast(QString, QString);
|
void replaceLast(QString, QString);
|
||||||
@ -263,210 +198,16 @@ public slots:
|
|||||||
private slots:
|
private slots:
|
||||||
bool updateTriggerSet(int progress);
|
bool updateTriggerSet(int progress);
|
||||||
bool customerEnvironment(int progress);
|
bool customerEnvironment(int progress);
|
||||||
bool filesToUpdate(int progress);
|
bool filesToUpdate();
|
||||||
bool updateFiles(int percent);
|
bool updateFiles(quint8 percent);
|
||||||
bool syncCustomerRepositoryAndFS(int progress);
|
bool syncCustomerRepositoryAndFS();
|
||||||
bool sendIsmasLastVersionNotification(int progress);
|
bool sendIsmasLastVersionNotification();
|
||||||
bool saveLogFile(int progress);
|
bool saveLogFile();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PSAInstalled getPSAInstalled();
|
PSAInstalled getPSAInstalled();
|
||||||
void privateUpdate();
|
void privateUpdate();
|
||||||
std::optional<QString> getApismVersion();
|
std::optional<QString> getApismVersion();
|
||||||
void printProgress(UPDATE_STEP step);
|
|
||||||
|
|
||||||
friend QDebug operator<<(QDebug debug, UPDATE_STEP step) {
|
|
||||||
if (!Worker::instance) {
|
|
||||||
return debug;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const QMap<UPDATE_STEP, const char*> smap (
|
|
||||||
std::initializer_list<std::pair<UPDATE_STEP, const char*>>{
|
|
||||||
#define INSERT_ELEMENT(p) std::pair(p, #p)
|
|
||||||
INSERT_ELEMENT(UPDATE_STEP::STARTED),
|
|
||||||
INSERT_ELEMENT(UPDATE_STEP::CHECK_REPOSITORY),
|
|
||||||
INSERT_ELEMENT(UPDATE_STEP::CHECK_SANITY),
|
|
||||||
INSERT_ELEMENT(UPDATE_STEP::CHECK_SANITY_SUCCESS),
|
|
||||||
INSERT_ELEMENT(UPDATE_STEP::CHECK_SANITY_FAILURE),
|
|
||||||
INSERT_ELEMENT(UPDATE_STEP::CLONE_REPOSITORY),
|
|
||||||
INSERT_ELEMENT(UPDATE_STEP::CLONE_REPOSITORY_SUCCESS),
|
|
||||||
INSERT_ELEMENT(UPDATE_STEP::CLONE_REPOSITORY_FAILURE),
|
|
||||||
INSERT_ELEMENT(UPDATE_STEP::SWITCH_BRANCH),
|
|
||||||
INSERT_ELEMENT(UPDATE_STEP::SWITCH_BRANCH_SUCCESS),
|
|
||||||
INSERT_ELEMENT(UPDATE_STEP::SWITCH_BRANCH_FAILURE),
|
|
||||||
INSERT_ELEMENT(UPDATE_STEP::CHECK_ISMAS_TRIGGER),
|
|
||||||
INSERT_ELEMENT(UPDATE_STEP::CHECK_ISMAS_TRIGGER_SUCCESS),
|
|
||||||
INSERT_ELEMENT(UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE),
|
|
||||||
INSERT_ELEMENT(UPDATE_STEP::UPDATE_REPOSITORY),
|
|
||||||
INSERT_ELEMENT(UPDATE_STEP::UPDATE_REPOSITORY_SUCCESS),
|
|
||||||
INSERT_ELEMENT(UPDATE_STEP::UPDATE_REPOSITORY_FAILURE),
|
|
||||||
INSERT_ELEMENT(UPDATE_STEP::CHECK_FOR_REPOSITORY_CHANGES),
|
|
||||||
INSERT_ELEMENT(UPDATE_STEP::CHECK_FOR_REPOSITORY_CHANGES_SUCCESS),
|
|
||||||
INSERT_ELEMENT(UPDATE_STEP::CHECK_FOR_REPOSITORY_CHANGES_FAILURE),
|
|
||||||
INSERT_ELEMENT(UPDATE_STEP::APPLY_REPOSITORY_CHANGES),
|
|
||||||
INSERT_ELEMENT(UPDATE_STEP::DOWNLOAD_CONFIG_FILE),
|
|
||||||
INSERT_ELEMENT(UPDATE_STEP::DOWNLOAD_CONFIG_FILE_SUCCESS),
|
|
||||||
INSERT_ELEMENT(UPDATE_STEP::DOWNLOAD_CONFIG_FILE_FAILURE),
|
|
||||||
INSERT_ELEMENT(UPDATE_STEP::DOWNLOAD_DEVICE_CONTROLLER),
|
|
||||||
INSERT_ELEMENT(UPDATE_STEP::DOWNLOAD_DEVICE_CONTROLLER_SUCCESS),
|
|
||||||
INSERT_ELEMENT(UPDATE_STEP::DOWNLOAD_DEVICE_CONTROLLER_FAILURE),
|
|
||||||
INSERT_ELEMENT(UPDATE_STEP::APPLY_REPOSITORY_CHANGES_SUCCESS),
|
|
||||||
INSERT_ELEMENT(UPDATE_STEP::APPLY_REPOSITORY_CHANGES_FAILURE),
|
|
||||||
INSERT_ELEMENT(UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY),
|
|
||||||
INSERT_ELEMENT(UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY_SUCCESS),
|
|
||||||
INSERT_ELEMENT(UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY_FAILURE),
|
|
||||||
INSERT_ELEMENT(UPDATE_STEP::SAVE_LOGS),
|
|
||||||
INSERT_ELEMENT(UPDATE_STEP::SAVE_LOGS_SUCCESS),
|
|
||||||
INSERT_ELEMENT(UPDATE_STEP::SAVE_LOGS_FAILURE),
|
|
||||||
INSERT_ELEMENT(UPDATE_STEP::SEND_LAST_VERSION),
|
|
||||||
INSERT_ELEMENT(UPDATE_STEP::UPDATE_SUCCEEDED),
|
|
||||||
INSERT_ELEMENT(UPDATE_STEP::UPDATE_FAILED),
|
|
||||||
INSERT_ELEMENT(UPDATE_STEP::FINISHED)
|
|
||||||
#undef INSERT_ELEMENT
|
|
||||||
});
|
|
||||||
|
|
||||||
switch (step) {
|
|
||||||
case UPDATE_STEP::STARTED:
|
|
||||||
break;
|
|
||||||
case UPDATE_STEP::CHECK_REPOSITORY:
|
|
||||||
break;
|
|
||||||
case UPDATE_STEP::CHECK_SANITY:
|
|
||||||
break;
|
|
||||||
case UPDATE_STEP::CHECK_SANITY_SUCCESS:
|
|
||||||
break;
|
|
||||||
case UPDATE_STEP::CHECK_SANITY_FAILURE:
|
|
||||||
break;
|
|
||||||
case UPDATE_STEP::CLONE_REPOSITORY:
|
|
||||||
break;
|
|
||||||
case UPDATE_STEP::CLONE_REPOSITORY_SUCCESS:
|
|
||||||
break;
|
|
||||||
case UPDATE_STEP::CLONE_REPOSITORY_FAILURE:
|
|
||||||
break;
|
|
||||||
case UPDATE_STEP::SWITCH_BRANCH:
|
|
||||||
break;
|
|
||||||
case UPDATE_STEP::SWITCH_BRANCH_SUCCESS:
|
|
||||||
break;
|
|
||||||
case UPDATE_STEP::SWITCH_BRANCH_FAILURE:
|
|
||||||
break;
|
|
||||||
case UPDATE_STEP::CHECK_ISMAS_TRIGGER:
|
|
||||||
break;
|
|
||||||
case UPDATE_STEP::CHECK_ISMAS_TRIGGER_SUCCESS:
|
|
||||||
break;
|
|
||||||
case UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE:
|
|
||||||
break;
|
|
||||||
case UPDATE_STEP::UPDATE_REPOSITORY:
|
|
||||||
break;
|
|
||||||
case UPDATE_STEP::UPDATE_REPOSITORY_SUCCESS:
|
|
||||||
break;
|
|
||||||
case UPDATE_STEP::UPDATE_REPOSITORY_FAILURE:
|
|
||||||
break;
|
|
||||||
case UPDATE_STEP::CHECK_FOR_REPOSITORY_CHANGES:
|
|
||||||
break;
|
|
||||||
case UPDATE_STEP::CHECK_FOR_REPOSITORY_CHANGES_SUCCESS:
|
|
||||||
break;
|
|
||||||
case UPDATE_STEP::CHECK_FOR_REPOSITORY_CHANGES_FAILURE:
|
|
||||||
break;
|
|
||||||
case UPDATE_STEP::APPLY_REPOSITORY_CHANGES:
|
|
||||||
break;
|
|
||||||
case UPDATE_STEP::DOWNLOAD_CONFIG_FILE:
|
|
||||||
break;
|
|
||||||
case UPDATE_STEP::DOWNLOAD_CONFIG_FILE_SUCCESS:
|
|
||||||
break;
|
|
||||||
case UPDATE_STEP::DOWNLOAD_CONFIG_FILE_FAILURE:
|
|
||||||
break;
|
|
||||||
case UPDATE_STEP::DOWNLOAD_DEVICE_CONTROLLER:
|
|
||||||
break;
|
|
||||||
case UPDATE_STEP::DOWNLOAD_DEVICE_CONTROLLER_SUCCESS:
|
|
||||||
break;
|
|
||||||
case UPDATE_STEP::DOWNLOAD_DEVICE_CONTROLLER_FAILURE:
|
|
||||||
break;
|
|
||||||
case UPDATE_STEP::APPLY_REPOSITORY_CHANGES_SUCCESS:
|
|
||||||
break;
|
|
||||||
case UPDATE_STEP::APPLY_REPOSITORY_CHANGES_FAILURE:
|
|
||||||
break;
|
|
||||||
case UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY:
|
|
||||||
break;
|
|
||||||
case UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY_SUCCESS:
|
|
||||||
break;
|
|
||||||
case UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY_FAILURE:
|
|
||||||
break;
|
|
||||||
case UPDATE_STEP::SAVE_LOGS:
|
|
||||||
break;
|
|
||||||
case UPDATE_STEP::SAVE_LOGS_SUCCESS:
|
|
||||||
break;
|
|
||||||
case UPDATE_STEP::SAVE_LOGS_FAILURE:
|
|
||||||
break;
|
|
||||||
case UPDATE_STEP::SEND_LAST_VERSION:
|
|
||||||
break;
|
|
||||||
case UPDATE_STEP::UPDATE_SUCCEEDED:
|
|
||||||
break;
|
|
||||||
case UPDATE_STEP::UPDATE_FAILED:
|
|
||||||
break;
|
|
||||||
case UPDATE_STEP::FINISHED:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
#if 0
|
|
||||||
case UPDATE_STEP::CHECK_SANITY:
|
|
||||||
Utils::printUpdateStatusMsg(
|
|
||||||
QStringList()
|
|
||||||
<< QString("STEP 1: CHECKED SANITY OF CUSTOMER REPOSITORY %1 DONE")
|
|
||||||
.arg(instance->m_customerRepository)
|
|
||||||
<< QString("STEP 2: FETCH CUSTOMER REPOSITORY %1...")
|
|
||||||
.arg(instance->m_customerRepository));
|
|
||||||
break;
|
|
||||||
//case UPDATE_STEP::FETCH_REPOSITORY:
|
|
||||||
// Utils::printUpdateStatusMsg(
|
|
||||||
// QStringList()
|
|
||||||
// << QString("STEP 2: FETCHED CUSTOMER REPOSITORY %1 DONE")
|
|
||||||
// .arg(instance->m_customerRepository)
|
|
||||||
// << QString("STEP 3: CHECK ISMAS-UPDATE-TRIGGER FOR WAIT-STATUS..."));
|
|
||||||
// break;
|
|
||||||
case UPDATE_STEP::CHECK_ISMAS_TRIGGER:
|
|
||||||
Utils::printUpdateStatusMsg(
|
|
||||||
QStringList()
|
|
||||||
<< QString("STEP 3: CHECKED ISMAS-UPDATE-TRIGGER FOR WAIT-STATUS. SUCCESS.")
|
|
||||||
<< QString("STEP 4: CHECK-OUT BRANCH %1...").arg(instance->m_gc.branchName()));
|
|
||||||
break;
|
|
||||||
case UPDATE_STEP::CHECKED_OUT_BRANCH:
|
|
||||||
Utils::printUpdateStatusMsg(
|
|
||||||
QStringList()
|
|
||||||
<< QString("STEP 4: CHECKED-OUT BRANCH %1 DONE")
|
|
||||||
.arg(instance->m_gc.branchName())
|
|
||||||
<< QString("STEP 5: COMPUTE FILES-TO-UPDATE..."));
|
|
||||||
break;
|
|
||||||
case UPDATE_STEP::COMPUTE_FILES_TO_UPDATE:
|
|
||||||
Utils::printUpdateStatusMsg(
|
|
||||||
QStringList()
|
|
||||||
<< QString("STEP 5: COMPUTE FILES-TO-UPDATE %1 DONE")
|
|
||||||
.arg(instance->m_filesToUpdate.join(','))
|
|
||||||
<< QString("STEP 6: DOWNLOAD FILES-TO-DOWNLOAD %1 AND EXECUTE OPKG_COMMANDS...")
|
|
||||||
.arg(instance->m_filesToDownload.join(',')));
|
|
||||||
break;
|
|
||||||
case UPDATE_STEP::DOWNLOAD_FILES_TO_UPDATE:
|
|
||||||
Utils::printUpdateStatusMsg(
|
|
||||||
QStringList()
|
|
||||||
<< QString("STEP 6: DOWNLOAD FILES-TO-DOWNLOAD %1 AND EXECUTE OPKG_COMMANDS DONE")
|
|
||||||
.arg(instance->m_filesToDownload.join(','))
|
|
||||||
<< QString("STEP 7: SYNC CUSTOMER REPOSITORY %1 WITH FILESYSTEM...")
|
|
||||||
.arg(instance->m_customerRepository));
|
|
||||||
break;
|
|
||||||
case UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY:
|
|
||||||
Utils::printUpdateStatusMsg(
|
|
||||||
QStringList()
|
|
||||||
<< QString("STEP 7: SYNC CUSTOMER REPOSITORY %1 WITH FILESYSTEM DONE")
|
|
||||||
.arg(instance->m_customerRepository)
|
|
||||||
<< QString("STEP 8: SEND-LAST-VERSION TO ISMAS..."));
|
|
||||||
break;
|
|
||||||
case UPDATE_STEP::UPDATE_SUCCESS:
|
|
||||||
Utils::printUpdateStatusMsg(
|
|
||||||
QStringList()
|
|
||||||
<< QString("STEP 9: SAVE-LOG-FILES (FUTURE USE) DONE")
|
|
||||||
<< QString("STEP 10: MARK UPDATE AS SUCCESSFUL AND ACTIVE..."));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return debug;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // WORKER_H_INCLUDED
|
#endif // WORKER_H_INCLUDED
|
||||||
|
Loading…
x
Reference in New Issue
Block a user