2023-06-16 16:47:13 +02:00
|
|
|
#include "worker.h"
|
|
|
|
#include "update.h"
|
|
|
|
|
|
|
|
#include <QCoreApplication>
|
|
|
|
#include <QApplication>
|
|
|
|
#include <QDebug>
|
|
|
|
#include <QTimer>
|
|
|
|
#include <QFileInfo>
|
|
|
|
#include <QDir>
|
2023-07-14 13:32:00 +02:00
|
|
|
#include <QDirIterator>
|
2023-06-16 16:47:13 +02:00
|
|
|
#include <QThread>
|
2023-07-14 13:32:00 +02:00
|
|
|
#include <QRegularExpression>
|
|
|
|
#include <QDateTime>
|
|
|
|
#include <QString>
|
2023-08-02 15:50:04 +02:00
|
|
|
#include <QMessageBox>
|
|
|
|
#include <QPushButton>
|
|
|
|
#include <QJsonParseError>
|
2023-08-23 16:26:55 +02:00
|
|
|
#include <Qt>
|
2023-08-02 15:50:04 +02:00
|
|
|
|
|
|
|
#include <thread>
|
2023-06-16 16:47:13 +02:00
|
|
|
|
|
|
|
#include "message_handler.h"
|
|
|
|
#include "plugins/interfaces.h"
|
2023-07-11 16:58:49 +02:00
|
|
|
#include "ismas/ismas_client.h"
|
2023-08-05 18:50:50 +02:00
|
|
|
#include "progress_event.h"
|
|
|
|
#include "mainwindow.h"
|
2023-08-11 10:52:31 +02:00
|
|
|
#include "utils.h"
|
2023-08-02 15:50:04 +02:00
|
|
|
|
|
|
|
QString const Worker::UPDATE_STEP_OK(" [ ok]");
|
|
|
|
QString const Worker::UPDATE_STEP_DONE(" [done]");
|
2023-08-06 14:14:47 +02:00
|
|
|
QString const Worker::UPDATE_STEP_FAIL(" [FAIL]");
|
2023-08-02 15:50:04 +02:00
|
|
|
QString const Worker::UPDATE_STEP_SUCCESS(" [SUCCESS]");
|
2023-07-17 16:43:05 +02:00
|
|
|
|
|
|
|
Worker::Worker(hwinf *hw,
|
|
|
|
int customerNr,
|
|
|
|
int machineNr,
|
|
|
|
int zoneNr,
|
|
|
|
QString branchName,
|
|
|
|
QString workingDirectory,
|
|
|
|
bool dryRun,
|
|
|
|
QObject *parent,
|
|
|
|
char const *serialInterface,
|
|
|
|
char const *baudrate)
|
2023-07-19 16:42:18 +02:00
|
|
|
: m_hw(hw)
|
|
|
|
, m_workerThread("workerThread")
|
2023-07-17 16:43:05 +02:00
|
|
|
, m_customerNr(customerNr)
|
|
|
|
, m_customerNrStr(QString("customer_") + QString::number(m_customerNr).rightJustified(3, '0'))
|
|
|
|
, m_machineNr(machineNr)
|
|
|
|
, m_zoneNr(zoneNr)
|
2023-07-14 13:32:00 +02:00
|
|
|
, m_workingDirectory(workingDirectory)
|
|
|
|
, m_branchName(branchName)
|
2023-07-19 16:42:18 +02:00
|
|
|
, m_customerRepositoryPath(QString("https://git.mimbach49.de/GerhardHoffmann/%1.git").arg(m_customerNrStr))
|
2023-07-17 16:43:05 +02:00
|
|
|
, m_customerRepository(QDir::cleanPath(m_workingDirectory + QDir::separator() + m_customerNrStr))
|
2023-08-02 15:50:04 +02:00
|
|
|
, m_update(new Update(m_hw, this, m_customerRepository, m_customerNrStr, m_branchName,
|
|
|
|
m_workingDirectory, dryRun, parent, serialInterface, baudrate))
|
2023-07-17 16:43:05 +02:00
|
|
|
, m_gc(m_customerNrStr, m_customerRepository, m_workingDirectory, m_branchName, this)
|
|
|
|
, m_osVersion(getOsVersion())
|
2023-07-19 16:42:18 +02:00
|
|
|
, m_atbqtVersion(getATBQTVersion())
|
|
|
|
, m_cpuSerial(getCPUSerial())
|
|
|
|
, m_raucVersion(getRaucVersion())
|
|
|
|
, m_opkgVersion(getOpkgVersion())
|
|
|
|
, m_pluginVersionATBDeciceController(getPluginVersion("/opt/app/ATBAPP/plugins/libATBDeviceControllerPlugin.so"))
|
|
|
|
, m_pluginVersionIngenicoISelf(getPluginVersion("/opt/app/ATBAPP/plugins/libIngenicoISelf_CCPlugin.so"))
|
|
|
|
, m_pluginVersionMobilisisCalc(getPluginVersion("/opt/app/ATBAPP/plugins/libMOBILISIS_CalculatePricePlugin.so"))
|
|
|
|
, m_pluginVersionMobilisisCalcConfig(getPluginVersion("/opt/app/ATBAPP/plugins/libMOBILISIS_CalculatePricePlugin_ConfigUi.so"))
|
|
|
|
, m_pluginVersionPrmCalc(getPluginVersion("/opt/app/ATBAPP/plugins/libPRM_CalculatePricePlugin.so"))
|
|
|
|
, m_pluginVersionPrmCalcConfig(getPluginVersion("/opt/app/ATBAPP/plugins/libPRM_CalculatePricePlugin_ConfigUi.so"))
|
|
|
|
, m_pluginVersionTcpZvt(getPluginVersion("/opt/app/ATBAPP/plugins/libTCP_ZVT_CCPlugin.so"))
|
2023-07-14 13:32:00 +02:00
|
|
|
, m_ismasUpdateRequests(ISMAS_UPDATE_REQUESTS)
|
2023-08-02 15:50:04 +02:00
|
|
|
, m_waitForNewUpdates(this)
|
|
|
|
, m_filesToUpdate()
|
2023-08-11 10:55:53 +02:00
|
|
|
, m_updateProcessRunning(true)
|
2023-08-06 20:44:26 +02:00
|
|
|
, m_returnCode(0)
|
2023-08-09 16:14:59 +02:00
|
|
|
, m_progressValue(0)
|
|
|
|
, m_withoutIsmasDirectPort(false) /* useful for testing */ {
|
2023-07-11 16:58:49 +02:00
|
|
|
|
2023-07-17 16:43:05 +02:00
|
|
|
QDir::setCurrent(m_workingDirectory);
|
|
|
|
|
|
|
|
qInfo() << "CURRENT TIME ..............." << QDateTime::currentDateTime().toString(Qt::ISODate);
|
|
|
|
qInfo() << "OS VERSION ................." << m_osVersion;
|
2023-07-19 16:42:18 +02:00
|
|
|
qInfo() << "ATBQT VERSION .............." << m_atbqtVersion;
|
|
|
|
qInfo() << "CPU SERIAL ................." << m_cpuSerial;
|
2023-07-17 16:43:05 +02:00
|
|
|
qInfo() << "CUSTOMER_NR ................" << m_customerNr;
|
|
|
|
qInfo() << "CUSTOMER_NR_STR ............" << m_customerNrStr;
|
2023-07-19 16:42:18 +02:00
|
|
|
qInfo() << "CUSTOMER_REPOSITORY_PATH ..." << m_customerRepositoryPath;
|
2023-07-17 16:43:05 +02:00
|
|
|
qInfo() << "CUSTOMER_REPOSITORY ........" << m_customerRepository;
|
|
|
|
qInfo() << "MACHINE_NR ................." << m_machineNr;
|
|
|
|
qInfo() << "ZONE_NR ...................." << m_zoneNr;
|
|
|
|
qInfo() << "BRANCH_NAME ................" << m_branchName;
|
|
|
|
qInfo() << "WORKING_DIRECTORY .........." << m_workingDirectory;
|
|
|
|
|
|
|
|
this->moveToThread(&m_workerThread);
|
2023-06-16 16:47:13 +02:00
|
|
|
m_workerThread.start();
|
|
|
|
|
|
|
|
int cnt = 0;
|
|
|
|
while (!m_workerThread.isRunning()) {
|
|
|
|
if (++cnt > 5) {
|
2023-08-11 10:52:31 +02:00
|
|
|
Utils::printCriticalErrorMsg("starting worker thread FAILED");
|
2023-06-16 16:47:13 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
QThread::sleep(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Worker::~Worker() {
|
|
|
|
int cnt = 0;
|
|
|
|
m_workerThread.quit();
|
|
|
|
while (!m_workerThread.isFinished()) {
|
|
|
|
if (!m_workerThread.wait(1000)) {
|
|
|
|
if (++cnt > 5) {
|
2023-08-11 10:52:31 +02:00
|
|
|
Utils::printCriticalErrorMsg("stopping worker thread FAILED");
|
2023-06-16 16:47:13 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-07-11 16:58:49 +02:00
|
|
|
if (m_update) {
|
|
|
|
delete m_update;
|
|
|
|
}
|
2023-06-16 16:47:13 +02:00
|
|
|
}
|
|
|
|
|
2023-08-05 18:50:50 +02:00
|
|
|
void Worker::setProgress(int progress) {
|
|
|
|
if (m_mainWindow) {
|
2023-08-06 20:44:26 +02:00
|
|
|
m_progressValue = progress;
|
|
|
|
QApplication::postEvent(m_mainWindow, new ProgressEvent(this, progress));
|
2023-08-05 18:50:50 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-06 20:44:26 +02:00
|
|
|
void Worker::startProgressLoop() {
|
|
|
|
QApplication::postEvent(m_mainWindow, new ProgressEvent(this, MainWindow::START_PROGRESS_LOOP));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Worker::stopProgressLoop() {
|
|
|
|
QApplication::postEvent(m_mainWindow, new ProgressEvent(this, MainWindow::STOP_PROGRESS_LOOP));
|
|
|
|
}
|
|
|
|
|
2023-08-02 15:50:04 +02:00
|
|
|
static std::once_flag once;
|
|
|
|
void Worker::update() {
|
2023-08-05 18:50:50 +02:00
|
|
|
// user should not start the update process several times
|
2023-08-02 15:50:04 +02:00
|
|
|
std::call_once(once, &Worker::privateUpdate, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Worker::privateUpdate() {
|
|
|
|
m_updateProcessRunning = true;
|
|
|
|
|
|
|
|
bool sentIsmasLastVersionNotification = false;
|
|
|
|
|
2023-08-09 16:14:59 +02:00
|
|
|
//emit appendText("\nRestart APISM ...");
|
|
|
|
//startProgressLoop();
|
|
|
|
//Command c("systemctl restart apism");
|
|
|
|
//if (c.execute("/tmp")) {
|
|
|
|
// QThread::sleep(10); // give APISM some time to reconnect
|
|
|
|
// stopProgressLoop();
|
|
|
|
// emit replaceLast("Restart APISM ...", UPDATE_STEP_DONE);
|
|
|
|
//} else {
|
|
|
|
// stopProgressLoop();
|
|
|
|
// emit replaceLast("Restart APISM ...", UPDATE_STEP_FAIL);
|
|
|
|
//}
|
|
|
|
|
|
|
|
emit disableExit();
|
|
|
|
|
2023-08-03 09:06:50 +02:00
|
|
|
m_returnCode = -1;
|
2023-08-02 15:50:04 +02:00
|
|
|
QDir customerRepository(m_customerRepository);
|
|
|
|
if (!customerRepository.exists()) {
|
2023-08-07 13:56:51 +02:00
|
|
|
emit appendText("\nInitializing customer environment ...");
|
|
|
|
startProgressLoop();
|
2023-08-02 15:50:04 +02:00
|
|
|
if (m_gc.gitCloneAndCheckoutBranch()) {
|
2023-08-07 13:56:51 +02:00
|
|
|
stopProgressLoop();
|
|
|
|
emit replaceLast("Initializing customer environment", UPDATE_STEP_DONE);
|
|
|
|
|
|
|
|
int progress = (m_mainWindow->progressValue()/10) + 10;
|
|
|
|
setProgress(progress);
|
2023-08-04 13:48:40 +02:00
|
|
|
|
2023-08-16 12:41:42 +02:00
|
|
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_CLONE_AND_CHECKOUT_SUCCESS,
|
2023-08-02 15:50:04 +02:00
|
|
|
QString("CLONED AND CHECKED OUT: ") + m_customerRepository);
|
|
|
|
|
|
|
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
|
|
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
|
|
|
m_ismasClient.cloneAndCheckoutCustomerRepository(
|
|
|
|
m_updateStatus.m_statusDescription));
|
|
|
|
|
2023-08-07 13:56:51 +02:00
|
|
|
setProgress(progress + 10);
|
|
|
|
|
2023-08-02 15:50:04 +02:00
|
|
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
|
|
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
|
|
|
m_ismasClient.updateOfPSASucceeded(""));
|
|
|
|
|
2023-08-05 18:50:50 +02:00
|
|
|
setProgress(100);
|
2023-08-04 13:48:40 +02:00
|
|
|
m_ismasClient.setProgressInPercent(100);
|
2023-08-02 16:53:19 +02:00
|
|
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
|
|
|
QString("#M=APISM#C=CMD_EVENT#J=") + m_ismasClient.updateOfPSAActivated());
|
2023-08-04 13:48:40 +02:00
|
|
|
|
2023-08-03 09:06:50 +02:00
|
|
|
m_returnCode = 0;
|
2023-08-07 13:56:51 +02:00
|
|
|
} else {
|
|
|
|
stopProgressLoop();
|
|
|
|
|
|
|
|
int progress = (m_mainWindow->progressValue()/10) + 10;
|
|
|
|
setProgress(progress);
|
|
|
|
|
|
|
|
emit replaceLast("Initializing customer environment", UPDATE_STEP_FAIL);
|
|
|
|
|
2023-08-16 12:41:42 +02:00
|
|
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_CLONE_AND_CHECKOUT_FAILURE,
|
2023-08-07 13:56:51 +02:00
|
|
|
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;
|
2023-08-02 15:50:04 +02:00
|
|
|
}
|
|
|
|
} else {
|
2023-08-11 10:55:53 +02:00
|
|
|
m_ismasClient.setProgressInPercent(10);
|
|
|
|
if (backendConnected()) {
|
|
|
|
m_ismasClient.setProgressInPercent(20);
|
|
|
|
if (updateTriggerSet()) {
|
|
|
|
m_ismasClient.setProgressInPercent(30);
|
|
|
|
if (customerEnvironment()) {
|
|
|
|
m_ismasClient.setProgressInPercent(40);
|
|
|
|
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));
|
|
|
|
m_ismasClient.setProgressInPercent(50);
|
|
|
|
if (updateFiles(50)) {
|
|
|
|
m_ismasClient.setProgressInPercent(60);
|
|
|
|
if (syncCustomerRepositoryAndFS()) {
|
|
|
|
m_ismasClient.setProgressInPercent(70);
|
|
|
|
if (sendIsmasLastVersionNotification()) {
|
|
|
|
m_ismasClient.setProgressInPercent(80);
|
|
|
|
sentIsmasLastVersionNotification = true;
|
|
|
|
if (saveLogFile()) {
|
|
|
|
m_ismasClient.setProgressInPercent(90);
|
|
|
|
|
|
|
|
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
|
|
|
|
m_ismasClient.setProgressInPercent(95);
|
|
|
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
|
|
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
|
|
|
m_ismasClient.updateOfPSAActivated());
|
|
|
|
|
|
|
|
m_returnCode = 0;
|
2023-08-03 09:06:50 +02:00
|
|
|
} else {
|
2023-08-11 10:55:53 +02:00
|
|
|
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));
|
2023-08-07 13:56:51 +02:00
|
|
|
m_returnCode = -11;
|
2023-08-02 15:50:04 +02:00
|
|
|
}
|
2023-08-03 09:06:50 +02:00
|
|
|
} else {
|
2023-08-11 10:55:53 +02:00
|
|
|
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));
|
2023-08-07 13:56:51 +02:00
|
|
|
m_returnCode = -10;
|
2023-08-02 15:50:04 +02:00
|
|
|
}
|
2023-08-03 09:06:50 +02:00
|
|
|
} else {
|
2023-08-11 10:55:53 +02:00
|
|
|
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));
|
2023-08-07 13:56:51 +02:00
|
|
|
m_returnCode = -9;
|
2023-08-02 15:50:04 +02:00
|
|
|
}
|
2023-08-03 09:06:50 +02:00
|
|
|
} else {
|
2023-08-11 10:55:53 +02:00
|
|
|
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));
|
2023-08-07 13:56:51 +02:00
|
|
|
m_returnCode = -8;
|
2023-08-02 15:50:04 +02:00
|
|
|
}
|
2023-08-03 09:06:50 +02:00
|
|
|
} else {
|
2023-08-11 10:55:53 +02:00
|
|
|
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));
|
2023-08-07 13:56:51 +02:00
|
|
|
m_returnCode = -7;
|
2023-08-02 15:50:04 +02:00
|
|
|
}
|
2023-08-03 09:06:50 +02:00
|
|
|
} else {
|
2023-08-16 12:41:42 +02:00
|
|
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_CHECKOUT_BRANCH_FAILURE,
|
2023-08-11 10:55:53 +02:00
|
|
|
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));
|
2023-08-07 13:56:51 +02:00
|
|
|
m_returnCode = -6;
|
2023-08-02 15:50:04 +02:00
|
|
|
}
|
2023-08-03 09:06:50 +02:00
|
|
|
} else {
|
2023-08-11 10:55:53 +02:00
|
|
|
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));
|
2023-08-07 13:56:51 +02:00
|
|
|
m_returnCode = -5;
|
2023-08-02 15:50:04 +02:00
|
|
|
}
|
2023-08-03 09:06:50 +02:00
|
|
|
} else {
|
2023-08-16 12:41:42 +02:00
|
|
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::BACKEND_CHECK_FAILURE,
|
2023-08-11 10:55:53 +02:00
|
|
|
QString("ISMAS backend not available"));
|
|
|
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
|
|
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
|
|
|
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
|
|
|
"ISMAS-BACKEND-CHECK",
|
|
|
|
m_updateStatus.m_statusDescription));
|
2023-08-07 13:56:51 +02:00
|
|
|
m_returnCode = -4;
|
2023-08-02 15:50:04 +02:00
|
|
|
}
|
|
|
|
}
|
2023-08-03 09:06:50 +02:00
|
|
|
|
2023-08-04 13:48:40 +02:00
|
|
|
m_ismasClient.setProgressInPercent(100);
|
2023-08-11 12:20:09 +02:00
|
|
|
setProgress(100);
|
2023-08-02 15:50:04 +02:00
|
|
|
|
2023-08-04 13:48:40 +02:00
|
|
|
if (m_returnCode != 0) {
|
2023-08-07 13:56:51 +02:00
|
|
|
stopProgressLoop();
|
|
|
|
emit appendText(QString("UPDATE "), UPDATE_STEP_FAIL);
|
2023-08-11 12:20:09 +02:00
|
|
|
|
|
|
|
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,
|
|
|
|
"FINAL-UPDATE-RESULT",
|
|
|
|
m_updateStatus.m_statusDescription)) {
|
|
|
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
|
|
|
QString("#M=APISM#C=CMD_EVENT#J=") + s.value());
|
|
|
|
}
|
2023-08-07 13:56:51 +02:00
|
|
|
} else {
|
|
|
|
emit appendText(QString("UPDATE "), UPDATE_STEP_SUCCESS);
|
2023-08-11 12:20:09 +02:00
|
|
|
|
|
|
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::UPDATE_PROCESS_SUCCESS,
|
|
|
|
QString("Update process succeeded"));
|
|
|
|
if (std::optional<QString> s = m_ismasClient.finalResult(IsmasClient::RESULT_CODE::SUCCESS,
|
|
|
|
"FINAL-UPDATE-RESULT",
|
|
|
|
m_updateStatus.m_statusDescription)) {
|
|
|
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
|
|
|
QString("#M=APISM#C=CMD_EVENT#J=") + s.value());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!sentIsmasLastVersionNotification) {
|
|
|
|
// try even if the backend is not connected
|
|
|
|
sendIsmasLastVersionNotification();
|
2023-08-04 13:48:40 +02:00
|
|
|
}
|
|
|
|
|
2023-08-02 15:50:04 +02:00
|
|
|
m_updateProcessRunning = false;
|
2023-08-02 17:51:35 +02:00
|
|
|
emit enableExit();
|
2023-08-02 15:50:04 +02:00
|
|
|
emit restartExitTimer();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Worker::backendConnected() {
|
2023-08-11 10:55:53 +02:00
|
|
|
// deactivated: REQ_SELF does not really help. Observation was that even
|
|
|
|
// id ISMAS is reported as 'true', a following check of the update-trigger
|
|
|
|
// button has no access to ISMAS.
|
|
|
|
return true;
|
2023-08-07 13:56:51 +02:00
|
|
|
|
2023-08-09 16:17:28 +02:00
|
|
|
emit appendText("\nConnecting backend ...");
|
|
|
|
|
2023-08-11 10:55:53 +02:00
|
|
|
if (false) { // so linker removes dead code
|
2023-08-16 12:41:42 +02:00
|
|
|
for (int repeat = 0; repeat < 100; ++repeat) {
|
2023-08-11 10:55:53 +02:00
|
|
|
qInfo() << "REPEAT" << repeat << "In backendConnected() -> #M=APISM#C=REQ_SELF#J={}";
|
|
|
|
startProgressLoop();
|
|
|
|
std::optional<QString> result
|
|
|
|
= IsmasClient::sendRequestReceiveResponse(
|
|
|
|
IsmasClient::APISM::DIRECT_PORT, "#M=APISM#C=REQ_SELF#J={}");
|
|
|
|
if (result) {
|
|
|
|
stopProgressLoop();
|
|
|
|
int progress = (m_mainWindow->progressValue()/10) + 10;
|
|
|
|
setProgress(progress);
|
|
|
|
|
|
|
|
QString msg = result.value();
|
|
|
|
qInfo() << "In backendConnected() -> APISM response" << msg;
|
|
|
|
QJsonParseError parseError;
|
|
|
|
QJsonDocument document(QJsonDocument::fromJson(msg.toUtf8(), &parseError));
|
|
|
|
if (parseError.error != QJsonParseError::NoError) {
|
|
|
|
qCritical() << "(1) INVALID JSON MSG: PARSING FAILED (msg=" << msg << "):"
|
|
|
|
<< parseError.error << parseError.errorString();
|
|
|
|
setProgress(100);
|
|
|
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::JSON_PARSE_FAILURE,
|
|
|
|
QString("(2) INVALID JSON %1 %2 %3")
|
|
|
|
.arg(msg)
|
|
|
|
.arg(parseError.error)
|
|
|
|
.arg(parseError.errorString()));
|
|
|
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
|
|
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
|
|
|
m_ismasClient.jsonParseFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
|
|
|
m_updateStatus.m_statusDescription));
|
|
|
|
emit replaceLast("Connecting backend ...", UPDATE_STEP_FAIL);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (!document.isObject()) {
|
|
|
|
qCritical() << "FILE IS NOT A JSON OBJECT!";
|
|
|
|
setProgress(100);
|
|
|
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::JSON_PARSE_FAILURE,
|
|
|
|
QString("NOT A JSON-OBJECT %1").arg(msg));
|
|
|
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
|
|
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
|
|
|
m_ismasClient.jsonParseFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
|
|
|
m_updateStatus.m_statusDescription));
|
|
|
|
emit replaceLast("Connecting backend ...", UPDATE_STEP_FAIL);
|
|
|
|
return false;
|
|
|
|
}
|
2023-08-02 15:50:04 +02:00
|
|
|
|
2023-08-11 10:55:53 +02:00
|
|
|
setProgress(progress + 1);
|
2023-08-07 13:56:51 +02:00
|
|
|
|
2023-08-11 10:55:53 +02:00
|
|
|
QJsonObject obj = document.object();
|
|
|
|
QStringList keys = obj.keys().filter("CMD_GET_APISMSTATUS_RESPONSE");
|
|
|
|
if (keys.size() == 1) {
|
|
|
|
QString const key = keys.at(0);
|
2023-08-02 15:50:04 +02:00
|
|
|
QJsonValue v = obj.value(key);
|
|
|
|
if (v.isObject()) {
|
|
|
|
obj = v.toObject();
|
|
|
|
bool ismas = obj.value("ISMAS").toBool();
|
|
|
|
QString status = obj.value("Broker").toString();
|
2023-08-09 16:16:36 +02:00
|
|
|
qInfo() << "REPEAT" << repeat << "In backendConnected() Broker=<"
|
|
|
|
<< status << ">, ISMAS=<" << (ismas ? "true>" : "false>");
|
2023-08-02 15:50:04 +02:00
|
|
|
if (ismas) {
|
|
|
|
if (status == "Connected") {
|
|
|
|
// do not send, as this would result in a corrupted wait button
|
|
|
|
// but update the user-interface
|
2023-08-07 13:56:51 +02:00
|
|
|
setProgress(100);
|
|
|
|
emit replaceLast("Connecting backend ...", UPDATE_STEP_OK);
|
2023-08-02 15:50:04 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2023-08-11 10:55:53 +02:00
|
|
|
|
|
|
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::BACKEND_CHECK,
|
|
|
|
QString ("REPEAT %1 Broker=<").arg(repeat)
|
|
|
|
+ status + ">, ISMAS=<" + (ismas ? "true>" : "false>"));
|
|
|
|
//IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
|
|
|
// QString("#M=APISM#C=CMD_EVENT#J=") +
|
|
|
|
// m_ismasClient.updateOfPSAContinues("BACKEND-CHECK", m_updateStatus.m_statusDescription));
|
|
|
|
|
|
|
|
qInfo() << "BACKEND-CHECK" << m_updateStatus.m_statusDescription;
|
|
|
|
emit showErrorMessage("Check backend connection", m_updateStatus.m_statusDescription);
|
2023-08-09 16:17:28 +02:00
|
|
|
QThread::sleep(6);
|
|
|
|
continue;
|
2023-08-11 10:55:53 +02:00
|
|
|
} else {
|
|
|
|
setProgress(100);
|
|
|
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::BACKEND_CHECK_FAILURE,
|
|
|
|
"CMD_GET_APISM_STATUS_RESPONSE KEY NOT A JSON-OBJECT");
|
|
|
|
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("check backend connection", m_updateStatus.m_statusDescription);
|
|
|
|
emit replaceLast("Connecting backend ...", UPDATE_STEP_FAIL);
|
|
|
|
return false;
|
2023-08-02 15:50:04 +02:00
|
|
|
}
|
2023-08-11 10:55:53 +02:00
|
|
|
} else {
|
|
|
|
setProgress(100);
|
|
|
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::BACKEND_CHECK_FAILURE,
|
|
|
|
"CMD_GET_APISMSTATUS_RESPONSE KEY NOT AVAILABLE");
|
|
|
|
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("check backend connection", m_updateStatus.m_statusDescription);
|
|
|
|
emit replaceLast("Connecting backend ...", UPDATE_STEP_FAIL);
|
|
|
|
return false;
|
2023-08-02 15:50:04 +02:00
|
|
|
}
|
2023-08-11 10:55:53 +02:00
|
|
|
|
|
|
|
} else {
|
|
|
|
stopProgressLoop();
|
|
|
|
int progress = (m_mainWindow->progressValue()/10) + 10;
|
|
|
|
setProgress(progress);
|
2023-08-02 15:50:04 +02:00
|
|
|
}
|
|
|
|
}
|
2023-08-07 13:56:51 +02:00
|
|
|
|
2023-08-11 10:55:53 +02:00
|
|
|
setProgress(100);
|
2023-08-04 13:49:32 +02:00
|
|
|
|
2023-08-11 10:55:53 +02:00
|
|
|
emit replaceLast("Connecting backend", UPDATE_STEP_FAIL);
|
|
|
|
emit showErrorMessage("Error", "Backend not available");
|
2023-08-02 15:50:04 +02:00
|
|
|
|
2023-08-11 10:55:53 +02:00
|
|
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::BACKEND_NOT_CONNECTED,
|
|
|
|
QString("NO BACKEND CONNECTION"));
|
|
|
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
|
|
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
|
|
|
m_ismasClient.errorBackendNotConnected(m_updateStatus.m_statusDescription, ""));
|
|
|
|
}
|
2023-08-02 15:50:04 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2023-08-14 14:33:12 +02:00
|
|
|
#define CHECK_UPDATE_TRIGGER_SET "Check update trigger ..."
|
|
|
|
|
2023-08-02 15:50:04 +02:00
|
|
|
bool Worker::updateTriggerSet() {
|
2023-08-09 16:17:28 +02:00
|
|
|
if (m_withoutIsmasDirectPort) { // useful for testing
|
|
|
|
return true;
|
|
|
|
}
|
2023-08-02 15:50:04 +02:00
|
|
|
|
2023-08-14 14:33:12 +02:00
|
|
|
emit appendText("\n" CHECK_UPDATE_TRIGGER_SET);
|
2023-08-02 15:50:04 +02:00
|
|
|
QString triggerValue("");
|
2023-08-18 11:52:34 +02:00
|
|
|
int const startMs = QTime::currentTime().msecsSinceStartOfDay();
|
2023-08-02 15:50:04 +02:00
|
|
|
|
2023-08-18 11:52:34 +02:00
|
|
|
for (int repeat = 1; repeat <= 100; ++repeat) {
|
2023-08-22 13:49:42 +02:00
|
|
|
|
2023-08-11 10:56:36 +02:00
|
|
|
qInfo() << "UPDATE TRIGGER SET -> REPEAT" << repeat;
|
|
|
|
|
2023-08-18 11:52:34 +02:00
|
|
|
if (repeat > 1) {
|
|
|
|
int const durationMs = QTime::currentTime().msecsSinceStartOfDay() - startMs;
|
2023-08-23 16:26:55 +02:00
|
|
|
QString const &msg = QString("elapsed: %1.%2s").arg(durationMs / 1000).arg(durationMs % 1000);
|
2023-08-22 13:49:42 +02:00
|
|
|
qInfo() << "REPEAT" << msg;
|
|
|
|
emit showErrorMessage("check update trigger", msg);
|
|
|
|
} else {
|
2023-08-23 16:26:55 +02:00
|
|
|
emit showErrorMessage("check update trigger", "");
|
2023-08-18 11:52:34 +02:00
|
|
|
}
|
2023-08-22 13:49:42 +02:00
|
|
|
|
2023-08-18 11:52:34 +02:00
|
|
|
if ((repeat % 10) == 0) {
|
|
|
|
qInfo() << "CHECK UPDATE TRIGGER. RESTART APISM ...";
|
|
|
|
Command c("systemctl restart apism");
|
|
|
|
if (c.execute("/tmp")) {
|
|
|
|
QThread::sleep(20); // give APISM some time to reconnect
|
|
|
|
qInfo() << "CHECK UPDATE TRIGGER. RESTARTING APISM DONE";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-09 16:17:28 +02:00
|
|
|
startProgressLoop();
|
|
|
|
if (std::optional<QString> result
|
|
|
|
= IsmasClient::sendRequestReceiveResponse(
|
|
|
|
IsmasClient::APISM::DIRECT_PORT, "#M=APISM#C=REQ_ISMASPARAMETER#J={}")) {
|
|
|
|
stopProgressLoop();
|
|
|
|
int progress = (m_mainWindow->progressValue()/10) + 10;
|
|
|
|
setProgress(progress);
|
2023-08-07 13:56:51 +02:00
|
|
|
|
2023-08-09 16:17:28 +02:00
|
|
|
QString msg = result.value();
|
2023-08-02 15:50:04 +02:00
|
|
|
|
2023-08-14 14:33:12 +02:00
|
|
|
qInfo() << "REPEAT" << repeat << "APISM RESPONSE (" << msg << ")";
|
2023-08-09 16:17:28 +02:00
|
|
|
|
|
|
|
QJsonParseError parseError;
|
|
|
|
QJsonDocument document(QJsonDocument::fromJson(msg.toUtf8(), &parseError));
|
|
|
|
if (parseError.error != QJsonParseError::NoError) {
|
|
|
|
qCritical() << "(2) INVALID JSON MSG: PARSING FAILED (msg=" << msg << "):"
|
|
|
|
<< parseError.error << parseError.errorString();
|
2023-08-11 10:58:29 +02:00
|
|
|
setProgress(100);
|
|
|
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::JSON_PARSE_FAILURE,
|
|
|
|
QString("(2) INVALID JSON %1 %2 %3")
|
|
|
|
.arg(msg)
|
|
|
|
.arg(parseError.error)
|
|
|
|
.arg(parseError.errorString()));
|
|
|
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
|
|
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
|
|
|
m_ismasClient.jsonParseFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
|
|
|
m_updateStatus.m_statusDescription));
|
2023-08-09 16:17:28 +02:00
|
|
|
emit showErrorMessage("check update trigger",
|
|
|
|
QString("invalid json ") + msg.mid(0, 20));
|
2023-08-14 14:33:12 +02:00
|
|
|
emit replaceLast(CHECK_UPDATE_TRIGGER_SET, UPDATE_STEP_FAIL);
|
2023-08-09 16:17:28 +02:00
|
|
|
return false;
|
2023-08-02 15:50:04 +02:00
|
|
|
}
|
2023-08-09 16:17:28 +02:00
|
|
|
if (!document.isObject()) {
|
|
|
|
qCritical() << "FILE IS NOT A JSON OBJECT!";
|
2023-08-11 10:58:29 +02:00
|
|
|
setProgress(100);
|
|
|
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::JSON_PARSE_FAILURE,
|
|
|
|
QString("NOT A JSON-OBJECT %1").arg(msg));
|
|
|
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
|
|
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
|
|
|
m_ismasClient.jsonParseFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
|
|
|
m_updateStatus.m_statusDescription));
|
|
|
|
emit showErrorMessage("check update trigger", QString("not a json object") + msg);
|
2023-08-14 14:33:12 +02:00
|
|
|
emit replaceLast(CHECK_UPDATE_TRIGGER_SET, UPDATE_STEP_FAIL);
|
2023-08-09 16:17:28 +02:00
|
|
|
return false;
|
|
|
|
}
|
2023-08-11 10:59:26 +02:00
|
|
|
progress += 1;
|
|
|
|
setProgress(progress);
|
2023-08-09 16:17:28 +02:00
|
|
|
|
|
|
|
QJsonObject obj = document.object();
|
2023-08-14 14:33:12 +02:00
|
|
|
|
|
|
|
// always look for an 'error' first
|
|
|
|
if (obj.contains("error")) {
|
|
|
|
progress += 1;
|
|
|
|
setProgress(progress);
|
|
|
|
QString value = obj.value("error").toString();
|
|
|
|
emit showErrorMessage("check update trigger", QString("REPEAT %1 error=<").arg(repeat) + value + ">");
|
|
|
|
qInfo() << "REPEAT" << repeat << "In updateTriggerSet() error=<"
|
|
|
|
<< value << ">";
|
|
|
|
QThread::sleep(6);
|
|
|
|
continue;
|
|
|
|
}
|
2023-08-09 16:17:28 +02:00
|
|
|
// sanity check: cust_nr and machine_nr of PSA correct ?
|
|
|
|
// note: this check has to be done here, as the cust_nr and the machine_nr
|
|
|
|
// of the PSA are sent by ISMAS.
|
|
|
|
if (obj.contains("Dev_ID")) {
|
|
|
|
QJsonValue v = obj.value("Dev_ID");
|
|
|
|
if (v.isObject()) {
|
|
|
|
QJsonObject obj = v.toObject();
|
|
|
|
if (obj.contains("Custom_ID") && obj.contains("Device_ID")) {
|
|
|
|
QJsonValue const c = obj.value("Custom_ID");
|
|
|
|
QJsonValue const m = obj.value("Device_ID");
|
|
|
|
int customerNr = c.toInt(-1);
|
|
|
|
int machineNr = m.toInt(-1);
|
|
|
|
if (customerNr != m_customerNr) {
|
2023-08-11 10:59:26 +02:00
|
|
|
setProgress(100);
|
2023-08-09 16:17:28 +02:00
|
|
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_FAILURE,
|
|
|
|
QString("CUSTOMER-NR (%1) != LOCAL CUSTOMER-NR (%2)")
|
|
|
|
.arg(customerNr).arg(m_customerNr));
|
|
|
|
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));
|
2023-08-11 11:00:02 +02:00
|
|
|
emit showErrorMessage("check update trigger", m_updateStatus.m_statusDescription);
|
2023-08-14 14:33:12 +02:00
|
|
|
emit replaceLast(CHECK_UPDATE_TRIGGER_SET, UPDATE_STEP_FAIL);
|
2023-08-09 16:17:28 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (machineNr != m_machineNr) {
|
2023-08-07 13:56:51 +02:00
|
|
|
setProgress(100);
|
2023-08-09 16:17:28 +02:00
|
|
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_FAILURE,
|
|
|
|
QString("MACHINE-NR (%1) != LOCAL MACHINE-NR (%2)")
|
|
|
|
.arg(machineNr).arg(m_machineNr));
|
2023-08-02 15:50:04 +02:00
|
|
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
|
|
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
2023-08-09 16:17:28 +02:00
|
|
|
m_ismasClient.sanityCheckFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
|
|
|
m_updateStatus.m_statusDescription));
|
2023-08-11 11:00:02 +02:00
|
|
|
emit showErrorMessage("check update trigger", m_updateStatus.m_statusDescription);
|
2023-08-14 14:33:12 +02:00
|
|
|
emit replaceLast(CHECK_UPDATE_TRIGGER_SET, UPDATE_STEP_FAIL);
|
2023-08-09 16:17:28 +02:00
|
|
|
return false;
|
|
|
|
}
|
2023-08-11 10:58:29 +02:00
|
|
|
|
|
|
|
qInfo() << "MACHINE-AND-CUSTOMER-CHECK" << m_updateStatus.m_statusDescription;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
setProgress(100);
|
|
|
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_FAILURE,
|
|
|
|
"Dev_ID DOES NOT CONTAIN Custom_ID AND/OR Device_ID");
|
|
|
|
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("check update trigger", m_updateStatus.m_statusDescription);
|
2023-08-14 14:33:12 +02:00
|
|
|
emit replaceLast(CHECK_UPDATE_TRIGGER_SET, UPDATE_STEP_FAIL);
|
2023-08-11 10:58:29 +02:00
|
|
|
return false;
|
2023-08-09 16:17:28 +02:00
|
|
|
}
|
2023-08-11 10:58:29 +02:00
|
|
|
} else {
|
|
|
|
setProgress(100);
|
|
|
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_FAILURE,
|
|
|
|
"Dev_ID KEY NOT A JSON-OBJECT");
|
|
|
|
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("check update trigger", m_updateStatus.m_statusDescription);
|
2023-08-14 14:33:12 +02:00
|
|
|
emit replaceLast(CHECK_UPDATE_TRIGGER_SET, UPDATE_STEP_FAIL);
|
2023-08-11 10:58:29 +02:00
|
|
|
return false;
|
2023-08-09 16:17:28 +02:00
|
|
|
}
|
2023-08-11 10:58:29 +02:00
|
|
|
} else {
|
|
|
|
setProgress(100);
|
|
|
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_FAILURE,
|
|
|
|
"Dev_ID KEY NOT AVAILABLE");
|
|
|
|
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("check update trigger", m_updateStatus.m_statusDescription);
|
2023-08-14 14:33:12 +02:00
|
|
|
emit replaceLast(CHECK_UPDATE_TRIGGER_SET, UPDATE_STEP_FAIL);
|
2023-08-11 10:58:29 +02:00
|
|
|
return false;
|
2023-08-09 16:17:28 +02:00
|
|
|
}
|
2023-08-11 10:59:26 +02:00
|
|
|
progress += 1;
|
|
|
|
setProgress(progress);
|
2023-08-09 16:17:28 +02:00
|
|
|
|
|
|
|
if (obj.contains("Fileupload")) {
|
|
|
|
QJsonValue v = obj.value("Fileupload");
|
|
|
|
if (v.isObject()) {
|
|
|
|
obj = v.toObject();
|
|
|
|
if (obj.contains("TRG")) {
|
2023-08-11 11:00:52 +02:00
|
|
|
triggerValue = obj.value("TRG").toString();
|
2023-08-09 16:17:28 +02:00
|
|
|
|
2023-08-11 11:00:02 +02:00
|
|
|
qInfo() << "REPEAT" << repeat
|
|
|
|
<< "In updateTriggerSet() TRG value=<"
|
|
|
|
<< triggerValue << ">";
|
2023-08-09 16:17:28 +02:00
|
|
|
|
2023-08-11 10:58:29 +02:00
|
|
|
if (triggerValue == "WAIT") {
|
|
|
|
setProgress(100);
|
|
|
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_SANITY_CHECK_OK,
|
|
|
|
QString("MACHINE-NR (%1) AND CUST-NR (%2) OK")
|
|
|
|
.arg(m_machineNr).arg(m_customerNr));
|
|
|
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
|
|
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
|
|
|
m_ismasClient.updateOfPSAContinues("MACHINE-AND-CUSTOMER-CHECK",
|
|
|
|
m_updateStatus.m_statusDescription));
|
2023-08-09 16:17:28 +02:00
|
|
|
|
2023-08-16 12:41:42 +02:00
|
|
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_UPDATE_TRIGGER_SET,
|
2023-08-11 10:58:29 +02:00
|
|
|
QString("UPDATE TRIGGER SET. CONTINUE. "));
|
|
|
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
|
|
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
|
|
|
m_ismasClient.updateTriggerSet(m_updateStatus.m_statusDescription, ""));
|
2023-08-09 16:17:28 +02:00
|
|
|
|
2023-08-14 14:33:12 +02:00
|
|
|
emit replaceLast(CHECK_UPDATE_TRIGGER_SET, UPDATE_STEP_DONE);
|
2023-08-11 10:58:29 +02:00
|
|
|
return true;
|
2023-08-14 14:33:12 +02:00
|
|
|
} else
|
|
|
|
if (QRegExp("\\s*").exactMatch(triggerValue)) { // check for whitespace
|
|
|
|
stopProgressLoop();
|
|
|
|
int progress = (m_mainWindow->progressValue()/10) + 10;
|
|
|
|
progress += 1;
|
|
|
|
setProgress(progress);
|
|
|
|
emit showErrorMessage("check update trigger", "empty update-trigger");
|
|
|
|
QThread::sleep(6);
|
|
|
|
continue;
|
2023-08-11 10:58:29 +02:00
|
|
|
} else {
|
|
|
|
// 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,
|
2023-08-14 14:33:12 +02:00
|
|
|
QString("TRIGGER-VALUE=<") + triggerValue + "> NOT 'WAIT'");
|
2023-08-11 10:58:29 +02:00
|
|
|
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("check update trigger", m_updateStatus.m_statusDescription);
|
2023-08-14 14:33:12 +02:00
|
|
|
emit replaceLast(CHECK_UPDATE_TRIGGER_SET, UPDATE_STEP_FAIL);
|
2023-08-11 10:58:29 +02:00
|
|
|
return false;
|
2023-08-02 15:50:04 +02:00
|
|
|
}
|
2023-08-09 16:17:28 +02:00
|
|
|
} else {
|
2023-08-11 10:58:29 +02:00
|
|
|
setProgress(100);
|
|
|
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_FAILURE,
|
|
|
|
"TRG KEY NOT AVAILABLE");
|
|
|
|
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));
|
2023-08-14 14:33:12 +02:00
|
|
|
emit replaceLast(CHECK_UPDATE_TRIGGER_SET, UPDATE_STEP_FAIL);
|
2023-08-11 10:58:29 +02:00
|
|
|
emit showErrorMessage("check update trigger", m_updateStatus.m_statusDescription);
|
|
|
|
return false;
|
2023-08-02 15:50:04 +02:00
|
|
|
}
|
|
|
|
} else {
|
2023-08-11 10:58:29 +02:00
|
|
|
setProgress(100);
|
|
|
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_FAILURE,
|
|
|
|
"Fileupload NOT A JSON-OBJECT");
|
|
|
|
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));
|
2023-08-14 14:33:12 +02:00
|
|
|
emit replaceLast(CHECK_UPDATE_TRIGGER_SET, UPDATE_STEP_FAIL);
|
2023-08-11 10:58:29 +02:00
|
|
|
emit showErrorMessage("check update trigger", m_updateStatus.m_statusDescription);
|
|
|
|
return false;
|
2023-08-02 15:50:04 +02:00
|
|
|
}
|
2023-08-11 10:58:29 +02:00
|
|
|
} else {
|
|
|
|
setProgress(100);
|
|
|
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_FAILURE,
|
|
|
|
"Fileupload KEY NOT AVAILABLE");
|
|
|
|
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));
|
2023-08-14 14:33:12 +02:00
|
|
|
emit replaceLast(CHECK_UPDATE_TRIGGER_SET, UPDATE_STEP_FAIL);
|
2023-08-11 10:58:29 +02:00
|
|
|
emit showErrorMessage("check update trigger", m_updateStatus.m_statusDescription);
|
|
|
|
return false;
|
2023-08-02 15:50:04 +02:00
|
|
|
}
|
2023-08-09 16:17:28 +02:00
|
|
|
} else {
|
|
|
|
stopProgressLoop();
|
|
|
|
int progress = (m_mainWindow->progressValue()/10) + 10;
|
2023-08-11 10:59:26 +02:00
|
|
|
progress += 1;
|
2023-08-09 16:17:28 +02:00
|
|
|
setProgress(progress);
|
|
|
|
emit showErrorMessage("check update trigger", "no ISMAS response");
|
|
|
|
QThread::sleep(6);
|
2023-08-02 15:50:04 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-07 13:56:51 +02:00
|
|
|
setProgress(100);
|
2023-08-16 12:41:42 +02:00
|
|
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_UPDATE_TRIGGER_NOT_SET_OR_WRONG,
|
|
|
|
QString("ISMAS_UPDATE-TRIGGER-NOT-SET-OR-WRONG: VALUE=(") +
|
2023-08-02 15:50:04 +02:00
|
|
|
triggerValue + ")");
|
|
|
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
|
|
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
|
|
|
m_ismasClient.errorUpdateTrigger(m_updateStatus.m_statusDescription, ""));
|
2023-08-07 13:56:51 +02:00
|
|
|
|
2023-08-14 14:33:12 +02:00
|
|
|
emit replaceLast(CHECK_UPDATE_TRIGGER_SET, UPDATE_STEP_FAIL);
|
2023-08-02 15:50:04 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Worker::customerEnvironment() {
|
2023-08-07 13:56:51 +02:00
|
|
|
emit appendText("\nPrepare customer environment ...");
|
2023-08-02 15:50:04 +02:00
|
|
|
if (QDir(m_customerRepository).exists()) {
|
2023-08-07 13:56:51 +02:00
|
|
|
startProgressLoop();
|
2023-08-02 15:50:04 +02:00
|
|
|
if (m_gc.gitCheckoutBranch()) {
|
2023-08-07 13:56:51 +02:00
|
|
|
stopProgressLoop();
|
|
|
|
int progress = (m_mainWindow->progressValue()/10) + 10;
|
|
|
|
setProgress(progress);
|
|
|
|
|
2023-08-02 15:50:04 +02:00
|
|
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_CHECKOUT_BRANCH,
|
|
|
|
QString("CHECKED-OUT BRANCH ") + m_gc.branchName());
|
|
|
|
|
|
|
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
|
|
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
|
|
|
m_ismasClient.checkoutBranch(m_updateStatus.m_statusDescription, ""));
|
2023-08-07 13:56:51 +02:00
|
|
|
|
|
|
|
setProgress(100);
|
|
|
|
emit replaceLast("Prepare customer environment ...", UPDATE_STEP_DONE);
|
2023-08-09 16:16:36 +02:00
|
|
|
qInfo() << "PREPARE CUSTOMER ENVIRONMENT DONE";
|
2023-08-02 15:50:04 +02:00
|
|
|
return true;
|
|
|
|
} else {
|
2023-08-07 13:56:51 +02:00
|
|
|
stopProgressLoop();
|
|
|
|
int progress = (m_mainWindow->progressValue()/10) + 10;
|
|
|
|
setProgress(progress);
|
2023-08-02 15:50:04 +02:00
|
|
|
emit showErrorMessage("cust-env",
|
|
|
|
QString("Checkout ") + m_customerRepository + " failed");
|
2023-08-11 10:52:31 +02:00
|
|
|
Utils::printCriticalErrorMsg(QString("CHECKOUT OF " + m_customerRepository + "FAILED"));
|
2023-08-02 15:50:04 +02:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
emit showErrorMessage("cust-env", m_customerRepository + " does not exist");
|
2023-08-11 10:52:31 +02:00
|
|
|
Utils::printCriticalErrorMsg(m_customerRepository + " DOES NOT EXIST");
|
2023-08-02 15:50:04 +02:00
|
|
|
}
|
2023-08-07 13:56:51 +02:00
|
|
|
|
|
|
|
setProgress(100);
|
|
|
|
emit replaceLast("Prepare customer environment ...", UPDATE_STEP_FAIL);
|
2023-08-02 15:50:04 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Worker::filesToUpdate() {
|
2023-08-07 13:56:51 +02:00
|
|
|
emit appendText("\nFetch changes files ...");
|
|
|
|
startProgressLoop();
|
2023-08-02 15:50:04 +02:00
|
|
|
if (std::optional<QString> changes = m_gc.gitFetch()) {
|
2023-08-07 13:56:51 +02:00
|
|
|
stopProgressLoop();
|
|
|
|
int progress = (m_mainWindow->progressValue()/10) + 10;
|
|
|
|
setProgress(progress);
|
|
|
|
|
2023-08-02 15:50:04 +02:00
|
|
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_FETCH_UPDATES,
|
|
|
|
QString("FETCHING OF ") + m_customerRepositoryPath +
|
|
|
|
QString(" INTO ") + m_customerRepository);
|
|
|
|
|
2023-08-07 13:56:51 +02:00
|
|
|
setProgress(progress + 10);
|
2023-08-02 15:50:04 +02:00
|
|
|
if (std::optional<QStringList> changedFileNames = m_gc.gitDiff(changes.value())) {
|
2023-08-07 13:56:51 +02:00
|
|
|
setProgress(progress + 20);
|
2023-08-04 13:50:19 +02:00
|
|
|
if (m_gc.gitPull()) {
|
2023-08-07 13:56:51 +02:00
|
|
|
emit replaceLast(QString("Fetch changes files ..."), UPDATE_STEP_DONE);
|
|
|
|
m_filesToUpdate = changedFileNames.value();
|
2023-08-09 16:16:36 +02:00
|
|
|
|
2023-08-11 10:52:31 +02:00
|
|
|
Utils::printInfoMsg("FILES-TO-UPDATE " + m_filesToUpdate.join(','));
|
2023-08-09 16:16:36 +02:00
|
|
|
|
2023-08-07 13:56:51 +02:00
|
|
|
int const size = m_filesToUpdate.size();
|
|
|
|
if (size > 1) {
|
2023-08-09 16:16:36 +02:00
|
|
|
emit appendText(QString("Found %1 files to update :").arg(size), UPDATE_STEP_DONE);
|
|
|
|
for (int i = 0; i < size; ++i) {
|
|
|
|
emit appendText(QString("\n ") + m_filesToUpdate.at(i));
|
|
|
|
}
|
2023-08-07 13:56:51 +02:00
|
|
|
} else {
|
2023-08-09 16:16:36 +02:00
|
|
|
emit appendText("Found 1 file to update :", UPDATE_STEP_DONE);
|
|
|
|
emit appendText(QString("\n ") + m_filesToUpdate.at(0));
|
2023-08-07 13:56:51 +02:00
|
|
|
}
|
2023-08-04 13:50:19 +02:00
|
|
|
return true;
|
2023-08-02 16:53:19 +02:00
|
|
|
}
|
2023-08-04 13:50:19 +02:00
|
|
|
emit showErrorMessage("files to update", "pulling files failed");
|
2023-08-11 10:52:31 +02:00
|
|
|
Utils::printCriticalErrorMsg("PULLING FILES FAILED");
|
2023-08-09 16:16:36 +02:00
|
|
|
|
2023-08-02 15:50:04 +02:00
|
|
|
} else {
|
|
|
|
emit showErrorMessage("files to update", "no files to update (checked-in any files?)");
|
2023-08-11 10:52:31 +02:00
|
|
|
Utils::printCriticalErrorMsg("NO FILES TO UPDATE (CHECKED IN ANY FILES?)");
|
2023-08-02 15:50:04 +02:00
|
|
|
}
|
2023-08-07 13:56:51 +02:00
|
|
|
setProgress(progress + 30);
|
2023-08-02 15:50:04 +02:00
|
|
|
} else {
|
2023-08-07 13:56:51 +02:00
|
|
|
stopProgressLoop();
|
|
|
|
int progress = (m_mainWindow->progressValue()/10) + 10;
|
|
|
|
setProgress(progress + 30);
|
|
|
|
|
2023-08-02 15:50:04 +02:00
|
|
|
emit showErrorMessage("files to update",
|
|
|
|
QString("no changes in ") + m_customerRepository +
|
|
|
|
" (checked-in any files?)");
|
2023-08-09 16:16:36 +02:00
|
|
|
|
2023-08-11 10:52:31 +02:00
|
|
|
Utils::printCriticalErrorMsg("NO CHANGES IN "
|
|
|
|
+ m_customerRepository
|
|
|
|
+ " (CHECKED IN ANY FILES?)");
|
2023-08-02 15:50:04 +02:00
|
|
|
}
|
2023-08-07 13:56:51 +02:00
|
|
|
|
|
|
|
emit replaceLast(QString("Fetch changes files ..."), UPDATE_STEP_FAIL);
|
|
|
|
setProgress(100);
|
2023-08-02 15:50:04 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Worker::updateFiles(quint8 percent) {
|
|
|
|
QStringList filesToDownload;
|
|
|
|
m_displayIndex = 0;
|
2023-08-07 13:56:51 +02:00
|
|
|
|
|
|
|
startProgressLoop();
|
2023-08-02 15:50:04 +02:00
|
|
|
for (int i = 0; i < m_filesToUpdate.size(); ++i) {
|
2023-08-11 10:52:31 +02:00
|
|
|
QString const fName = m_filesToUpdate.at(i);
|
|
|
|
Utils::printInfoMsg(QString("FNAME ") + fName);
|
2023-08-09 16:16:36 +02:00
|
|
|
|
2023-08-02 15:50:04 +02:00
|
|
|
if (fName.contains("opkg_commands", Qt::CaseInsensitive)) {
|
2023-08-09 16:16:36 +02:00
|
|
|
emit appendText("\n( ) Update opkg pakets ...");
|
2023-08-02 15:50:04 +02:00
|
|
|
// execute opkg commands
|
|
|
|
if (QDir::setCurrent(m_customerRepository)) {
|
|
|
|
QFile f(fName);
|
|
|
|
if (f.exists()) {
|
|
|
|
if (f.open(QIODevice::ReadOnly)) {
|
|
|
|
QTextStream in(&f);
|
|
|
|
int cmdCount = 0;
|
2023-08-18 11:53:32 +02:00
|
|
|
QStringList opkgCommands;
|
2023-08-02 15:50:04 +02:00
|
|
|
while (!in.atEnd()) {
|
|
|
|
QString line = in.readLine();
|
|
|
|
static const QRegularExpression comment("^\\s*#.*$");
|
|
|
|
if (line.indexOf(comment, 0) == -1) {
|
|
|
|
// found opkg command
|
|
|
|
QString opkgCommand = line.trimmed();
|
|
|
|
++cmdCount;
|
2023-08-18 11:53:32 +02:00
|
|
|
executeOpkgCommand(opkgCommand);
|
|
|
|
QString cmd = "\n " + opkgCommand;
|
|
|
|
emit appendText(cmd);
|
|
|
|
opkgCommands << cmd;
|
2023-08-02 15:50:04 +02:00
|
|
|
|
|
|
|
m_ismasClient.setProgressInPercent(++percent);
|
|
|
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::EXEC_OPKG_COMMAND,
|
|
|
|
QString("EXEC OPKG-COMMAND ") + opkgCommand);
|
|
|
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
|
|
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
|
|
|
m_ismasClient.execOpkgCommand(m_updateStatus.m_statusDescription, ""));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
f.close();
|
|
|
|
if (cmdCount > 0) {
|
|
|
|
m_displayIndex = 1;
|
2023-08-18 11:53:32 +02:00
|
|
|
QString prepend = QString("(") + QString("%1").arg(m_displayIndex).rightJustified(2, ' ') + QString(")")
|
|
|
|
+ QString(" Update opkg pakets ... ");
|
|
|
|
opkgCommands.prepend(prepend);
|
|
|
|
emit replaceLast(opkgCommands, UPDATE_STEP_DONE);
|
2023-08-09 16:17:28 +02:00
|
|
|
} else {
|
|
|
|
m_displayIndex = 1;
|
|
|
|
emit replaceLast(QString("(") + QString("%1").arg(m_displayIndex).rightJustified(2, ' ') + QString(")")
|
|
|
|
+ QString(" Update opkg pakets ... "), UPDATE_STEP_FAIL);
|
2023-08-02 15:50:04 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
if (fName.contains("print", Qt::CaseInsensitive)) {
|
|
|
|
filesToDownload << fName; // download printer-config-files
|
2023-08-09 16:16:36 +02:00
|
|
|
} else {
|
|
|
|
static const QRegularExpression version("^.*dc2c[.][0-9][0-9][.][0-9][0-9][.]bin.*$");
|
|
|
|
if (fName.contains(version)) {
|
|
|
|
filesToDownload << fName; // download device controller
|
|
|
|
}
|
2023-08-02 15:50:04 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-09 16:16:36 +02:00
|
|
|
stopProgressLoop();
|
|
|
|
setProgress(100);
|
|
|
|
bool ret = true;
|
|
|
|
|
2023-08-03 09:06:50 +02:00
|
|
|
if (filesToDownload.size() > 0) {
|
2023-08-11 10:52:31 +02:00
|
|
|
Utils::printInfoMsg(QString("FILES_TO_DOWNLOAD_TO_PSA_HW ") + filesToDownload.join(','));
|
2023-08-09 16:16:36 +02:00
|
|
|
ret = m_update->doUpdate(m_displayIndex, filesToDownload);
|
|
|
|
} else {
|
2023-08-11 10:52:31 +02:00
|
|
|
Utils::printCriticalErrorMsg("NO FILES_TO_DOWNLOAD_TO_PSA_HW");
|
2023-08-03 09:06:50 +02:00
|
|
|
}
|
2023-08-02 15:50:04 +02:00
|
|
|
|
2023-08-07 13:56:51 +02:00
|
|
|
return ret;
|
2023-08-02 15:50:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Worker::syncCustomerRepositoryAndFS() {
|
2023-08-14 14:33:12 +02:00
|
|
|
// this step is currently needed only for updating tariff-files
|
2023-08-07 13:56:51 +02:00
|
|
|
setProgress(0);
|
|
|
|
emit appendText("\nSync customer environment with filesystem ...");
|
2023-08-02 15:50:04 +02:00
|
|
|
if (QDir(m_customerRepository).exists()) {
|
|
|
|
if (QDir::setCurrent(m_customerRepository)) {
|
2023-08-14 14:33:12 +02:00
|
|
|
Command md("bash");
|
|
|
|
if (!md.execute(m_customerRepository,
|
|
|
|
QStringList() << "-c" << "mkdir -p /etc/psa_config /etc/psa_update /etc/dc /etc/psa_tariff")) {
|
|
|
|
qCritical() << "COULD NOT EXECUTE '" << md.command() << "' exitCode=(" << md.exitCode() << ")";
|
|
|
|
}
|
2023-08-07 13:56:51 +02:00
|
|
|
int progress = 10;
|
|
|
|
setProgress(progress);
|
2023-08-23 16:26:55 +02:00
|
|
|
QString const params("-vvv "
|
2023-08-04 13:52:57 +02:00
|
|
|
"--recursive "
|
2023-08-02 15:50:04 +02:00
|
|
|
"--progress "
|
|
|
|
"--checksum "
|
|
|
|
"--exclude=.* "
|
|
|
|
"--include=*.bin "
|
|
|
|
"--include=*.json "
|
|
|
|
"--include=opkg_commands "
|
|
|
|
"--include=*.ini");
|
|
|
|
QStringList cmds;
|
|
|
|
cmds << QString("rsync ") + params.simplified() + " etc/ /etc";
|
|
|
|
cmds << QString("rsync ") + params.simplified() + " opt/ /opt";
|
|
|
|
|
|
|
|
QString cmd;
|
|
|
|
bool error = false;
|
|
|
|
foreach (cmd, cmds) {
|
2023-08-07 13:56:51 +02:00
|
|
|
progress += 5;
|
|
|
|
setProgress(progress);
|
2023-08-02 15:50:04 +02:00
|
|
|
if (!error) {
|
|
|
|
Command c("bash");
|
|
|
|
qInfo() << "EXECUTING CMD..." << cmd;
|
|
|
|
if (c.execute(m_customerRepository, QStringList() << "-c" << cmd)) {
|
2023-08-04 13:49:32 +02:00
|
|
|
QStringList result = c.getCommandResult().split('\n');
|
2023-08-23 16:26:55 +02:00
|
|
|
QString const &p1 = "send_files mapped ";
|
|
|
|
QString const &p2 = "of size";
|
2023-08-04 13:49:32 +02:00
|
|
|
for (int i = 0; i < result.size(); ++i) {
|
2023-08-23 16:26:55 +02:00
|
|
|
QString line = result.at(i);
|
|
|
|
qInfo() << line;
|
|
|
|
|
|
|
|
// "send_files mapped etc/psa_tariff/tariff01.json of size 19339"
|
|
|
|
int sendFilesAtPos = line.indexOf(p1);
|
|
|
|
int ofSizeAtPos = line.indexOf(p2);
|
|
|
|
if (sendFilesAtPos != -1 && ofSizeAtPos != -1) {
|
|
|
|
sendFilesAtPos += p1.length();
|
|
|
|
QString const &s = line.mid(sendFilesAtPos, ofSizeAtPos - sendFilesAtPos).trimmed();
|
|
|
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::RSYNC_FILE_SUCCESS,
|
|
|
|
QString("RSYNC FILE ") + s.split("/").last() +
|
|
|
|
" LAST-COMMIT: " + m_gc.gitLastCommit(s));
|
|
|
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
|
|
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
|
|
|
m_ismasClient.rsyncFile(m_updateStatus.m_statusDescription, ""));
|
|
|
|
}
|
2023-08-04 13:49:32 +02:00
|
|
|
}
|
2023-08-02 15:50:04 +02:00
|
|
|
} else {
|
2023-08-11 10:52:31 +02:00
|
|
|
Utils::printCriticalErrorMsg(QString("CMD ") + cmd + " FAILED: "
|
2023-08-14 14:33:12 +02:00
|
|
|
+ c.getCommandResult() + QString(" EXIT_CODE=(%1)").arg(c.exitCode()));
|
2023-08-02 15:50:04 +02:00
|
|
|
error = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-08-07 13:56:51 +02:00
|
|
|
progress += 5;
|
|
|
|
setProgress(progress);
|
2023-08-02 15:50:04 +02:00
|
|
|
if (!error) {
|
2023-08-22 12:31:15 +02:00
|
|
|
// now check tariff-files in etc and /etc/psa_tariff
|
|
|
|
QDir dir1(QDir::cleanPath(m_customerRepository + QDir::separator() + "etc/psa_tariff"));
|
|
|
|
QDir dir2("/etc/psa_tariff");
|
|
|
|
if (Utils::sameFilesInDirs(dir1, dir2)) {
|
|
|
|
setProgress(100);
|
|
|
|
emit replaceLast(QString("Sync customer environment with filesystem ..."), UPDATE_STEP_DONE);
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
// TODO: send message to ISMAS
|
|
|
|
}
|
2023-08-02 15:50:04 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-08-07 13:56:51 +02:00
|
|
|
setProgress(100);
|
|
|
|
emit replaceLast(QString("Sync customer environment with filesystem ..."), UPDATE_STEP_FAIL);
|
2023-08-02 15:50:04 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Worker::sendIsmasLastVersionNotification() {
|
|
|
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
|
|
|
QString("#M=APISM#C=CMD_SENDVERSION#J=") +
|
|
|
|
m_ismasClient.updateOfPSASendVersion(getPSAInstalled()));
|
2023-08-07 13:56:51 +02:00
|
|
|
emit appendText(QString("Send last version info "), UPDATE_STEP_DONE);
|
2023-08-02 15:50:04 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Worker::saveLogFile() {
|
|
|
|
return true;
|
|
|
|
}
|
2023-07-17 16:43:05 +02:00
|
|
|
QString Worker::getOsVersion() const {
|
|
|
|
QString const cmd = QString("echo -n $(cat /etc/os-release | head -n 1 | cut -d'\"' -f2 | tr -d '\"')");
|
|
|
|
Command c("bash");
|
|
|
|
if (c.execute(m_workingDirectory, QStringList() << "-c" << cmd)) {
|
|
|
|
return c.getCommandResult();
|
|
|
|
}
|
|
|
|
return "N/A";
|
|
|
|
}
|
|
|
|
|
2023-07-19 16:42:18 +02:00
|
|
|
QString Worker::getATBQTVersion() const {
|
|
|
|
QString const cmd = QString("echo -n $(/opt/app/ATBAPP/ATBQT -v | head -n 2 | cut -d':' -f2)");
|
|
|
|
Command c("bash");
|
|
|
|
if (c.execute(m_workingDirectory, QStringList() << "-c" << cmd)) {
|
|
|
|
return c.getCommandResult();
|
|
|
|
}
|
|
|
|
return "N/A";
|
|
|
|
}
|
|
|
|
|
|
|
|
QString Worker::getCPUSerial() const {
|
|
|
|
QString const cmd = QString("echo -n $(cat /proc/cpuinfo | grep -i Serial | cut -d':' -f2)");
|
|
|
|
Command c("bash");
|
|
|
|
if (c.execute(m_workingDirectory, QStringList() << "-c" << cmd)) {
|
|
|
|
return c.getCommandResult();
|
|
|
|
}
|
|
|
|
return "N/A";
|
|
|
|
}
|
|
|
|
|
|
|
|
QString Worker::getRaucVersion() const {
|
|
|
|
QString const cmd = QString("echo -n $(rauc --version)");
|
|
|
|
Command c("bash");
|
|
|
|
if (c.execute(m_workingDirectory, QStringList() << "-c" << cmd)) {
|
|
|
|
return c.getCommandResult();
|
|
|
|
}
|
|
|
|
return "N/A";
|
|
|
|
}
|
|
|
|
|
|
|
|
QString Worker::getOpkgVersion() const {
|
|
|
|
QString const cmd = QString("echo -n $(opkg --version)");
|
|
|
|
Command c("bash");
|
|
|
|
if (c.execute(m_workingDirectory, QStringList() << "-c" << cmd)) {
|
|
|
|
return c.getCommandResult();
|
|
|
|
}
|
|
|
|
return "N/A";
|
|
|
|
}
|
|
|
|
|
|
|
|
QString Worker::getPluginVersion(QString const &pluginFileName) const {
|
|
|
|
QString const cmd = QString("echo -n $(strings %1 | grep \\\"Version\\\" | cut -d':' -f2 | tr -d '\"' | tr -d ',')").arg(pluginFileName);
|
|
|
|
Command c("bash");
|
|
|
|
if (c.execute(m_workingDirectory, QStringList() << "-c" << cmd)) {
|
|
|
|
return c.getCommandResult();
|
|
|
|
}
|
|
|
|
return "N/A";
|
|
|
|
}
|
|
|
|
|
|
|
|
QStringList Worker::getDCVersion() const {
|
|
|
|
QStringList lst = (QStringList() << "N/A" << "N/A");
|
|
|
|
if (m_hw) {
|
|
|
|
m_hw->dc_autoRequest(true); // turn auto-request setting on
|
|
|
|
|
|
|
|
QByteArray const cmp(8, char(0));
|
|
|
|
QByteArray hw(""), sw("");
|
|
|
|
for (int i=0; i<5; ++i) {
|
|
|
|
hw = m_hw->dc_getHWversion().toUtf8();
|
|
|
|
sw = m_hw->dc_getSWversion().toUtf8();
|
|
|
|
if (!hw.startsWith(cmp)) {
|
|
|
|
lst.clear();
|
|
|
|
qInfo() << hw << sw;
|
|
|
|
lst << hw << sw;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
QThread::sleep(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return lst;
|
|
|
|
}
|
|
|
|
|
|
|
|
qint64 Worker::getFileSize(QString const &fileName) const {
|
|
|
|
// fileName has to be an absolute path
|
|
|
|
QFileInfo fInfo(fileName);
|
|
|
|
return fInfo.exists() ? fInfo.size() : -1;
|
|
|
|
}
|
|
|
|
|
2023-08-02 15:50:04 +02:00
|
|
|
bool Worker::executeOpkgCommand(QString opkgCommand) {
|
2023-07-14 13:32:00 +02:00
|
|
|
Command c(opkgCommand);
|
|
|
|
if (c.execute(m_workingDirectory)) {
|
|
|
|
QString const r = c.getCommandResult();
|
2023-08-11 10:52:31 +02:00
|
|
|
Utils::printInfoMsg(QString("EXECUTE OPKG COMMAND %1 OK: %2")
|
2023-07-19 16:42:18 +02:00
|
|
|
.arg(opkgCommand)
|
|
|
|
.arg(c.getCommandResult()));
|
2023-08-02 15:50:04 +02:00
|
|
|
return true;
|
2023-07-17 16:43:05 +02:00
|
|
|
} else {
|
2023-08-11 10:52:31 +02:00
|
|
|
Utils::printCriticalErrorMsg(QString("EXECUTE OPKG COMMAND %1 FAILED")
|
|
|
|
.arg(opkgCommand));
|
2023-07-14 13:32:00 +02:00
|
|
|
}
|
2023-08-02 15:50:04 +02:00
|
|
|
return false;
|
2023-06-16 16:47:13 +02:00
|
|
|
}
|
|
|
|
|
2023-08-02 15:50:04 +02:00
|
|
|
PSAInstalled Worker::getPSAInstalled() {
|
|
|
|
QStringList const dcVersion = getDCVersion();
|
|
|
|
QString const deviceControllerVersionHW = dcVersion.first();
|
|
|
|
QString const deviceControllerVersionSW = dcVersion.last();
|
2023-07-19 16:42:18 +02:00
|
|
|
|
2023-08-02 15:50:04 +02:00
|
|
|
qInfo() << "CURRENT DC-HW-VERSION: " << deviceControllerVersionHW;
|
|
|
|
qInfo() << "CURRENT DC-SW-VERSION: " << deviceControllerVersionSW;
|
2023-07-19 16:42:18 +02:00
|
|
|
|
2023-08-02 15:50:04 +02:00
|
|
|
QString const deviceControllerGitBlob = "N/A";
|
|
|
|
QString const deviceControllerGitLastCommit = "N/A";
|
2023-07-19 16:42:18 +02:00
|
|
|
|
2023-08-02 15:50:04 +02:00
|
|
|
PSAInstalled psaInstalled;
|
|
|
|
QString printSysDir("/etc/psa_config");
|
|
|
|
QString tariffSysDir("/etc/psa_tariff");
|
2023-08-11 11:02:15 +02:00
|
|
|
QString tariffRepoDir("etc/psa_tariff");
|
2023-08-22 13:49:09 +02:00
|
|
|
QString opkgSysDir("/etc/psa_update");
|
|
|
|
QString opkgRepoDir("etc/psa_update");
|
|
|
|
QString const &absPathNameOpkg = QDir::cleanPath(opkgSysDir + QDir::separator() + "opkg_commands");
|
|
|
|
QString const &absPathNameRepositoryOpkg = QDir::cleanPath(opkgRepoDir + QDir::separator() + "opkg_commands");
|
2023-08-02 15:50:04 +02:00
|
|
|
QString absPathName;
|
2023-08-11 11:02:15 +02:00
|
|
|
QString absPathNameRepository;
|
2023-07-19 16:42:18 +02:00
|
|
|
|
2023-08-16 10:38:36 +02:00
|
|
|
psaInstalled.versionInfo.lastCommit = "";
|
|
|
|
psaInstalled.versionInfo.reason = "";
|
|
|
|
psaInstalled.versionInfo.created = "";
|
|
|
|
|
|
|
|
QStringList versionInfo = m_gc.gitShowReason();
|
|
|
|
if (versionInfo.size() == 3) {
|
|
|
|
psaInstalled.versionInfo.lastCommit = versionInfo.at(0);
|
|
|
|
psaInstalled.versionInfo.reason = versionInfo.at(1);
|
|
|
|
psaInstalled.versionInfo.created = versionInfo.at(2);
|
|
|
|
}
|
|
|
|
|
2023-08-02 15:50:04 +02:00
|
|
|
if (m_zoneNr != 0) {
|
|
|
|
QString const &n = QString("%1").arg(m_zoneNr).rightJustified(2, '0');
|
|
|
|
psaInstalled.tariff.name = QString("tariff%1.json").arg(n);
|
|
|
|
absPathName = QDir::cleanPath(tariffSysDir + QDir::separator() + psaInstalled.tariff.name);
|
|
|
|
psaInstalled.tariff.blob = m_gc.gitBlob(absPathName);
|
2023-08-11 11:02:15 +02:00
|
|
|
absPathNameRepository = QDir::cleanPath(tariffRepoDir + QDir::separator() + psaInstalled.tariff.name);
|
|
|
|
psaInstalled.tariff.lastCommit = m_gc.gitLastCommit(absPathNameRepository);
|
2023-08-02 15:50:04 +02:00
|
|
|
psaInstalled.tariff.size = getFileSize(absPathName);
|
|
|
|
psaInstalled.tariff.zone = m_zoneNr;
|
2023-08-11 11:02:15 +02:00
|
|
|
psaInstalled.tariff.loadTime = Utils::getTariffLoadTime(absPathName);
|
2023-07-11 16:58:49 +02:00
|
|
|
}
|
2023-08-02 15:50:04 +02:00
|
|
|
psaInstalled.tariff.project = "Szeged";
|
|
|
|
psaInstalled.tariff.info = "N/A";
|
|
|
|
psaInstalled.tariff.version = "N/A";
|
2023-07-11 16:58:49 +02:00
|
|
|
|
2023-08-02 15:50:04 +02:00
|
|
|
psaInstalled.hw.linuxVersion = m_osVersion;
|
|
|
|
psaInstalled.hw.cpuSerial = m_cpuSerial;
|
2023-07-19 16:42:18 +02:00
|
|
|
|
2023-08-22 13:49:09 +02:00
|
|
|
psaInstalled.opkg.blob = m_gc.gitBlob(absPathNameOpkg);
|
|
|
|
psaInstalled.opkg.size = getFileSize(absPathNameOpkg);
|
|
|
|
psaInstalled.opkg.loadTime = Utils::getTariffLoadTime(absPathNameOpkg);
|
|
|
|
psaInstalled.opkg.lastCommit = m_gc.gitLastCommit(absPathNameRepositoryOpkg);
|
|
|
|
|
2023-08-02 15:50:04 +02:00
|
|
|
psaInstalled.dc.versionHW = deviceControllerVersionHW;
|
|
|
|
psaInstalled.dc.versionSW = deviceControllerVersionSW;
|
|
|
|
psaInstalled.dc.gitBlob = "N/A";
|
|
|
|
psaInstalled.dc.gitLastCommit = "N/A";
|
|
|
|
psaInstalled.dc.size = -1;
|
2023-07-19 16:42:18 +02:00
|
|
|
|
2023-08-02 15:50:04 +02:00
|
|
|
psaInstalled.sw.raucVersion = m_raucVersion;
|
|
|
|
psaInstalled.sw.opkgVersion = m_opkgVersion;
|
|
|
|
psaInstalled.sw.atbQTVersion = m_atbqtVersion;
|
2023-07-19 16:42:18 +02:00
|
|
|
|
2023-08-02 15:50:04 +02:00
|
|
|
psaInstalled.pluginVersion.deviceController = m_pluginVersionATBDeciceController;
|
|
|
|
psaInstalled.pluginVersion.ingenicoISelfCC = m_pluginVersionIngenicoISelf;
|
|
|
|
psaInstalled.pluginVersion.mobilisisCalculatePrice = m_pluginVersionMobilisisCalc;
|
|
|
|
psaInstalled.pluginVersion.mobilisisCalculatePriceConfigUi = m_pluginVersionMobilisisCalcConfig;
|
|
|
|
psaInstalled.pluginVersion.prmCalculatePrice = m_pluginVersionPrmCalc;
|
|
|
|
psaInstalled.pluginVersion.prmCalculatePriceConfigUi = m_pluginVersionPrmCalcConfig;
|
|
|
|
psaInstalled.pluginVersion.tcpZVT = m_pluginVersionTcpZvt;
|
2023-07-14 13:32:00 +02:00
|
|
|
|
2023-08-02 15:50:04 +02:00
|
|
|
psaInstalled.cash.name = "DC2C_cash.json";
|
|
|
|
absPathName = QDir::cleanPath(printSysDir + QDir::separator() + psaInstalled.cash.name);
|
|
|
|
psaInstalled.cash.blob = m_gc.gitBlob(absPathName);
|
|
|
|
psaInstalled.cash.size = getFileSize(absPathName);
|
2023-07-14 13:32:00 +02:00
|
|
|
|
2023-08-02 15:50:04 +02:00
|
|
|
psaInstalled.conf.name = "DC2C_conf.json";
|
|
|
|
absPathName = QDir::cleanPath(printSysDir + QDir::separator() + psaInstalled.conf.name);
|
|
|
|
psaInstalled.conf.blob = m_gc.gitBlob(absPathName);
|
|
|
|
psaInstalled.conf.size = getFileSize(absPathName);
|
2023-07-19 16:42:18 +02:00
|
|
|
|
2023-08-02 15:50:04 +02:00
|
|
|
psaInstalled.device.name = "DC2C_device.json";
|
|
|
|
absPathName = QDir::cleanPath(printSysDir + QDir::separator() + psaInstalled.device.name);
|
|
|
|
psaInstalled.device.blob = m_gc.gitBlob(absPathName);
|
|
|
|
psaInstalled.device.size = getFileSize(absPathName);
|
2023-07-19 16:42:18 +02:00
|
|
|
|
2023-08-02 15:50:04 +02:00
|
|
|
for (int i=0; i < 32; ++i) {
|
|
|
|
QString const &n = QString("%1").arg(i+1).rightJustified(2, '0');
|
|
|
|
psaInstalled.print[i].name = QString("DC2C_print%1.json").arg(n);
|
|
|
|
absPathName = QDir::cleanPath(printSysDir + QDir::separator() + psaInstalled.print[i].name);
|
|
|
|
psaInstalled.print[i].blob = m_gc.gitBlob(absPathName);
|
|
|
|
psaInstalled.print[i].size = getFileSize(absPathName);
|
|
|
|
}
|
|
|
|
|
|
|
|
return psaInstalled;
|
2023-07-11 16:58:49 +02:00
|
|
|
}
|
|
|
|
|
2023-07-19 16:42:18 +02:00
|
|
|
/************************************************************************************************
|
|
|
|
* operators
|
|
|
|
*/
|
|
|
|
QDebug operator<< (QDebug debug, UpdateStatus status) {
|
|
|
|
switch(status.m_updateStatus) {
|
2023-08-16 12:41:42 +02:00
|
|
|
case UPDATE_STATUS::ISMAS_SEND_LAST_VERSION_FAILED:
|
|
|
|
debug << QString("UPDATE_STATUS::ISMAS_SEND_LAST_VERSION_FAILED: ")
|
|
|
|
<< status.m_statusDescription;
|
|
|
|
break;
|
|
|
|
case UPDATE_STATUS::SAVE_LOG_FILES_FAILED:
|
|
|
|
debug << QString("UPDATE_STATUS::SAVE_LOG_FILES_FAILED: ")
|
|
|
|
<< status.m_statusDescription;
|
|
|
|
break;
|
|
|
|
case UPDATE_STATUS::GIT_CHECK_FILES_TO_UPDATE_SUCCESS:
|
|
|
|
debug << QString("UPDATE_STATUS::GIT_CHECK_FILES_TO_UPDATE_SUCCESS: ")
|
|
|
|
<< status.m_statusDescription;
|
|
|
|
break;
|
|
|
|
case UPDATE_STATUS::PSA_UPDATE_FILES_FAILED:
|
|
|
|
debug << QString("UPDATE_STATUS::PSA_UPDATE_FILES_FAILED: ")
|
|
|
|
<< status.m_statusDescription;
|
|
|
|
break;
|
|
|
|
case UPDATE_STATUS::RSYNC_UPDATES_SUCCESS:
|
|
|
|
debug << QString("UPDATE_STATUS::RSYNC_UPDATES_SUCCESS: ")
|
|
|
|
<< status.m_statusDescription;
|
|
|
|
break;
|
|
|
|
case UPDATE_STATUS::RSYNC_UPDATES_FAILURE:
|
|
|
|
debug << QString("UPDATE_STATUS::RSYNC_UPDATES_FAILURE: ")
|
|
|
|
<< status.m_statusDescription;
|
|
|
|
break;
|
|
|
|
case UPDATE_STATUS::EXEC_OPKG_COMMAND:
|
|
|
|
debug << QString("UPDATE_STATUS::EXEC_OPKG_COMMAND: ")
|
|
|
|
<< status.m_statusDescription;
|
|
|
|
break;
|
|
|
|
case UPDATE_STATUS::GIT_CLONE_AND_CHECKOUT_SUCCESS:
|
|
|
|
debug << QString("UPDATE_STATUS::GIT_CLONE_AND_CHECKOUT_SUCCESS: ")
|
|
|
|
<< status.m_statusDescription;
|
|
|
|
break;
|
|
|
|
case UPDATE_STATUS::GIT_CLONE_AND_CHECKOUT_FAILURE:
|
|
|
|
debug << QString("UPDATE_STATUS::GIT_CLONE_AND_CHECKOUT_FAILURE: ")
|
|
|
|
<< status.m_statusDescription;
|
|
|
|
break;
|
|
|
|
case UPDATE_STATUS::NOT_DEFINED:
|
|
|
|
debug << QString("UPDATE_STATUS::NOT_DEFINED: ")
|
|
|
|
<< status.m_statusDescription;
|
|
|
|
break;
|
|
|
|
case UPDATE_STATUS::UPDATE_PROCESS_FAILURE:
|
|
|
|
debug << QString("UPDATE_STATUS::UPDATE_PROCESS_FAILURE: ")
|
|
|
|
<< status.m_statusDescription;
|
|
|
|
break;
|
|
|
|
case UPDATE_STATUS::ISMAS_UPDATE_TRIGGER_SET_FAILURE:
|
|
|
|
debug << QString("UPDATE_STATUS::ISMAS_UPDATE_TRIGGER_FAILURE: ")
|
|
|
|
<< status.m_statusDescription;
|
|
|
|
break;
|
|
|
|
case UPDATE_STATUS::GIT_CHECKOUT_BRANCH_FAILURE:
|
|
|
|
debug << QString("UPDATE_STATUS::GIT_CHECKOUT_BRANCH_FAILURE: ")
|
|
|
|
<< status.m_statusDescription;
|
|
|
|
break;
|
|
|
|
case UPDATE_STATUS::GIT_CHECKOUT_BRANCH:
|
|
|
|
debug << QString("UPDATE_STATUS::GIT_CHECKOUT_BRANCH: ")
|
|
|
|
<< status.m_statusDescription;
|
|
|
|
break;
|
|
|
|
case UPDATE_STATUS::ISMAS_UPDATE_TRIGGER_NOT_SET_OR_WRONG:
|
|
|
|
debug << QString("UPDATE_STATUS::ISMAS_UPDATE_TRIGGER_NOT_SET_OR_WRONG: ")
|
|
|
|
<< status.m_statusDescription;
|
|
|
|
break;
|
|
|
|
case UPDATE_STATUS::ISMAS_UPDATE_TRIGGER_SET:
|
|
|
|
debug << QString("UPDATE_STATUS::ISMAS_UPDATE_TRIGGER_SET: ")
|
|
|
|
<< status.m_statusDescription;
|
|
|
|
break;
|
|
|
|
case UPDATE_STATUS::ISMAS_SANITY_CHECK_OK:
|
|
|
|
debug << QString("UPDATE_STATUS::ISMAS_SANITY_CHECK_OK: ")
|
|
|
|
<< status.m_statusDescription;
|
|
|
|
break;
|
|
|
|
case UPDATE_STATUS::JSON_PARSE_FAILURE:
|
|
|
|
debug << QString("UPDATE_STATUS::JSON_PARSE_FAILURE: ")
|
|
|
|
<< status.m_statusDescription;
|
|
|
|
break;
|
|
|
|
case UPDATE_STATUS::BACKEND_CHECK:
|
|
|
|
debug << QString("UPDATE_STATUS::BACKEND_CHECK: ")
|
|
|
|
<< status.m_statusDescription;
|
|
|
|
break;
|
|
|
|
case UPDATE_STATUS::BACKEND_CHECK_FAILURE:
|
|
|
|
debug << QString("UPDATE_STATUS::BACKEND_CHECK_FAILURE: ")
|
|
|
|
<< status.m_statusDescription;
|
|
|
|
break;
|
|
|
|
case UPDATE_STATUS::BACKEND_NOT_CONNECTED:
|
|
|
|
debug << QString("UPDATE_STATUS::BACKEND_NOT_CONNECTED: ")
|
|
|
|
<< status.m_statusDescription;
|
|
|
|
break;
|
2023-08-02 15:50:04 +02:00
|
|
|
case UPDATE_STATUS::UPDATE_PROCESS_SUCCESS:
|
|
|
|
debug << QString("UPDATE_STATUS::UPDATE_PROCESS_SUCCESS: ")
|
2023-07-19 16:42:18 +02:00
|
|
|
<< status.m_statusDescription;
|
|
|
|
break;
|
2023-08-02 15:50:04 +02:00
|
|
|
case UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_PENDING:
|
|
|
|
debug << QString("UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_PENDING: ")
|
|
|
|
<< status.m_statusDescription;
|
|
|
|
break;
|
|
|
|
case UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_FAILURE:
|
|
|
|
debug << QString("UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_FAILURE: ")
|
|
|
|
<< status.m_statusDescription;
|
|
|
|
break;
|
|
|
|
case UPDATE_STATUS::GIT_FETCH_UPDATES:
|
|
|
|
debug << QString("UPDATE_STATUS::GIT_FETCH_UPDATES: ")
|
2023-07-19 16:42:18 +02:00
|
|
|
<< status.m_statusDescription;
|
|
|
|
break;
|
|
|
|
case UPDATE_STATUS::GIT_FETCH_UPDATES_REQUEST_FAILURE:
|
|
|
|
debug << QString("UPDATE_STATUS::GIT_FETCH_UPDATES_REQUEST_FAILURE: ")
|
|
|
|
<< status.m_statusDescription;
|
|
|
|
break;
|
|
|
|
case UPDATE_STATUS::ISMAS_RESPONSE_RECEIVED:
|
|
|
|
debug << QString("UPDATE_STATUS::ISMAS_RESPONSE_RECEIVED: ")
|
|
|
|
<< status.m_statusDescription;
|
|
|
|
break;
|
2023-08-23 16:26:55 +02:00
|
|
|
case UPDATE_STATUS::RSYNC_FILE_SUCCESS:
|
|
|
|
debug << QString("UPDATE_STATUS::RSYNC_FILE_SUCCESS: ")
|
|
|
|
<< status.m_statusDescription;
|
|
|
|
break;
|
2023-07-19 16:42:18 +02:00
|
|
|
case UPDATE_STATUS::EXEC_OPKG_COMMANDS:
|
|
|
|
debug << QString("UPDATE_STATUS::EXEC_OPKG_COMMANDS: ")
|
|
|
|
<< status.m_statusDescription;
|
|
|
|
break;
|
2023-08-16 12:41:42 +02:00
|
|
|
// default:;
|
2023-07-19 16:42:18 +02:00
|
|
|
}
|
|
|
|
return debug;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString& operator<< (QString& str, UpdateStatus status) {
|
|
|
|
switch(status.m_updateStatus) {
|
2023-08-16 12:41:42 +02:00
|
|
|
case UPDATE_STATUS::ISMAS_SEND_LAST_VERSION_FAILED:
|
|
|
|
str = QString("UPDATE_STATUS::ISMAS_SEND_LAST_VERSION_FAILED: ");
|
|
|
|
str += status.m_statusDescription;
|
|
|
|
break;
|
|
|
|
case UPDATE_STATUS::SAVE_LOG_FILES_FAILED:
|
|
|
|
str = QString("UPDATE_STATUS::SAVE_LOG_FILES_FAILED: ");
|
|
|
|
str += status.m_statusDescription;
|
|
|
|
break;
|
|
|
|
case UPDATE_STATUS::GIT_CHECK_FILES_TO_UPDATE_SUCCESS:
|
|
|
|
str = QString("UPDATE_STATUS::GIT_CHECK_FILES_TO_UPDATE_SUCCESS: ");
|
|
|
|
str += status.m_statusDescription;
|
|
|
|
break;
|
|
|
|
case UPDATE_STATUS::PSA_UPDATE_FILES_FAILED:
|
|
|
|
str = QString("UPDATE_STATUS::PSA_UPDATE_FILES_FAILED: ");
|
|
|
|
str += status.m_statusDescription;
|
|
|
|
break;
|
|
|
|
case UPDATE_STATUS::RSYNC_UPDATES_SUCCESS:
|
|
|
|
str = QString("UPDATE_STATUS::RSYNC_UPDATES_SUCCESS: ");
|
|
|
|
str += status.m_statusDescription;
|
|
|
|
break;
|
|
|
|
case UPDATE_STATUS::RSYNC_UPDATES_FAILURE:
|
|
|
|
str = QString("UPDATE_STATUS::RSYNC_UPDATES_FAILURE: ");
|
|
|
|
str += status.m_statusDescription;
|
|
|
|
break;
|
|
|
|
case UPDATE_STATUS::EXEC_OPKG_COMMAND:
|
|
|
|
str = QString("UPDATE_STATUS::EXEC_OPKG_COMMAND: ");
|
|
|
|
str += status.m_statusDescription;
|
|
|
|
break;
|
|
|
|
case UPDATE_STATUS::GIT_CLONE_AND_CHECKOUT_SUCCESS:
|
|
|
|
str = QString("UPDATE_STATUS::GIT_CLONE_AND_CHECKOUT_SUCCESS: ");
|
|
|
|
str += status.m_statusDescription;
|
|
|
|
break;
|
|
|
|
case UPDATE_STATUS::GIT_CLONE_AND_CHECKOUT_FAILURE:
|
|
|
|
str = QString("UPDATE_STATUS::GIT_CLONE_AND_CHECKOUT_FAILURE: ");
|
|
|
|
str += status.m_statusDescription;
|
|
|
|
break;
|
|
|
|
case UPDATE_STATUS::NOT_DEFINED:
|
|
|
|
str = QString("UPDATE_STATUS::NOT_DEFINED: ");
|
|
|
|
str += status.m_statusDescription;
|
|
|
|
break;
|
|
|
|
case UPDATE_STATUS::UPDATE_PROCESS_FAILURE:
|
|
|
|
str = QString("UPDATE_STATUS::UPDATE_PROCESS_FAILURE: ");
|
|
|
|
str += status.m_statusDescription;
|
|
|
|
break;
|
|
|
|
case UPDATE_STATUS::ISMAS_UPDATE_TRIGGER_SET_FAILURE:
|
|
|
|
str = QString("UPDATE_STATUS::ISMAS_UPDATE_TRIGGER_FAILURE: ");
|
|
|
|
str += status.m_statusDescription;
|
|
|
|
break;
|
|
|
|
case UPDATE_STATUS::GIT_CHECKOUT_BRANCH_FAILURE:
|
|
|
|
str = QString("UPDATE_STATUS::GIT_CHECKOUT_BRANCH_FAILURE: ");
|
|
|
|
str += status.m_statusDescription;
|
|
|
|
break;
|
|
|
|
case UPDATE_STATUS::GIT_CHECKOUT_BRANCH:
|
|
|
|
str = QString("UPDATE_STATUS::GIT_CHECKOUT_BRANCH: ");
|
|
|
|
str += status.m_statusDescription;
|
|
|
|
break;
|
|
|
|
case UPDATE_STATUS::ISMAS_UPDATE_TRIGGER_NOT_SET_OR_WRONG:
|
|
|
|
str = QString("UPDATE_STATUS::ISMAS_UPDATE_TRIGGER_NOT_SET_OR_WRONG: ");
|
|
|
|
str += status.m_statusDescription;
|
|
|
|
break;
|
|
|
|
case UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_FAILURE:
|
|
|
|
str = QString("UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_FAILURE: ");
|
|
|
|
str += status.m_statusDescription;
|
|
|
|
break;
|
|
|
|
case UPDATE_STATUS::ISMAS_UPDATE_TRIGGER_SET:
|
|
|
|
str = QString("UPDATE_STATUS::ISMAS_UPDATE_TRIGGER_SET: ");
|
|
|
|
str += status.m_statusDescription;
|
|
|
|
break;
|
|
|
|
case UPDATE_STATUS::ISMAS_SANITY_CHECK_OK:
|
|
|
|
str = QString("UPDATE_STATUS::ISMAS_SANITY_CHECK_OK: ");
|
|
|
|
str += status.m_statusDescription;
|
|
|
|
break;
|
|
|
|
case UPDATE_STATUS::JSON_PARSE_FAILURE:
|
|
|
|
str = QString("UPDATE_STATUS::JSON_PARSE_FAILURE: ");
|
|
|
|
str += status.m_statusDescription;
|
|
|
|
break;
|
|
|
|
case UPDATE_STATUS::BACKEND_CHECK:
|
|
|
|
str = QString("UPDATE_STATUS::BACKEND_CHECK: ");
|
|
|
|
str += status.m_statusDescription;
|
|
|
|
break;
|
|
|
|
case UPDATE_STATUS::BACKEND_CHECK_FAILURE:
|
|
|
|
str = QString("UPDATE_STATUS::BACKEND_CHECK_FAILURE: ");
|
|
|
|
str += status.m_statusDescription;
|
|
|
|
break;
|
|
|
|
case UPDATE_STATUS::BACKEND_NOT_CONNECTED:
|
|
|
|
str = QString("UPDATE_STATUS::BACKEND_NOT_CONNECTED: ");
|
|
|
|
str += status.m_statusDescription;
|
|
|
|
break;
|
2023-08-02 15:50:04 +02:00
|
|
|
case UPDATE_STATUS::UPDATE_PROCESS_SUCCESS:
|
|
|
|
str = QString("UPDATE_STATUS::UPDATE_PROCESS_SUCCESS: ");
|
|
|
|
str += status.m_statusDescription;
|
|
|
|
break;
|
|
|
|
case UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_PENDING:
|
|
|
|
str = QString("UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_PENDING: ");
|
2023-07-19 16:42:18 +02:00
|
|
|
str += status.m_statusDescription;
|
|
|
|
break;
|
2023-08-02 15:50:04 +02:00
|
|
|
case UPDATE_STATUS::GIT_FETCH_UPDATES:
|
|
|
|
str = QString("UPDATE_STATUS::GIT_FETCH_UPDATES: ");
|
2023-07-19 16:42:18 +02:00
|
|
|
str += status.m_statusDescription;
|
|
|
|
break;
|
|
|
|
case UPDATE_STATUS::GIT_FETCH_UPDATES_REQUEST_FAILURE:
|
|
|
|
str = QString("UPDATE_STATUS::GIT_FETCH_UPDATES_REQUEST_FAILURE: ");
|
|
|
|
str += status.m_statusDescription;
|
|
|
|
break;
|
|
|
|
case UPDATE_STATUS::ISMAS_RESPONSE_RECEIVED:
|
|
|
|
str = QString("UPDATE_STATUS::ISMAS_RESPONSE_RECEIVED: ");
|
|
|
|
str += status.m_statusDescription;
|
|
|
|
break;
|
|
|
|
case UPDATE_STATUS::EXEC_OPKG_COMMANDS:
|
|
|
|
str = QString("UPDATE_STATUS::EXEC_OPKG_COMMANDS: ");
|
|
|
|
str += status.m_statusDescription;
|
|
|
|
break;
|
2023-08-23 16:26:55 +02:00
|
|
|
case UPDATE_STATUS::RSYNC_FILE_SUCCESS:
|
|
|
|
str = QString("UPDATE_STATUS::RSYNC_FILE_SUCCESS: ");
|
|
|
|
str += status.m_statusDescription;
|
|
|
|
break;
|
2023-08-16 12:41:42 +02:00
|
|
|
//default:;
|
2023-07-19 16:42:18 +02:00
|
|
|
}
|
|
|
|
return str;
|
|
|
|
}
|