Compare commits

...

19 Commits

Author SHA1 Message Date
769626581f Use head -n 1 in gitLastCommit(). 2023-08-11 11:12:59 +02:00
0e97ce7dc2 Take the pipe symbol into account in output of git getch command. 2023-08-11 11:12:09 +02:00
34334676fc Use print-utis from utils.h. 2023-08-11 11:11:14 +02:00
853787cd4b Added lastCommit to tariff-struct. Added jsonParseFailed(). 2023-08-11 11:09:51 +02:00
a932ed5471 Hide button on error message box. 2023-08-11 11:07:16 +02:00
c338884fc7 Use print-util in utils.h. 2023-08-11 11:06:38 +02:00
ed6df98653 Set progress bar timer to 500ms.
Yield thread to give worker thread its share of CPU time.
2023-08-11 11:05:33 +02:00
9eb458c4c5 Start Application after 1 second delay. 2023-08-11 11:05:02 +02:00
202e83268b Added utilities
void printCriticalErrorMsg(QString const &errorMsg);
    void printInfoMsg(QString const &infoMsg);
    void printLineEditInfo(QStringList const &lines);
    QString getTariffLoadTime(QString fileName);
2023-08-11 11:03:21 +02:00
8f26bfee0f Get last commit date and loadtime of tariff-file. 2023-08-11 11:02:15 +02:00
1af136e39d Set delay when trying to fetch value of update-trigger. 2023-08-11 11:01:26 +02:00
a550d55004 Get triggerValue directly from JSON. 2023-08-11 11:00:52 +02:00
a37a22d3f9 Show message boxes when running UpdateTool manually. 2023-08-11 11:00:02 +02:00
a8941f4ef4 Set progress values. 2023-08-11 10:59:26 +02:00
746565dbe0 Add messages sent to ISMAS. 2023-08-11 10:58:29 +02:00
79906df12e Add some qt debug aoutput. 2023-08-11 10:56:36 +02:00
edf1d105e7 Deactivate backendConnected(). 2023-08-11 10:55:53 +02:00
6c4b02cb56 Use print-utils to print some debug messages. 2023-08-11 10:52:31 +02:00
04d5061d79 Added some constants. 2023-08-11 10:49:34 +02:00
8 changed files with 462 additions and 249 deletions

View File

