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

View File

@ -753,11 +753,21 @@ QString IsmasClient::sanityCheckFailed(int resultCode, QString reason, QString c
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",
m_progressInPercent,
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(),
version.toStdString().c_str());
}

View File

@ -12,6 +12,7 @@ struct PSAInstalled {
int zone;
int size;
QString blob;
QString lastCommit;
QString info;
QString loadTime;
} tariff;
@ -155,8 +156,9 @@ public:
// and update accepted
QString updateOfPSASucceeded(QString const &version = QString()); // update process succeeded
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 jsonParseFailed(int resultCode, QString reason, QString const &version = QString());
QString updateOfPSASendVersion(PSAInstalled const &psa);

View File

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

View File

@ -1,8 +1,9 @@
#include "utils.h"
#include "message_handler.h"
#include <QFile>
#include <QTextStream>
#include <QDebug>
int Utils::read1stLineOfFile(QString fileName) {
QFile f(fileName);
@ -33,3 +34,46 @@ QString Utils::zoneName(quint8 i) {
}
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 <QString>
#include <QStringList>
#include <QFile>
#include <QFileInfo>
#include <QDateTime>
namespace Utils {
int read1stLineOfFile(QString fileName);
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

View File

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

View File

@ -32,6 +32,9 @@ enum class UPDATE_STATUS : quint8 {
ISMAS_WAIT_STATE_CHECK_SUCCESS,
ISMAS_RESPONSE_RECEIVED,
BACKEND_CONNECTED,
BACKEND_CHECK,
BACKEND_CHECK_FAILURE,
ISMAS_BACKEND_CHECK_FAILURE,
BACKEND_NOT_CONNECTED,
UPDATE_TRIGGER_SET,
UPDATE_TRIGGER_NOT_SET_OR_WRONG,
@ -59,6 +62,7 @@ enum class UPDATE_STATUS : quint8 {
DEVICE_CONTROLLER_UPDATE_SUCCESS,
JSON_UPDATE,
JSON_UPDATE_FAILURE,
JSON_PARSE_FAILURE,
JSON_UPDATE_SUCCESS,
UPDATE_PROCESS_SUCCESS,
UPDATE_PROCESS_FAILURE,
@ -67,7 +71,13 @@ enum class UPDATE_STATUS : quint8 {
ISMAS_UPDATE_INFO_CONFIRM_SUCCESS,
ISMAS_CURRENT_PSA_STATUS_CONFIRM,
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 {