Compare commits
10 Commits
1d4f50fb9f
...
81c5f8ee7e
Author | SHA1 | Date | |
---|---|---|---|
81c5f8ee7e | |||
29e6a25e72 | |||
5abc057bda | |||
8aeb7ecfea | |||
4bb8e241b6 | |||
4469a23f9c | |||
d1f795e2db | |||
6865056f4b | |||
37bd5c90d3 | |||
fcba120dfa |
@ -39,6 +39,11 @@ 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,7 +68,11 @@ 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);
|
||||||
|
|
||||||
@ -79,26 +83,32 @@ 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
|
||||||
static QRegularExpression re("(^\\s*Cloning\\s+into\\s+[']\\s*)(.*)(\\s*['].*$)");
|
int customer = -1;
|
||||||
QRegularExpressionMatch match = re.match(result);
|
int cloning = result.indexOf("Cloning", 0, Qt::CaseInsensitive);
|
||||||
if (match.hasMatch()) {
|
if (cloning != -1) {
|
||||||
if (re.captureCount() == 3) { // start with full match (0), then the other 3 matches
|
customer = result.indexOf("customer_", cloning, Qt::CaseInsensitive);
|
||||||
QString const &customerNr = match.captured(2).trimmed();
|
if (customer != -1) {
|
||||||
if (customerNr == m_customerNr) {
|
QString customerNr = result.mid(customer);
|
||||||
qInfo() << "CLONING" << m_repositoryPath << "OK";
|
static constexpr char const ch = '\'';
|
||||||
return true;
|
int i = customerNr.indexOf(QChar(ch));
|
||||||
|
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. rcc=%1 CLONE_RESULT=%2")
|
QString("ERROR CLONE RESULT HAS WRONG FORMAT. CLONING=%1 CUSTOMER=%2 CLONE_RESULT=%3")
|
||||||
.arg(re.captureCount())
|
.arg(cloning)
|
||||||
|
.arg(customer)
|
||||||
.arg(result));
|
.arg(result));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -269,6 +279,17 @@ 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,6 +47,8 @@ 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,6 +56,12 @@ 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"
|
||||||
@ -64,12 +70,19 @@ 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"
|
||||||
@ -78,6 +91,7 @@ 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,
|
||||||
@ -376,16 +390,18 @@ QString IsmasClient::errorBackendNotConnected(QString const &info,
|
|||||||
version.toStdString().c_str());
|
version.toStdString().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
QString IsmasClient::errorGitClone(int percent, QString const &info, QString const &version) {
|
QString IsmasClient::errorGitClone(QString const &info,
|
||||||
|
QString const &version) {
|
||||||
return updateNewsToIsmas("U0003",
|
return updateNewsToIsmas("U0003",
|
||||||
percent,
|
m_progressInPercent,
|
||||||
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 const &version) {
|
QString IsmasClient::backendConnected(QString const &info,
|
||||||
|
QString const &version) {
|
||||||
return updateNewsToIsmas("U0010",
|
return updateNewsToIsmas("U0010",
|
||||||
m_progressInPercent,
|
m_progressInPercent,
|
||||||
RESULT_CODE::SUCCESS,
|
RESULT_CODE::SUCCESS,
|
||||||
@ -394,7 +410,8 @@ QString IsmasClient::backendConnected(QString const &info, QString const &versio
|
|||||||
version.toStdString().c_str());
|
version.toStdString().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
QString IsmasClient::execOpkgCommand(QString const &info, QString const &version) {
|
QString IsmasClient::execOpkgCommand(QString const &info,
|
||||||
|
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(int percent, QString const &info, QString const &version = QString());
|
QString errorGitClone(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, m_progressValue));
|
QApplication::postEvent(this, new ProgressEvent(this, 1));
|
||||||
} 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/10);
|
ui->updateProgress->setValue(progress);
|
||||||
QApplication::postEvent(this, new ProgressEvent(this, progress+10));
|
// ueberpruefen: hauptfenster schickt sich selber ein event
|
||||||
QThread::msleep(500);
|
// QApplication::postEvent(this, new ProgressEvent(this, progress));
|
||||||
}
|
// 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,6 +68,12 @@ 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,6 +17,7 @@ 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,8 +17,6 @@
|
|||||||
#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"
|
||||||
@ -31,6 +29,8 @@ 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,10 +73,12 @@ 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);
|
||||||
|
|
||||||
@ -127,19 +129,25 @@ Worker::~Worker() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Worker::setProgress(int progress) {
|
void Worker::displayProgressInMainWindow(int progress) {
|
||||||
if (m_mainWindow) {
|
if (m_mainWindow) {
|
||||||
m_progressValue = progress;
|
QApplication::postEvent(m_mainWindow,
|
||||||
QApplication::postEvent(m_mainWindow, new ProgressEvent(this, progress));
|
new ProgressEvent(this, progress));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Worker::setProgress(int progress) {
|
||||||
|
m_ismasClient.setProgressInPercent(progress);
|
||||||
|
displayProgressInMainWindow(progress);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Worker::startProgressLoop() {
|
void Worker::startProgressLoop() {
|
||||||
QApplication::postEvent(m_mainWindow, new ProgressEvent(this, MainWindow::START_PROGRESS_LOOP));
|
displayProgressInMainWindow(MainWindow::START_PROGRESS_LOOP);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Worker::stopProgressLoop() {
|
void Worker::stopProgressLoop() {
|
||||||
QApplication::postEvent(m_mainWindow, new ProgressEvent(this, MainWindow::STOP_PROGRESS_LOOP));
|
displayProgressInMainWindow(MainWindow::STOP_PROGRESS_LOOP);
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::once_flag once;
|
static std::once_flag once;
|
||||||
@ -148,6 +156,244 @@ 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");
|
||||||
@ -160,183 +406,134 @@ void Worker::privateUpdate() {
|
|||||||
emit disableExit();
|
emit disableExit();
|
||||||
|
|
||||||
m_returnCode = -1;
|
m_returnCode = -1;
|
||||||
|
|
||||||
QDir customerRepository(m_customerRepository);
|
QDir customerRepository(m_customerRepository);
|
||||||
if (!customerRepository.exists()) {
|
QDir customerRepositoryEtc(QDir::cleanPath(m_customerRepository + QDir::separator() + "etc/"));
|
||||||
emit appendText("\nInitializing customer environment ...");
|
|
||||||
startProgressLoop();
|
|
||||||
if (m_gc.gitCloneAndCheckoutBranch()) {
|
|
||||||
stopProgressLoop();
|
|
||||||
emit replaceLast("Initializing customer environment", UPDATE_STEP_DONE);
|
|
||||||
|
|
||||||
setProgress(5);
|
Utils::printUpdateStatusMsg(
|
||||||
|
QStringList()
|
||||||
|
<< QString("STEP 1: CHECK SANITY OF CUSTOMER REPOSITORY %1...")
|
||||||
|
.arg(m_customerRepository));
|
||||||
|
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_CLONE_AND_CHECKOUT_SUCCESS,
|
bool initialClone = false; // the customer repository is cloned without
|
||||||
QString("CLONED AND CHECKED OUT: ") + m_customerRepository);
|
// checking the ISMAS-trigger (WAIT-)button.
|
||||||
|
// but if there was a sane repository
|
||||||
|
// available, then the trigger-button must
|
||||||
|
// have been activated in ISMAS.
|
||||||
|
|
||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
bool continueUpdate = true; // check if git-clone command has timed-out,
|
||||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
// resulting in a corrupted git-repository, which
|
||||||
m_ismasClient.cloneAndCheckoutCustomerRepository(
|
// does not contain an ./etc-directory
|
||||||
m_updateStatus.m_statusDescription));
|
if (isRepositoryCorrupted()) {
|
||||||
|
QString s("CORRUPTED CUSTOMER REPOSITORY. REPAIRING...");
|
||||||
setProgress(10);
|
if ((continueUpdate = repairCorruptedRepository()) == true) {
|
||||||
|
Utils::printUpdateStatusMsg(
|
||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
QStringList() << s <<
|
||||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
QString("CORRUPTED CUSTOMER REPOSITORY. REPAIRING...DONE"));
|
||||||
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 {
|
||||||
stopProgressLoop();
|
Utils::printUpdateStatusMsg(
|
||||||
setProgress(0);
|
QStringList() << s <<
|
||||||
|
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_ismasClient.setProgressInPercent(100);
|
if (continueUpdate) {
|
||||||
setProgress(100);
|
// qDebug() << UPDATE_STEP::SANITY_CHECK;
|
||||||
|
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 (m_returnCode != 0) {
|
if (!initialClone) {
|
||||||
stopProgressLoop();
|
// qDebug() << UPDATE_STEP::FETCH_REPOSITORY;
|
||||||
emit appendText(QString("UPDATE "), UPDATE_STEP_FAIL);
|
} else {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
// m_updateStatus = UpdateStatus(UPDATE_STATUS::UPDATE_PROCESS_FAILURE,
|
setProgress(100);
|
||||||
// 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());
|
|
||||||
// }
|
|
||||||
|
|
||||||
} else {
|
if (m_returnCode != 0) {
|
||||||
emit appendText(QString("UPDATE "), UPDATE_STEP_SUCCESS);
|
stopProgressLoop();
|
||||||
|
emit appendText(QString("UPDATE "), UPDATE_STEP_FAIL);
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::UPDATE_PROCESS_SUCCESS,
|
} else {
|
||||||
QString("Update process succeeded. Reset WAIT."));
|
emit appendText(QString("UPDATE "), UPDATE_STEP_SUCCESS);
|
||||||
if (std::optional<QString> s = m_ismasClient.finalResult(IsmasClient::RESULT_CODE::SUCCESS,
|
sendFinalResult();
|
||||||
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();
|
sendIsmasLastVersionNotification(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_updateProcessRunning = false;
|
m_updateProcessRunning = false;
|
||||||
@ -440,7 +637,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();
|
||||||
|
|
||||||
@ -451,7 +648,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)
|
||||||
@ -468,7 +665,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,
|
||||||
@ -479,13 +676,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=<"
|
||||||
@ -506,7 +703,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));
|
||||||
@ -519,7 +716,6 @@ 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));
|
||||||
@ -535,7 +731,6 @@ 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,
|
||||||
@ -547,7 +742,6 @@ 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,
|
||||||
@ -559,7 +753,6 @@ 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,
|
||||||
@ -570,7 +763,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");
|
||||||
@ -584,7 +777,6 @@ 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));
|
||||||
@ -610,13 +802,12 @@ 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,
|
||||||
@ -628,7 +819,6 @@ 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,
|
||||||
@ -640,7 +830,6 @@ 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,
|
||||||
@ -652,7 +841,6 @@ 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,
|
||||||
@ -665,13 +853,12 @@ 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 + ")");
|
||||||
@ -687,7 +874,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);
|
||||||
@ -699,7 +886,6 @@ 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;
|
||||||
@ -716,12 +902,13 @@ 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() {
|
bool Worker::filesToUpdate(int progress) {
|
||||||
|
m_ismasClient.setProgressInPercent(progress);
|
||||||
|
|
||||||
emit appendText("\nFetch changes files ...");
|
emit appendText("\nFetch changes files ...");
|
||||||
startProgressLoop();
|
startProgressLoop();
|
||||||
|
|
||||||
@ -729,17 +916,11 @@ bool Worker::filesToUpdate() {
|
|||||||
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();
|
||||||
@ -748,10 +929,6 @@ bool Worker::filesToUpdate() {
|
|||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -769,15 +946,13 @@ bool Worker::filesToUpdate() {
|
|||||||
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(quint8 percent) {
|
bool Worker::updateFiles(int percent) {
|
||||||
QStringList filesToDownload;
|
m_filesToDownload.clear();
|
||||||
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) {
|
||||||
@ -830,8 +1005,6 @@ bool Worker::updateFiles(quint8 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -842,24 +1015,21 @@ bool Worker::updateFiles(quint8 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)) {
|
||||||
filesToDownload << fName; // download printer-config-files
|
m_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)) {
|
||||||
filesToDownload << fName; // download device controller
|
m_filesToDownload << fName; // download device controller
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stopProgressLoop();
|
if (m_filesToDownload.size() > 0) {
|
||||||
setProgress(100);
|
Utils::printInfoMsg(QString("FILES_TO_DOWNLOAD_TO_PSA_HW ") + m_filesToDownload.join(','));
|
||||||
|
|
||||||
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, filesToDownload);
|
return update->doUpdate(m_displayIndex, m_filesToDownload);
|
||||||
} else {
|
} else {
|
||||||
Utils::printCriticalErrorMsg("UPDATE NOT SET");
|
Utils::printCriticalErrorMsg("UPDATE NOT SET");
|
||||||
}
|
}
|
||||||
@ -870,9 +1040,9 @@ bool Worker::updateFiles(quint8 percent) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Worker::syncCustomerRepositoryAndFS() {
|
bool Worker::syncCustomerRepositoryAndFS(int progress) {
|
||||||
|
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)) {
|
||||||
@ -881,8 +1051,6 @@ bool Worker::syncCustomerRepositoryAndFS() {
|
|||||||
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 "
|
||||||
@ -905,8 +1073,6 @@ bool Worker::syncCustomerRepositoryAndFS() {
|
|||||||
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;
|
||||||
@ -940,14 +1106,11 @@ bool Worker::syncCustomerRepositoryAndFS() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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 {
|
||||||
@ -956,12 +1119,12 @@ bool Worker::syncCustomerRepositoryAndFS() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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() {
|
bool Worker::sendIsmasLastVersionNotification(int progress) {
|
||||||
|
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()));
|
||||||
@ -969,7 +1132,8 @@ bool Worker::sendIsmasLastVersionNotification() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Worker::saveLogFile() {
|
bool Worker::saveLogFile(int progress) {
|
||||||
|
m_ismasClient.setProgressInPercent(progress);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
QString Worker::getOsVersion() const {
|
QString Worker::getOsVersion() const {
|
||||||
@ -1148,8 +1312,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;
|
||||||
@ -1209,6 +1373,7 @@ 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:
|
||||||
@ -1327,6 +1492,10 @@ 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;
|
||||||
@ -1450,7 +1619,12 @@ 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,13 +8,17 @@
|
|||||||
#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"
|
||||||
@ -52,7 +56,8 @@ 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 {
|
||||||
@ -64,8 +69,6 @@ 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)
|
||||||
|
|
||||||
@ -108,12 +111,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;
|
||||||
|
|
||||||
@ -128,6 +131,76 @@ 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();
|
||||||
@ -154,6 +227,7 @@ 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();
|
||||||
|
|
||||||
@ -172,15 +246,6 @@ 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);
|
||||||
@ -198,16 +263,210 @@ public slots:
|
|||||||
private slots:
|
private slots:
|
||||||
bool updateTriggerSet(int progress);
|
bool updateTriggerSet(int progress);
|
||||||
bool customerEnvironment(int progress);
|
bool customerEnvironment(int progress);
|
||||||
bool filesToUpdate();
|
bool filesToUpdate(int progress);
|
||||||
bool updateFiles(quint8 percent);
|
bool updateFiles(int percent);
|
||||||
bool syncCustomerRepositoryAndFS();
|
bool syncCustomerRepositoryAndFS(int progress);
|
||||||
bool sendIsmasLastVersionNotification();
|
bool sendIsmasLastVersionNotification(int progress);
|
||||||
bool saveLogFile();
|
bool saveLogFile(int progress);
|
||||||
|
|
||||||
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