@ -48,9 +48,7 @@ bool GitClient::gitCloneCustomerRepository() {
} }
} }
} }
qCritical() << QString(80, '*'); Utils::printCriticalErrorMsg(QString("ERROR CLONE RESULT HAS WRONG FORMAT. CLONE_RESULT=") + result);
qCritical() << "ERROR CLONE RESULT HAS WRONG FORMAT. CLONE_RESULT=" << result;
qCritical() << QString(80, '*');
} }
return false; return false;
} }
@ -97,9 +95,7 @@ bool GitClient::gitCheckoutBranch() {
Command c(gitCommand); Command c(gitCommand);
return c.execute(m_customerRepository); // execute command in customerRepo return c.execute(m_customerRepository); // execute command in customerRepo
} }
qCritical() << QString(80, '*'); Utils::printCriticalErrorMsg(QString("ERROR ") + m_customerRepository + " DOES NOT EXIST");
qCritical() << "ERROR" << m_customerRepository << "DOES NOT EXIST";
qCritical() << QString(80, '*');
return false; return false;
} }
@ -113,11 +109,8 @@ bool GitClient::gitCloneAndCheckoutBranch() {
// TODO // TODO
} }
//} //}
} else {
qCritical() << QString(80, '*');
qInfo() << "CLONE" << m_repositoryPath << "AND CHECKOUT FAILED";
qCritical() << QString(80, '*');
} }
Utils::printCriticalErrorMsg(QString("CLONE ") + m_repositoryPath + " AND CHECKOUT FAILED");
return false; return false;
} }
@ -134,12 +127,9 @@ std::optional<QStringList> GitClient::gitDiff(QString const &commits) {
Command c(gitCommand); Command c(gitCommand);
if (c.execute(m_customerRepository)) { // execute command in local customerRepo if (c.execute(m_customerRepository)) { // execute command in local customerRepo
QString s = c.getCommandResult().trimmed(); QString s = c.getCommandResult().trimmed();
Utils::printInfoMsg("GIT DIFF RESULT " + s);
QStringList lines = Update::split(s, '\n'); QStringList lines = Update::split(s, '\n');
qInfo() << QString(80, '*');
qInfo() << "GIT DIFF RESULT" << lines;
qInfo() << QString(80, '*');
QStringList fileNames; QStringList fileNames;
// each line has the format "etc/psa_config/DC2C_print01.json | 1 + // each line has the format "etc/psa_config/DC2C_print01.json | 1 +
// or the format "etc/psa_config/DC2C_print01.json (new) | 1 + // or the format "etc/psa_config/DC2C_print01.json (new) | 1 +
@ -149,7 +139,7 @@ std::optional<QStringList> GitClient::gitDiff(QString const &commits) {
int newIndex = line.indexOf("(new"); // for new files int newIndex = line.indexOf("(new"); // for new files
int goneIndex = line.indexOf("(gone"); // for removed files int goneIndex = line.indexOf("(gone"); // for removed files
int modeIndex = line.indexOf("(mode"); int modeIndex = line.indexOf("(mode");
// int pipeIndex = line.indexOf('|'); int pipeIndex = line.indexOf('|');
if (newIndex != -1) { if (newIndex != -1) {
QString file = line.left(newIndex).trimmed(); QString file = line.left(newIndex).trimmed();
qInfo() << "FILE (NEW)" << file; qInfo() << "FILE (NEW)" << file;
@ -160,16 +150,14 @@ std::optional<QStringList> GitClient::gitDiff(QString const &commits) {
qInfo() << "FILE (MODE)" << file; qInfo() << "FILE (MODE)" << file;
fileNames << file; fileNames << file;
} else } else
//if (pipeIndex != -1) {
// QString const file = line.left(pipeIndex).trimmed();
// qInfo() << "FILE (PIPE)" << file;
// fileNames << file;
//} else
if (goneIndex != -1) { if (goneIndex != -1) {
QString const file = line.left(goneIndex).trimmed(); QString const file = line.left(goneIndex).trimmed();
qCritical() << QString(80, '*');
qCritical() << "FILE (GONE)" << file; qCritical() << "FILE (GONE)" << file;
qCritical() << QString(80, '*'); } else
if (pipeIndex != -1) {
QString const file = line.left(pipeIndex).trimmed();
qInfo() << "FILE (PIPE)" << file;
fileNames << file;
} }
} }
if (!fileNames.isEmpty()) { if (!fileNames.isEmpty()) {
@ -185,9 +173,7 @@ std::optional<QStringList> GitClient::gitDiff(QString const &commits) {
*/ */
std::optional<QString> GitClient::gitFetch() { std::optional<QString> GitClient::gitFetch() {
if (QDir(m_customerRepository).exists()) { if (QDir(m_customerRepository).exists()) {
qCritical() << QString(80, '*');
qInfo() << "BRANCH NAME" << m_branchName; qInfo() << "BRANCH NAME" << m_branchName;
qCritical() << QString(80, '*');
Command c("git fetch"); Command c("git fetch");
if (c.execute(m_customerRepository)) { if (c.execute(m_customerRepository)) {
@ -221,38 +207,28 @@ std::optional<QString> GitClient::gitFetch() {
} else { } else {
emit m_worker->showErrorMessage("git fetch", emit m_worker->showErrorMessage("git fetch",
"no regex-match for commits"); "no regex-match for commits");
qCritical() << QString(80, '*'); Utils::printCriticalErrorMsg("NO REGEX MATCH FOR COMMITS");
qCritical() << "NO REGEX MATCH FOR COMMITS";
qCritical() << QString(80, '*');
} }
} }
} }
if (!found) { if (!found) {
emit m_worker->showErrorMessage("git fetch", emit m_worker->showErrorMessage("git fetch",
QString("unkown branch name ") + m_branchName); QString("unkown branch name ") + m_branchName);
qCritical() << QString(80, '*'); Utils::printCriticalErrorMsg("UNKNOWN BRANCH NAME " + m_branchName);
qCritical() << "UNKNOWN BRANCH NAME" << m_branchName;
qCritical() << QString(80, '*');
} }
} else { } else {
emit m_worker->showErrorMessage("git fetch", emit m_worker->showErrorMessage("git fetch",
QString("wrong format for result of 'git fetch' ") + s); QString("wrong format for result of 'git fetch' ") + s);
qCritical() << QString(80, '*'); Utils::printCriticalErrorMsg(QString("WRONG FORMAT FOR RESULT OF 'GIT FETCH' ") + s);
qCritical() << "WRONG FORMAT FOR RESULT OF 'GIT FETCH'" << s;
qCritical() << QString(80, '*');
} }
} else { } else {
emit m_worker->showErrorMessage("git fetch", "empty result for 'git fetch'"); emit m_worker->showErrorMessage("git fetch", "empty result for 'git fetch'");
qCritical() << QString(80, '*'); Utils::printCriticalErrorMsg("EMPTY RESULT FOR 'GIT FETCH'");
qCritical() << "EMPTY RESULT FOR 'GIT FETCH'";
qCritical() << QString(80, '*');
} }
} }
} else { } else {
emit m_worker->showErrorMessage("git fetch", QString("repository ") + m_customerRepository + " does not exist"); emit m_worker->showErrorMessage("git fetch", QString("repository ") + m_customerRepository + " does not exist");
qCritical() << QString(80, '*'); Utils::printCriticalErrorMsg(QString("REPOSITORY ") + m_customerRepository + " DOES NOT EXIST");
qCritical() << "REPOSITORY" << m_customerRepository << "DOES NOT EXIST";
qCritical() << QString(80, '*');
} }
return std::nullopt; return std::nullopt;
} }
@ -273,9 +249,7 @@ bool GitClient::gitPull() {
qInfo() << "PULLED INTO" << m_customerRepository; qInfo() << "PULLED INTO" << m_customerRepository;
return true; return true;
} }
qCritical() << QString(80, '*'); Utils::printCriticalErrorMsg(QString("PULL INTO " + m_customerRepository + " FAILED"));
qCritical() << "PULL INTO" << m_customerRepository << "FAILED";
qCritical() << QString(80, '*');
} }
return false; return false;
} }
@ -294,6 +268,7 @@ QString GitClient::gitLastCommit(QString fileName) {
if (QDir(m_customerRepository).exists()) { if (QDir(m_customerRepository).exists()) {
QString const filePath QString const filePath
= QDir::cleanPath(m_customerRepository + QDir::separator() + fileName); = QDir::cleanPath(m_customerRepository + QDir::separator() + fileName);
if (QFile(filePath).exists()) {
QString const gitCommand = QString("git log %1 | head -n 1").arg(fileName); QString const gitCommand = QString("git log %1 | head -n 1").arg(fileName);
Command c("bash"); Command c("bash");
if (c.execute(m_customerRepository, QStringList() << "-c" << gitCommand)) { if (c.execute(m_customerRepository, QStringList() << "-c" << gitCommand)) {
@ -304,6 +279,7 @@ QString GitClient::gitLastCommit(QString fileName) {
} }
} }
} }
}
return ""; return "";
} }

View File

@ -753,11 +753,21 @@ QString IsmasClient::sanityCheckFailed(int resultCode, QString reason, QString c
version.toStdString().c_str()); version.toStdString().c_str());
} }
QString IsmasClient::updateOfPSAFailed(int resultCode, QString reason, QString const &version) { QString IsmasClient::jsonParseFailed(int resultCode, QString reason, QString const &version) {
return updateNewsToIsmas("U0003", return updateNewsToIsmas("U0003",
m_progressInPercent, m_progressInPercent,
resultCode, resultCode,
"UPDATE ERROR", "JSON-PARSE-ERROR",
reason.toStdString().c_str(),
version.toStdString().c_str());
}
QString IsmasClient::updateOfPSAFailed(int resultCode, QString step,
QString reason, QString const &version) {
return updateNewsToIsmas("U0003",
m_progressInPercent,
resultCode,
step.toStdString().c_str(),
reason.toStdString().c_str(), reason.toStdString().c_str(),
version.toStdString().c_str()); version.toStdString().c_str());
} }

View File

@ -12,6 +12,7 @@ struct PSAInstalled {
int zone; int zone;
int size; int size;
QString blob; QString blob;
QString lastCommit;
QString info; QString info;
QString loadTime; QString loadTime;
} tariff; } tariff;
@ -155,8 +156,9 @@ public:
// and update accepted // and update accepted
QString updateOfPSASucceeded(QString const &version = QString()); // update process succeeded QString updateOfPSASucceeded(QString const &version = QString()); // update process succeeded
QString updateOfPSAContinues(QString currentStage, QString currentStageInfo, QString const &version = QString()); QString updateOfPSAContinues(QString currentStage, QString currentStageInfo, QString const &version = QString());
QString updateOfPSAFailed(int resultCode, QString reason, QString const &version = QString()); QString updateOfPSAFailed(int resultCode, QString step, QString reason, QString const &version = QString());
QString sanityCheckFailed(int resultCode, QString reason, QString const &version = QString()); QString sanityCheckFailed(int resultCode, QString reason, QString const &version = QString());
QString jsonParseFailed(int resultCode, QString reason, QString const &version = QString());
QString updateOfPSASendVersion(PSAInstalled const &psa); QString updateOfPSASendVersion(PSAInstalled const &psa);

View File

@ -33,10 +33,9 @@ MainWindow::MainWindow(Worker *worker, QWidget *parent)
ui->updateStatus->setEnabled(true); ui->updateStatus->setEnabled(true);
m_startTimer = new QTimer(this); m_startTimer = new QTimer(this);
// connect(m_startTimer, SIGNAL(timeout()), ui->start, SLOT(click()));
connect(m_startTimer, SIGNAL(timeout()), m_worker, SLOT(update())); connect(m_startTimer, SIGNAL(timeout()), m_worker, SLOT(update()));
m_startTimer->setSingleShot(true); m_startTimer->setSingleShot(true);
m_startTimer->start(5 * 1000); m_startTimer->start(1000);
m_exitTimer = new QTimer(this); m_exitTimer = new QTimer(this);
connect(m_exitTimer, SIGNAL(timeout()), ui->exit, SLOT(click())); connect(m_exitTimer, SIGNAL(timeout()), ui->exit, SLOT(click()));
@ -88,7 +87,7 @@ void MainWindow::customEvent(QEvent *event) {
m_progressValue = progress; m_progressValue = progress;
ui->updateProgress->setValue(progress/10); ui->updateProgress->setValue(progress/10);
QApplication::postEvent(this, new ProgressEvent(this, progress+10)); QApplication::postEvent(this, new ProgressEvent(this, progress+10));
QThread::msleep(100); QThread::msleep(500);
} }
} }
} }
@ -111,6 +110,8 @@ void MainWindow::customEvent(QEvent *event) {
qCritical() << "!!! UNKNOWN SENDER !!!"; qCritical() << "!!! UNKNOWN SENDER !!!";
} }
} }
QThread::yieldCurrentThread();
} }
void MainWindow::onStopStartTimer() { void MainWindow::onStopStartTimer() {
@ -149,10 +150,7 @@ void MainWindow::onAppendText(QString text, QString suffix) {
editText += text.leftJustified(m_width-9); editText += text.leftJustified(m_width-9);
} }
QStringList const lines = editText.split('\n'); Utils::printLineEditInfo(editText.split('\n'));
for (int i=0; i<lines.size(); ++i) {
qInfo() << lines.at(i);
} qInfo() << ""; qInfo() << "";
ui->updateStatus->setPlainText(editText.trimmed()); ui->updateStatus->setPlainText(editText.trimmed());
ui->updateStatus->setEnabled(true); ui->updateStatus->setEnabled(true);
@ -172,21 +170,20 @@ void MainWindow::onReplaceLast(QString text, QString suffix) {
} }
} }
for (int i=0; i<lines.size(); ++i) { Utils::printLineEditInfo(lines);
qInfo() << lines.at(i);
} qInfo() << ""; qInfo() << "";
ui->updateStatus->setText(lines.join('\n').trimmed()); ui->updateStatus->setText(lines.join('\n').trimmed());
ui->updateStatus->setEnabled(true); ui->updateStatus->setEnabled(true);
} }
void MainWindow::onShowErrorMessage(QString title, QString text) { void MainWindow::onShowErrorMessage(QString title, QString text) {
text = text.leftJustified(50, ' '); text = text.leftJustified(50, ' ');
QMessageBox msgBox(QMessageBox::NoIcon, title, QMessageBox msgBox(QMessageBox::NoIcon, title,
text, QMessageBox::Ok, text, QMessageBox::Ok,
nullptr, Qt::FramelessWindowHint); nullptr, Qt::FramelessWindowHint);
msgBox.setDefaultButton(QMessageBox::Ok); msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.setStyleSheet("QDialog {background-color: red;}" msgBox.defaultButton()->setVisible(false);
"QPushButton {background-color: blue;}");
QTimer *t = new QTimer(this); QTimer *t = new QTimer(this);
connect(t, SIGNAL(timeout()), msgBox.defaultButton(), SLOT(click())); connect(t, SIGNAL(timeout()), msgBox.defaultButton(), SLOT(click()));
t->setSingleShot(true); t->setSingleShot(true);
@ -197,5 +194,4 @@ void MainWindow::onShowErrorMessage(QString title, QString text) {
} else { } else {
// do something else // do something else
} }
disconnect(t, SIGNAL(timeout()), msgBox.defaultButton(), SLOT(click()));
} }

View File

@ -1,8 +1,9 @@
#include "utils.h" #include "utils.h"
#include "message_handler.h"
#include <QFile> #include <QFile>
#include <QTextStream> #include <QTextStream>
#include <QDebug>
int Utils::read1stLineOfFile(QString fileName) { int Utils::read1stLineOfFile(QString fileName) {
QFile f(fileName); QFile f(fileName);
@ -33,3 +34,46 @@ QString Utils::zoneName(quint8 i) {
} }
return "N/A"; return "N/A";
} }
void Utils::printCriticalErrorMsg(QString const &errorMsg) {
qCritical() << QString(80, '!');
qCritical() << errorMsg;
qCritical() << QString(80, '!');
}
void Utils::printInfoMsg(QString const &infoMsg) {
qCritical() << QString(80, '=');
qCritical() << infoMsg;
qCritical() << QString(80, '=');
}
void Utils::printLineEditInfo(QStringList const &lines) {
if (getDebugLevel() == LOG_DEBUG) {
for (int i=0; i<lines.size(); ++i) {
qInfo() << lines.at(i);
} qInfo() << ""; qInfo() << "";
}
}
QString Utils::getTariffLoadTime(QString fileName) {
QFileInfo fInfo(fileName);
if (fInfo.exists()) {
QDateTime lastModifiedTime = fInfo.lastModified();
if (lastModifiedTime.isValid()) {
return lastModifiedTime.toString(Qt::ISODateWithMs);
} else {
printCriticalErrorMsg(fileName + " HAS INVALID MODIFIED-TIME");
QDateTime birthTime = fInfo.birthTime();
if (birthTime.isValid()) {
return birthTime.toString(Qt::ISODateWithMs);
} else {
printCriticalErrorMsg(fileName + " HAS INVALID BIRTH-TIME");
}
}
} else {
printCriticalErrorMsg(fileName + " DOES NOT EXIST");
}
return "N/A";
}

View File

@ -3,11 +3,18 @@
#include <QObject> #include <QObject>
#include <QString> #include <QString>
#include <QStringList>
#include <QFile> #include <QFile>
#include <QFileInfo>
#include <QDateTime>
namespace Utils { namespace Utils {
int read1stLineOfFile(QString fileName); int read1stLineOfFile(QString fileName);
QString zoneName(quint8 i); QString zoneName(quint8 i);
void printCriticalErrorMsg(QString const &errorMsg);
void printInfoMsg(QString const &infoMsg);
void printLineEditInfo(QStringList const &lines);
QString getTariffLoadTime(QString fileName);
} }
#endif // UTILS_H_INCLUDED #endif // UTILS_H_INCLUDED

View File

@ -23,6 +23,7 @@
#include "ismas/ismas_client.h" #include "ismas/ismas_client.h"
#include "progress_event.h" #include "progress_event.h"
#include "mainwindow.h" #include "mainwindow.h"
#include "utils.h"
QString const Worker::UPDATE_STEP_OK(" [ ok]"); QString const Worker::UPDATE_STEP_OK(" [ ok]");
QString const Worker::UPDATE_STEP_DONE(" [done]"); QString const Worker::UPDATE_STEP_DONE(" [done]");
@ -67,7 +68,7 @@ Worker::Worker(hwinf *hw,
, m_ismasUpdateRequests(ISMAS_UPDATE_REQUESTS) , m_ismasUpdateRequests(ISMAS_UPDATE_REQUESTS)
, m_waitForNewUpdates(this) , m_waitForNewUpdates(this)
, m_filesToUpdate() , m_filesToUpdate()
, m_updateProcessRunning(false) , m_updateProcessRunning(true)
, m_returnCode(0) , m_returnCode(0)
, m_progressValue(0) , m_progressValue(0)
, m_withoutIsmasDirectPort(false) /* useful for testing */ { , m_withoutIsmasDirectPort(false) /* useful for testing */ {
@ -93,7 +94,7 @@ Worker::Worker(hwinf *hw,
int cnt = 0; int cnt = 0;
while (!m_workerThread.isRunning()) { while (!m_workerThread.isRunning()) {
if (++cnt > 5) { if (++cnt > 5) {
qCritical() << "starting worker thread FAILED"; Utils::printCriticalErrorMsg("starting worker thread FAILED");
return; return;
} }
QThread::sleep(1); QThread::sleep(1);
@ -106,7 +107,7 @@ Worker::~Worker() {
while (!m_workerThread.isFinished()) { while (!m_workerThread.isFinished()) {
if (!m_workerThread.wait(1000)) { if (!m_workerThread.wait(1000)) {
if (++cnt > 5) { if (++cnt > 5) {
qCritical() << "stopping worker thread FAILED"; Utils::printCriticalErrorMsg("stopping worker thread FAILED");
return; return;
} }
} }
@ -205,23 +206,7 @@ void Worker::privateUpdate() {
m_returnCode = -3; m_returnCode = -3;
} }
} else { } else {
qInfo() << "CHECKOUT BRANCH...";
emit appendText("\nInitializing customer environment ...");
startProgressLoop();
if (m_gc.gitCheckoutBranch()) {
stopProgressLoop();
emit replaceLast("Initializing customer environment ...", UPDATE_STEP_DONE);
setProgress(100);
m_ismasClient.setProgressInPercent(10); m_ismasClient.setProgressInPercent(10);
//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, ""));
qInfo() << "CHECKED OUT BRANCH";
if (backendConnected()) { if (backendConnected()) {
m_ismasClient.setProgressInPercent(20); m_ismasClient.setProgressInPercent(20);
if (updateTriggerSet()) { if (updateTriggerSet()) {
@ -229,6 +214,14 @@ void Worker::privateUpdate() {
if (customerEnvironment()) { if (customerEnvironment()) {
m_ismasClient.setProgressInPercent(40); m_ismasClient.setProgressInPercent(40);
if (filesToUpdate()) { 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); m_ismasClient.setProgressInPercent(50);
if (updateFiles(50)) { if (updateFiles(50)) {
m_ismasClient.setProgressInPercent(60); m_ismasClient.setProgressInPercent(60);
@ -252,30 +245,83 @@ void Worker::privateUpdate() {
m_returnCode = 0; m_returnCode = 0;
} else { } else {
m_returnCode = -12; m_updateStatus = UpdateStatus(UPDATE_STATUS::SAVE_LOG_FILES_FAILED,
} QString("Saving log files failed"));
} else { 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; m_returnCode = -11;
} }
} else { } 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; m_returnCode = -10;
} }
} else { } 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; m_returnCode = -9;
} }
} else { } 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; m_returnCode = -8;
} }
} else { } 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; m_returnCode = -7;
} }
} else { } else {
m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_CHECKOUT_BRANCH_REQUEST_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; m_returnCode = -6;
} }
} else { } 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_returnCode = -5;
} }
} else { } else {
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_BACKEND_CHECK_FAILURE,
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));
m_returnCode = -4; m_returnCode = -4;
} }
} }
@ -301,12 +347,14 @@ void Worker::privateUpdate() {
} }
bool Worker::backendConnected() { bool Worker::backendConnected() {
if (m_withoutIsmasDirectPort) { // useful for testing // 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; return true;
}
emit appendText("\nConnecting backend ..."); emit appendText("\nConnecting backend ...");
if (false) { // so linker removes dead code
for (int repeat = 0; repeat < 50; ++repeat) { for (int repeat = 0; repeat < 50; ++repeat) {
qInfo() << "REPEAT" << repeat << "In backendConnected() -> #M=APISM#C=REQ_SELF#J={}"; qInfo() << "REPEAT" << repeat << "In backendConnected() -> #M=APISM#C=REQ_SELF#J={}";
startProgressLoop(); startProgressLoop();
@ -323,13 +371,30 @@ bool Worker::backendConnected() {
QJsonParseError parseError; QJsonParseError parseError;
QJsonDocument document(QJsonDocument::fromJson(msg.toUtf8(), &parseError)); QJsonDocument document(QJsonDocument::fromJson(msg.toUtf8(), &parseError));
if (parseError.error != QJsonParseError::NoError) { if (parseError.error != QJsonParseError::NoError) {
qCritical() << "(2) INVALID JSON MSG: PARSING FAILED (msg=" << msg << "):" qCritical() << "(1) INVALID JSON MSG: PARSING FAILED (msg=" << msg << "):"
<< parseError.error << parseError.errorString(); << 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); emit replaceLast("Connecting backend ...", UPDATE_STEP_FAIL);
return false; return false;
} }
if (!document.isObject()) { if (!document.isObject()) {
qCritical() << "FILE IS NOT A JSON OBJECT!"; 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); emit replaceLast("Connecting backend ...", UPDATE_STEP_FAIL);
return false; return false;
} }
@ -337,9 +402,9 @@ bool Worker::backendConnected() {
setProgress(progress + 1); setProgress(progress + 1);
QJsonObject obj = document.object(); QJsonObject obj = document.object();
QStringList keys = obj.keys(); QStringList keys = obj.keys().filter("CMD_GET_APISMSTATUS_RESPONSE");
for (QString const& key : keys ) { if (keys.size() == 1) {
if (key.contains("CMD_GET_APISMSTATUS_RESPONSE")) { QString const key = keys.at(0);
QJsonValue v = obj.value(key); QJsonValue v = obj.value(key);
if (v.isObject()) { if (v.isObject()) {
obj = v.toObject(); obj = v.toObject();
@ -356,14 +421,43 @@ bool Worker::backendConnected() {
return true; return true;
} }
} }
emit showErrorMessage("Check backend connection",
m_updateStatus = UpdateStatus(UPDATE_STATUS::BACKEND_CHECK,
QString ("REPEAT %1 Broker=<").arg(repeat) QString ("REPEAT %1 Broker=<").arg(repeat)
+ status + ">, ISMAS=<" + (ismas ? "true>" : "false>")); + 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);
QThread::sleep(6); QThread::sleep(6);
continue; continue;
} 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;
} }
} 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;
} }
}
} else { } else {
stopProgressLoop(); stopProgressLoop();
int progress = (m_mainWindow->progressValue()/10) + 10; int progress = (m_mainWindow->progressValue()/10) + 10;
@ -381,7 +475,7 @@ bool Worker::backendConnected() {
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT, IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
QString("#M=APISM#C=CMD_EVENT#J=") + QString("#M=APISM#C=CMD_EVENT#J=") +
m_ismasClient.errorBackendNotConnected(m_updateStatus.m_statusDescription, "")); m_ismasClient.errorBackendNotConnected(m_updateStatus.m_statusDescription, ""));
}
return false; return false;
} }
@ -394,6 +488,8 @@ bool Worker::updateTriggerSet() {
QString triggerValue(""); QString triggerValue("");
for (int repeat = 0; repeat < 50; ++repeat) { for (int repeat = 0; repeat < 50; ++repeat) {
qInfo() << "UPDATE TRIGGER SET -> REPEAT" << repeat;
startProgressLoop(); startProgressLoop();
if (std::optional<QString> result if (std::optional<QString> result
= IsmasClient::sendRequestReceiveResponse( = IsmasClient::sendRequestReceiveResponse(
@ -411,6 +507,16 @@ bool Worker::updateTriggerSet() {
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);
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 showErrorMessage("check update trigger", emit showErrorMessage("check update trigger",
QString("invalid json ") + msg.mid(0, 20)); QString("invalid json ") + msg.mid(0, 20));
emit replaceLast("Update trigger set ...", UPDATE_STEP_FAIL); emit replaceLast("Update trigger set ...", UPDATE_STEP_FAIL);
@ -418,13 +524,19 @@ bool Worker::updateTriggerSet() {
} }
if (!document.isObject()) { if (!document.isObject()) {
qCritical() << "FILE IS NOT A JSON OBJECT!"; qCritical() << "FILE IS NOT A JSON OBJECT!";
emit showErrorMessage("check update trigger", setProgress(100);
QString("not a json object") + msg); 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);
emit replaceLast("Update trigger set ...", UPDATE_STEP_FAIL); emit replaceLast("Update trigger set ...", UPDATE_STEP_FAIL);
return false; return false;
} }
progress += 1;
setProgress(progress + 1); setProgress(progress);
QJsonObject obj = document.object(); QJsonObject obj = document.object();
// sanity check: cust_nr and machine_nr of PSA correct ? // sanity check: cust_nr and machine_nr of PSA correct ?
@ -440,15 +552,15 @@ bool Worker::updateTriggerSet() {
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);
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));
emit showErrorMessage("check update trigger", m_updateStatus.m_statusDescription);
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT, IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
QString("#M=APISM#C=CMD_EVENT#J=") + QString("#M=APISM#C=CMD_EVENT#J=") +
m_ismasClient.sanityCheckFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR, m_ismasClient.sanityCheckFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
m_updateStatus.m_statusDescription)); m_updateStatus.m_statusDescription));
emit showErrorMessage("check update trigger", m_updateStatus.m_statusDescription);
emit replaceLast("Update trigger set ...", UPDATE_STEP_FAIL); emit replaceLast("Update trigger set ...", UPDATE_STEP_FAIL);
return false; return false;
} }
@ -457,29 +569,62 @@ bool Worker::updateTriggerSet() {
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));
emit showErrorMessage("check update trigger", m_updateStatus.m_statusDescription);
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT, IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
QString("#M=APISM#C=CMD_EVENT#J=") + QString("#M=APISM#C=CMD_EVENT#J=") +
m_ismasClient.sanityCheckFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR, m_ismasClient.sanityCheckFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
m_updateStatus.m_statusDescription)); m_updateStatus.m_statusDescription));
emit showErrorMessage("check update trigger", m_updateStatus.m_statusDescription);
emit replaceLast("Update trigger set ...", UPDATE_STEP_FAIL); emit replaceLast("Update trigger set ...", UPDATE_STEP_FAIL);
return false; return false;
} }
}
}
}
setProgress(progress + 1); 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);
emit replaceLast("Update trigger set ...", UPDATE_STEP_FAIL);
return false;
}
} 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);
emit replaceLast("Update trigger set ...", UPDATE_STEP_FAIL);
return false;
}
} 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);
emit replaceLast("Update trigger set ...", UPDATE_STEP_FAIL);
return false;
}
progress += 1;
setProgress(progress);
if (obj.contains("Fileupload")) { if (obj.contains("Fileupload")) {
QJsonValue v = obj.value("Fileupload"); QJsonValue v = obj.value("Fileupload");
if (v.isObject()) { if (v.isObject()) {
obj = v.toObject(); obj = v.toObject();
if (obj.contains("TRG")) { if (obj.contains("TRG")) {
v = obj.value("TRG"); triggerValue = obj.value("TRG").toString();
if (v.isString()) {
triggerValue = v.toString();
qInfo() << "REPEAT" << repeat qInfo() << "REPEAT" << repeat
<< "In updateTriggerSet() TRG value=<" << "In updateTriggerSet() TRG value=<"
@ -487,9 +632,16 @@ bool Worker::updateTriggerSet() {
if (triggerValue == "WAIT") { if (triggerValue == "WAIT") {
setProgress(100); 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));
m_updateStatus = UpdateStatus(UPDATE_STATUS::UPDATE_TRIGGER_SET, m_updateStatus = UpdateStatus(UPDATE_STATUS::UPDATE_TRIGGER_SET,
QString("UPDATE TRIGGER SET. CONTINUE. ")); QString("UPDATE TRIGGER SET. CONTINUE. "));
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT, IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
QString("#M=APISM#C=CMD_EVENT#J=") + QString("#M=APISM#C=CMD_EVENT#J=") +
m_ismasClient.updateTriggerSet(m_updateStatus.m_statusDescription, "")); m_ismasClient.updateTriggerSet(m_updateStatus.m_statusDescription, ""));
@ -497,30 +649,68 @@ bool Worker::updateTriggerSet() {
emit replaceLast("Update trigger set ...", UPDATE_STEP_OK); emit replaceLast("Update trigger set ...", UPDATE_STEP_OK);
return true; return true;
} else { } else {
emit showErrorMessage("check update trigger", // if the download-button once has the wrong value, it will never recover
QString ("TRG value=<") + triggerValue setProgress(100);
+ ">\n(reset download button?)"); m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_FAILURE,
QThread::sleep(6); QString("TRIGGER-VALUE ") + triggerValue + " NOT 'WAIT'");
continue; 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);
emit replaceLast("Update trigger set ...", UPDATE_STEP_FAIL);
return false;
} }
} else { } else {
emit showErrorMessage("check update trigger", "TRG key not contained"); 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));
emit replaceLast("Update trigger set ...", UPDATE_STEP_FAIL);
emit showErrorMessage("check update trigger", m_updateStatus.m_statusDescription);
return false;
} }
} else { } else {
emit showErrorMessage("check update trigger", "Fileupload not a json-object"); 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));
emit replaceLast("Update trigger set ...", UPDATE_STEP_FAIL);
emit showErrorMessage("check update trigger", m_updateStatus.m_statusDescription);
return false;
} }
} 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));
emit replaceLast("Update trigger set ...", UPDATE_STEP_FAIL);
emit showErrorMessage("check update trigger", m_updateStatus.m_statusDescription);
return false;
} }
if (obj.contains("error")) { if (obj.contains("error")) {
progress += 1;
setProgress(progress);
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=<"
<< value << ">"; << value << ">";
QThread::sleep(6);
} }
} else { } else {
stopProgressLoop(); stopProgressLoop();
int progress = (m_mainWindow->progressValue()/10) + 10; int progress = (m_mainWindow->progressValue()/10) + 10;
progress += 1;
setProgress(progress); setProgress(progress);
emit showErrorMessage("check update trigger", "no ISMAS response"); emit showErrorMessage("check update trigger", "no ISMAS response");
QThread::sleep(6); QThread::sleep(6);
@ -565,15 +755,11 @@ bool Worker::customerEnvironment() {
setProgress(progress); setProgress(progress);
emit showErrorMessage("cust-env", emit showErrorMessage("cust-env",
QString("Checkout ") + m_customerRepository + " failed"); QString("Checkout ") + m_customerRepository + " failed");
qCritical() << QString(80, '*'); Utils::printCriticalErrorMsg(QString("CHECKOUT OF " + m_customerRepository + "FAILED"));
qCritical() << "CHECKOUT OF" << m_customerRepository << "FAILED";
qCritical() << QString(80, '*');
} }
} else { } else {
emit showErrorMessage("cust-env", m_customerRepository + " does not exist"); emit showErrorMessage("cust-env", m_customerRepository + " does not exist");
qCritical() << QString(80, '*'); Utils::printCriticalErrorMsg(m_customerRepository + " DOES NOT EXIST");
qCritical() << m_customerRepository << "DOES NOT EXIST";
qCritical() << QString(80, '*');
} }
setProgress(100); setProgress(100);
@ -600,9 +786,7 @@ bool Worker::filesToUpdate() {
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();
qInfo() << QString(80, '*'); Utils::printInfoMsg("FILES-TO-UPDATE " + m_filesToUpdate.join(','));
qInfo() << "FILES-TO-UPDATE" << m_filesToUpdate;
qInfo() << QString(80, '*');
int const size = m_filesToUpdate.size(); int const size = m_filesToUpdate.size();
if (size > 1) { if (size > 1) {
@ -617,17 +801,11 @@ bool Worker::filesToUpdate() {
return true; return true;
} }
emit showErrorMessage("files to update", "pulling files failed"); emit showErrorMessage("files to update", "pulling files failed");
Utils::printCriticalErrorMsg("PULLING FILES FAILED");
qCritical() << QString(80, '*');
qCritical() << "PULLING FILES FAILED";
qCritical() << QString(80, '*');
} else { } else {
emit showErrorMessage("files to update", "no files to update (checked-in any files?)"); emit showErrorMessage("files to update", "no files to update (checked-in any files?)");
Utils::printCriticalErrorMsg("NO FILES TO UPDATE (CHECKED IN ANY FILES?)");
qCritical() << QString(80, '*');
qCritical() << "NO FILES TO UPDATE (CHECKED IN ANY FILES?)";
qCritical() << QString(80, '*');
} }
setProgress(progress + 30); setProgress(progress + 30);
} else { } else {
@ -639,9 +817,9 @@ bool Worker::filesToUpdate() {
QString("no changes in ") + m_customerRepository + QString("no changes in ") + m_customerRepository +
" (checked-in any files?)"); " (checked-in any files?)");
qCritical() << QString(80, '*'); Utils::printCriticalErrorMsg("NO CHANGES IN "
qCritical() << "NO CHANGES IN" << m_customerRepository << "(CHECKED IN ANY FILES?)"; + m_customerRepository
qCritical() << QString(80, '*'); + " (CHECKED IN ANY FILES?)");
} }
emit replaceLast(QString("Fetch changes files ..."), UPDATE_STEP_FAIL); emit replaceLast(QString("Fetch changes files ..."), UPDATE_STEP_FAIL);
@ -655,11 +833,8 @@ bool Worker::updateFiles(quint8 percent) {
startProgressLoop(); startProgressLoop();
for (int i = 0; i < m_filesToUpdate.size(); ++i) { for (int i = 0; i < m_filesToUpdate.size(); ++i) {
QString fName = m_filesToUpdate.at(i); QString const fName = m_filesToUpdate.at(i);
Utils::printInfoMsg(QString("FNAME ") + fName);
qInfo() << QString(80, '*');
qInfo() << "FNAME" << fName;
qInfo() << QString(80, '*');
if (fName.contains("opkg_commands", Qt::CaseInsensitive)) { if (fName.contains("opkg_commands", Qt::CaseInsensitive)) {
emit appendText("\n( ) Update opkg pakets ..."); emit appendText("\n( ) Update opkg pakets ...");
@ -716,14 +891,10 @@ bool Worker::updateFiles(quint8 percent) {
bool ret = true; bool ret = true;
if (filesToDownload.size() > 0) { if (filesToDownload.size() > 0) {
qInfo() << QString(80, '*'); Utils::printInfoMsg(QString("FILES_TO_DOWNLOAD_TO_PSA_HW ") + filesToDownload.join(','));
qInfo() << "FILES_TO_WORK_ON" << filesToDownload;
qInfo() << QString(80, '*');
ret = m_update->doUpdate(m_displayIndex, filesToDownload); ret = m_update->doUpdate(m_displayIndex, filesToDownload);
} else { } else {
qInfo() << QString(80, '*'); Utils::printCriticalErrorMsg("NO FILES_TO_DOWNLOAD_TO_PSA_HW");
qInfo() << "NO FILES_TO_WORK_ON";
qInfo() << QString(80, '*');
} }
return ret; return ret;
@ -762,12 +933,9 @@ bool Worker::syncCustomerRepositoryAndFS() {
for (int i = 0; i < result.size(); ++i) { for (int i = 0; i < result.size(); ++i) {
qInfo() << result.at(i); qInfo() << result.at(i);
} }
qInfo() << "SUCCESS";
} else { } else {
qCritical() << QString(80, '*'); Utils::printCriticalErrorMsg(QString("CMD ") + cmd + " FAILED: "
qCritical() << "CMD" << cmd << "FAILED"; + c.getCommandResult());
qCritical() << c.getCommandResult().split('\n');
qCritical() << QString(80, '*');
error = true; error = true;
} }
} }
@ -883,17 +1051,13 @@ bool Worker::executeOpkgCommand(QString opkgCommand) {
Command c(opkgCommand); Command c(opkgCommand);
if (c.execute(m_workingDirectory)) { if (c.execute(m_workingDirectory)) {
QString const r = c.getCommandResult(); QString const r = c.getCommandResult();
qInfo() << UpdateStatus(UPDATE_STATUS::EXEC_OPKG_COMMAND_SUCCESS, Utils::printInfoMsg(QString("EXECUTE OPKG COMMAND %1 OK: %2")
QString("EXECUTE OPKG COMMAND %1 OK: %2")
.arg(opkgCommand) .arg(opkgCommand)
.arg(c.getCommandResult())); .arg(c.getCommandResult()));
return true; return true;
} else { } else {
qCritical() << QString(80, '*'); Utils::printCriticalErrorMsg(QString("EXECUTE OPKG COMMAND %1 FAILED")
qCritical() << UpdateStatus(UPDATE_STATUS::EXEC_OPKG_COMMAND_FAILURE,
QString("EXECUTE OPKG COMMAND %1 FAILED")
.arg(opkgCommand)); .arg(opkgCommand));
qCritical() << QString(80, '*');
} }
return false; return false;
} }
@ -912,19 +1076,23 @@ PSAInstalled Worker::getPSAInstalled() {
PSAInstalled psaInstalled; PSAInstalled psaInstalled;
QString printSysDir("/etc/psa_config"); QString printSysDir("/etc/psa_config");
QString tariffSysDir("/etc/psa_tariff"); QString tariffSysDir("/etc/psa_tariff");
QString tariffRepoDir("etc/psa_tariff");
QString absPathName; QString absPathName;
QString absPathNameRepository;
if (m_zoneNr != 0) { if (m_zoneNr != 0) {
QString const &n = QString("%1").arg(m_zoneNr).rightJustified(2, '0'); QString const &n = QString("%1").arg(m_zoneNr).rightJustified(2, '0');
psaInstalled.tariff.name = QString("tariff%1.json").arg(n); psaInstalled.tariff.name = QString("tariff%1.json").arg(n);
absPathName = QDir::cleanPath(tariffSysDir + QDir::separator() + psaInstalled.tariff.name); absPathName = QDir::cleanPath(tariffSysDir + QDir::separator() + psaInstalled.tariff.name);
psaInstalled.tariff.blob = m_gc.gitBlob(absPathName); psaInstalled.tariff.blob = m_gc.gitBlob(absPathName);
absPathNameRepository = QDir::cleanPath(tariffRepoDir + QDir::separator() + psaInstalled.tariff.name);
psaInstalled.tariff.lastCommit = m_gc.gitLastCommit(absPathNameRepository);
psaInstalled.tariff.size = getFileSize(absPathName); psaInstalled.tariff.size = getFileSize(absPathName);
psaInstalled.tariff.zone = m_zoneNr; psaInstalled.tariff.zone = m_zoneNr;
psaInstalled.tariff.loadTime = Utils::getTariffLoadTime(absPathName);
} }
psaInstalled.tariff.project = "Szeged"; psaInstalled.tariff.project = "Szeged";
psaInstalled.tariff.info = "N/A"; psaInstalled.tariff.info = "N/A";
psaInstalled.tariff.loadTime = "N/A"; // QDateTime::currentDateTime().toString(Qt::ISODateWithMs);
psaInstalled.tariff.version = "N/A"; psaInstalled.tariff.version = "N/A";
psaInstalled.hw.linuxVersion = m_osVersion; psaInstalled.hw.linuxVersion = m_osVersion;

View File

@ -32,6 +32,9 @@ enum class UPDATE_STATUS : quint8 {
ISMAS_WAIT_STATE_CHECK_SUCCESS, ISMAS_WAIT_STATE_CHECK_SUCCESS,
ISMAS_RESPONSE_RECEIVED, ISMAS_RESPONSE_RECEIVED,
BACKEND_CONNECTED, BACKEND_CONNECTED,
BACKEND_CHECK,
BACKEND_CHECK_FAILURE,
ISMAS_BACKEND_CHECK_FAILURE,
BACKEND_NOT_CONNECTED, BACKEND_NOT_CONNECTED,
UPDATE_TRIGGER_SET, UPDATE_TRIGGER_SET,
UPDATE_TRIGGER_NOT_SET_OR_WRONG, UPDATE_TRIGGER_NOT_SET_OR_WRONG,
@ -59,6 +62,7 @@ enum class UPDATE_STATUS : quint8 {
DEVICE_CONTROLLER_UPDATE_SUCCESS, DEVICE_CONTROLLER_UPDATE_SUCCESS,
JSON_UPDATE, JSON_UPDATE,
JSON_UPDATE_FAILURE, JSON_UPDATE_FAILURE,
JSON_PARSE_FAILURE,
JSON_UPDATE_SUCCESS, JSON_UPDATE_SUCCESS,
UPDATE_PROCESS_SUCCESS, UPDATE_PROCESS_SUCCESS,
UPDATE_PROCESS_FAILURE, UPDATE_PROCESS_FAILURE,
@ -67,7 +71,13 @@ enum class UPDATE_STATUS : quint8 {
ISMAS_UPDATE_INFO_CONFIRM_SUCCESS, ISMAS_UPDATE_INFO_CONFIRM_SUCCESS,
ISMAS_CURRENT_PSA_STATUS_CONFIRM, ISMAS_CURRENT_PSA_STATUS_CONFIRM,
ISMAS_CURRENT_PSA_STATUS_CONFIRM_FAILURE, ISMAS_CURRENT_PSA_STATUS_CONFIRM_FAILURE,
ISMAS_CURRENT_PSA_STATUS_CONFIRM_SUCCESS ISMAS_CURRENT_PSA_STATUS_CONFIRM_SUCCESS,
ISMAS_SANITY_CHECK_OK,
ISMAS_UPDATE_TRIGGER_SET_FAILURE,
PSA_UPDATE_FILES_FAILED,
GIT_CHECK_FILES_TO_UPDATE_SUCCESS,
ISMAS_SEND_LAST_VERSION_FAILED,
SAVE_LOG_FILES_FAILED
}; };
struct UpdateStatus { struct UpdateStatus {