Compare commits
29 Commits
v1.1.0
...
4307fb96a6
Author | SHA1 | Date | |
---|---|---|---|
4307fb96a6 | |||
c35390b6d6 | |||
fff6bd2b49 | |||
631ade1954 | |||
337bdd1bb0 | |||
978cc16304 | |||
bea8242d6f | |||
56daa84a14 | |||
17ddfd0ddd | |||
2ac8c4cfc6 | |||
0559ff64e2 | |||
385a7b7b00 | |||
503b7c64f9 | |||
beec9c2f9d | |||
5263b7de0f | |||
9b4d0494c8 | |||
0f2ee0349f | |||
e700a40875 | |||
1eba5338e4 | |||
f20be9ddcf | |||
7631c05e22 | |||
ad93e536f0 | |||
259da8200e | |||
8d528f0f55 | |||
66d0214720 | |||
86064979b4 | |||
86c996d7ac | |||
effe41bac9 | |||
4968942cc2 |
@@ -15,7 +15,7 @@ DEFINES += QT_DEPRECATED_WARNINGS
|
|||||||
# In order to do so, uncomment the following line.
|
# In order to do so, uncomment the following line.
|
||||||
# You can also select to disable deprecated APIs only up to a certain version of Qt.
|
# You can also select to disable deprecated APIs only up to a certain version of Qt.
|
||||||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||||
VERSION=1.0.0
|
VERSION=1.1.1
|
||||||
|
|
||||||
INCLUDEPATH += plugins
|
INCLUDEPATH += plugins
|
||||||
|
|
||||||
|
@@ -114,6 +114,47 @@ bool GitClient::gitCloneAndCheckoutBranch() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QStringList GitClient::gitShowReason() {
|
||||||
|
QStringList lst;
|
||||||
|
if (QDir(m_customerRepository).exists()) {
|
||||||
|
// %h: commit (short form)
|
||||||
|
// %s: commit message
|
||||||
|
// %cI: commit date, strict ISO 8601 format
|
||||||
|
Command c("git show -s --format=\"c=%h m=%s d=%cI\"");
|
||||||
|
if (c.execute(m_customerRepository)) {
|
||||||
|
QString const s = c.getCommandResult().trimmed();
|
||||||
|
int const c = s.indexOf("c=");
|
||||||
|
int const m = s.indexOf("m=");
|
||||||
|
int const d = s.indexOf("d=");
|
||||||
|
QString commit{""}, msg{""}, date{""};
|
||||||
|
if (c != -1) {
|
||||||
|
int start = c + 2;
|
||||||
|
if (m >= start) {
|
||||||
|
int length = m - start;
|
||||||
|
commit = s.mid(start, length).trimmed();
|
||||||
|
|
||||||
|
start = m + 2;
|
||||||
|
if (d >= start) {
|
||||||
|
length = d - start;
|
||||||
|
msg = s.mid(start, length).trimmed();
|
||||||
|
|
||||||
|
start = d + 2;
|
||||||
|
date = s.mid(start);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!commit.isEmpty() && !msg.isEmpty() && !date.isEmpty()) {
|
||||||
|
lst << commit << msg << date;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
qCritical() << "CUSTOMER_REPOSITORY" << m_customerRepository
|
||||||
|
<< "DOES NOT EXIST";
|
||||||
|
}
|
||||||
|
return lst;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Zu beachten: wird eine datei neu hinzugefuegt (git add/commit) dann aber gleich
|
Zu beachten: wird eine datei neu hinzugefuegt (git add/commit) dann aber gleich
|
||||||
wieder geloscht, so wird sie im diff nicht angezeigt.
|
wieder geloscht, so wird sie im diff nicht angezeigt.
|
||||||
|
@@ -50,6 +50,7 @@ class GitClient : public QObject {
|
|||||||
std::optional<QStringList> gitMerge();
|
std::optional<QStringList> gitMerge();
|
||||||
|
|
||||||
QString gitLastCommit(QString fileName);
|
QString gitLastCommit(QString fileName);
|
||||||
|
QStringList gitShowReason();
|
||||||
QString gitBlob(QString fileName);
|
QString gitBlob(QString fileName);
|
||||||
QString gitCommitForBlob(QString blob);
|
QString gitCommitForBlob(QString blob);
|
||||||
bool gitIsFileTracked(QString file2name);
|
bool gitIsFileTracked(QString file2name);
|
||||||
|
@@ -137,7 +137,12 @@ IsmasClient::sendRequestReceiveResponse(int port, QString const &request) {
|
|||||||
so_linger.l_onoff = 1;
|
so_linger.l_onoff = 1;
|
||||||
so_linger.l_linger = 0;
|
so_linger.l_linger = 0;
|
||||||
|
|
||||||
|
int maxfdp1;
|
||||||
|
fd_set rset;
|
||||||
|
fd_set wset;
|
||||||
|
|
||||||
setsockopt(sockfd, SOL_SOCKET, SO_LINGER, &so_linger, sizeof(so_linger));
|
setsockopt(sockfd, SOL_SOCKET, SO_LINGER, &so_linger, sizeof(so_linger));
|
||||||
|
// no reliable, but does not harm, as we use select() as well
|
||||||
setsockopt(sockfd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv));
|
setsockopt(sockfd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv));
|
||||||
setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
|
setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
|
||||||
int flag = 1;
|
int flag = 1;
|
||||||
@@ -151,6 +156,37 @@ IsmasClient::sendRequestReceiveResponse(int port, QString const &request) {
|
|||||||
int loop = 0;
|
int loop = 0;
|
||||||
int bytesWritten = 0;
|
int bytesWritten = 0;
|
||||||
while (bytesWritten < bytesToWrite) {
|
while (bytesWritten < bytesToWrite) {
|
||||||
|
errno = 0;
|
||||||
|
FD_ZERO(&wset);
|
||||||
|
FD_SET(sockfd, &wset);
|
||||||
|
maxfdp1 = sockfd + 1;
|
||||||
|
tv.tv_sec = 60; /* 60 secs timeout for read and write -> APISM cuts the connection after 30s */
|
||||||
|
tv.tv_usec = 0;
|
||||||
|
|
||||||
|
int const w = select(maxfdp1, NULL, &wset, NULL, &tv);
|
||||||
|
if (w < 0) { // error
|
||||||
|
if (errno == EINTR) {
|
||||||
|
printErrorMessage(port, clientIP, clientPort,
|
||||||
|
QString("INTERRUPTED BY SIGNAL (1) (") + strerror(errno) + ")");
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
printErrorMessage(port, clientIP, clientPort,
|
||||||
|
QString("SELECT-ERROR (WRITE) %1(").arg(loop) + strerror(errno) + ")");
|
||||||
|
::close(sockfd);
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
if (w == 0) { // timeout
|
||||||
|
printErrorMessage(port, clientIP, clientPort,
|
||||||
|
QString("SELECT-TIMEOUT (WRITE) %1(").arg(loop) + strerror(errno) + ")");
|
||||||
|
if (++loop < 10) {
|
||||||
|
QThread::msleep(500);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
::close(sockfd);
|
||||||
|
return std::nullopt;
|
||||||
|
} else
|
||||||
|
if (w > 0) {
|
||||||
int n = ::sendto(sockfd, buf+bytesWritten, bytesToWrite-bytesWritten, 0, NULL, 0);
|
int n = ::sendto(sockfd, buf+bytesWritten, bytesToWrite-bytesWritten, 0, NULL, 0);
|
||||||
if (n >= 0) {
|
if (n >= 0) {
|
||||||
bytesWritten += n;
|
bytesWritten += n;
|
||||||
@@ -172,6 +208,7 @@ IsmasClient::sendRequestReceiveResponse(int port, QString const &request) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// DO NOT USE SHUTDOWN! APISM CAN NOT COPE WITH IT
|
// DO NOT USE SHUTDOWN! APISM CAN NOT COPE WITH IT
|
||||||
// errno = 0;
|
// errno = 0;
|
||||||
@@ -180,7 +217,7 @@ IsmasClient::sendRequestReceiveResponse(int port, QString const &request) {
|
|||||||
// QString("CANNOT CLOSE WRITING END (") + strerror(errno) + ")");
|
// QString("CANNOT CLOSE WRITING END (") + strerror(errno) + ")");
|
||||||
// }
|
// }
|
||||||
|
|
||||||
printInfoMessage(port, clientIP, clientPort, QString("MESSAGE SENT ") + buf);
|
printInfoMessage(port, clientIP, clientPort, QString("MESSAGE SENT <<<") + buf + ">>>");
|
||||||
|
|
||||||
loop = 0;
|
loop = 0;
|
||||||
bzero(buf, sizeof(buf));
|
bzero(buf, sizeof(buf));
|
||||||
@@ -188,6 +225,39 @@ IsmasClient::sendRequestReceiveResponse(int port, QString const &request) {
|
|||||||
int bytesRead = 0;
|
int bytesRead = 0;
|
||||||
while (bytesRead < bytesToRead) {
|
while (bytesRead < bytesToRead) {
|
||||||
errno = 0;
|
errno = 0;
|
||||||
|
FD_ZERO(&rset);
|
||||||
|
FD_SET(sockfd, &rset);
|
||||||
|
maxfdp1 = sockfd + 1;
|
||||||
|
tv.tv_sec = 60; /* 60 secs timeout for read and write */
|
||||||
|
tv.tv_usec = 0;
|
||||||
|
|
||||||
|
QString const selectStart = QDateTime::currentDateTime().toString(Qt::ISODateWithMs);
|
||||||
|
|
||||||
|
int const r = select(maxfdp1, &rset, NULL, NULL, &tv);
|
||||||
|
if (r < 0) { // error
|
||||||
|
if (errno == EINTR) {
|
||||||
|
printErrorMessage(port, clientIP, clientPort,
|
||||||
|
QString("INTERRUPTED BY SIGNAL (2) (") + strerror(errno) + ")");
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
printErrorMessage(port, clientIP, clientPort,
|
||||||
|
QString("SELECT-ERROR (READ) %1(").arg(loop) + strerror(errno) + ")");
|
||||||
|
::close(sockfd);
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
if (r == 0) { // timeout
|
||||||
|
printErrorMessage(port, clientIP, clientPort,
|
||||||
|
QString("SELECT-TIMEOUT (READ) %1(").arg(loop) + strerror(errno) + ")");
|
||||||
|
if (++loop < 10) {
|
||||||
|
QThread::msleep(500);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
::close(sockfd);
|
||||||
|
return std::nullopt;
|
||||||
|
} else
|
||||||
|
if (r > 0) {
|
||||||
|
if (FD_ISSET(sockfd, &rset)) {
|
||||||
int n = ::recvfrom(sockfd, buf+bytesRead, bytesToRead-bytesRead,
|
int n = ::recvfrom(sockfd, buf+bytesRead, bytesToRead-bytesRead,
|
||||||
0, NULL, NULL);
|
0, NULL, NULL);
|
||||||
if (n > 0) { //
|
if (n > 0) { //
|
||||||
@@ -196,12 +266,13 @@ IsmasClient::sendRequestReceiveResponse(int port, QString const &request) {
|
|||||||
if (n == 0) {
|
if (n == 0) {
|
||||||
// The return value will be 0 when the peer has performed an orderly shutdown.
|
// The return value will be 0 when the peer has performed an orderly shutdown.
|
||||||
printErrorMessage(port, clientIP, clientPort,
|
printErrorMessage(port, clientIP, clientPort,
|
||||||
QString("PEER CLOSED CONNECTION (") + strerror(errno) + ")");
|
QString("PEER CLOSED CONNECTION (") + strerror(errno) + ") START AT" +
|
||||||
|
selectStart + " NOW " + QDateTime::currentDateTime().toString(Qt::ISODateWithMs));
|
||||||
::close(sockfd);
|
::close(sockfd);
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
} else
|
} else
|
||||||
if (n < 0) {
|
if (n < 0) {
|
||||||
if (errno == EWOULDBLOCK) {
|
if (errno == EWOULDBLOCK) { // check just in case
|
||||||
if (++loop < 10) {
|
if (++loop < 10) {
|
||||||
QThread::msleep(500);
|
QThread::msleep(500);
|
||||||
continue;
|
continue;
|
||||||
@@ -217,6 +288,8 @@ IsmasClient::sendRequestReceiveResponse(int port, QString const &request) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
printInfoMessage(port, clientIP, clientPort, QString("MESSAGE RECEIVED ") + buf);
|
printInfoMessage(port, clientIP, clientPort, QString("MESSAGE RECEIVED ") + buf);
|
||||||
QString response(buf);
|
QString response(buf);
|
||||||
@@ -345,13 +418,11 @@ QString IsmasClient::updateOfPSASendVersion(PSAInstalled const &psa) {
|
|||||||
static char buf[4096*2];
|
static char buf[4096*2];
|
||||||
memset(buf, 0, sizeof(buf));
|
memset(buf, 0, sizeof(buf));
|
||||||
|
|
||||||
QString const ts = QDateTime::currentDateTime().toString(Qt::ISODateWithMs);
|
|
||||||
QString sendVersionHash = "N/A";
|
|
||||||
|
|
||||||
// local data="#M=APISM#C=CMD_SENDVERSION#J=
|
// local data="#M=APISM#C=CMD_SENDVERSION#J=
|
||||||
snprintf(buf, sizeof(buf)-1,
|
snprintf(buf, sizeof(buf)-1,
|
||||||
"{"
|
"{"
|
||||||
"\"VERSION_INFO\" : {"
|
"\"VERSION_INFO\" : {"
|
||||||
|
"\"REASON\":\"%s\","
|
||||||
"\"CREATED\":\"%s\","
|
"\"CREATED\":\"%s\","
|
||||||
"\"HASH\":\"%s\""
|
"\"HASH\":\"%s\""
|
||||||
"},"
|
"},"
|
||||||
@@ -559,8 +630,9 @@ QString IsmasClient::updateOfPSASendVersion(PSAInstalled const &psa) {
|
|||||||
"}"
|
"}"
|
||||||
"}"
|
"}"
|
||||||
"}",
|
"}",
|
||||||
ts.toStdString().c_str(),
|
psa.versionInfo.reason.toStdString().c_str(),
|
||||||
sendVersionHash.toStdString().c_str(),
|
psa.versionInfo.created.toStdString().c_str(),
|
||||||
|
psa.versionInfo.lastCommit.toStdString().c_str(),
|
||||||
|
|
||||||
psa.tariff.version.toStdString().c_str(),
|
psa.tariff.version.toStdString().c_str(),
|
||||||
psa.tariff.project.toStdString().c_str(),
|
psa.tariff.project.toStdString().c_str(),
|
||||||
@@ -762,6 +834,27 @@ QString IsmasClient::jsonParseFailed(int resultCode, QString reason, QString con
|
|||||||
version.toStdString().c_str());
|
version.toStdString().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::optional<QString> IsmasClient::finalResult(int resultCode, QString reason, QString const &version) {
|
||||||
|
m_progressInPercent = 0;
|
||||||
|
if (resultCode == RESULT_CODE::SUCCESS) {
|
||||||
|
return updateNewsToIsmas("U0002",
|
||||||
|
m_progressInPercent,
|
||||||
|
RESULT_CODE::SUCCESS,
|
||||||
|
"FINAL-UPDATE-RESULT",
|
||||||
|
"(re-)set WAIT state",
|
||||||
|
version.toStdString().c_str());
|
||||||
|
}
|
||||||
|
if (resultCode == RESULT_CODE::INSTALL_ERROR) {
|
||||||
|
return updateNewsToIsmas("U0003",
|
||||||
|
m_progressInPercent,
|
||||||
|
resultCode,
|
||||||
|
"FINAL-UPDATE-RESULT",
|
||||||
|
reason.toStdString().c_str(),
|
||||||
|
version.toStdString().c_str());
|
||||||
|
}
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
QString IsmasClient::updateOfPSAFailed(int resultCode, QString step,
|
QString IsmasClient::updateOfPSAFailed(int resultCode, QString step,
|
||||||
QString reason, QString const &version) {
|
QString reason, QString const &version) {
|
||||||
return updateNewsToIsmas("U0003",
|
return updateNewsToIsmas("U0003",
|
||||||
|
@@ -4,7 +4,15 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
struct PSAInstalled {
|
struct PSAInstalled {
|
||||||
|
struct VersionInfo {
|
||||||
|
QString created;
|
||||||
|
QString reason;
|
||||||
|
QString lastCommit;
|
||||||
|
} versionInfo;
|
||||||
|
|
||||||
struct Tariff {
|
struct Tariff {
|
||||||
QString name;
|
QString name;
|
||||||
QString version;
|
QString version;
|
||||||
@@ -159,6 +167,7 @@ public:
|
|||||||
QString updateOfPSAFailed(int resultCode, QString step, 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 jsonParseFailed(int resultCode, QString reason, QString const &version = QString());
|
||||||
|
std::optional<QString> finalResult(int resultCode, QString reason, QString const &version = QString());
|
||||||
|
|
||||||
QString updateOfPSASendVersion(PSAInstalled const &psa);
|
QString updateOfPSASendVersion(PSAInstalled const &psa);
|
||||||
|
|
||||||
|
17
main.cpp
17
main.cpp
@@ -31,6 +31,7 @@
|
|||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
|
#include <QtWidgets>
|
||||||
|
|
||||||
#ifdef PTU5
|
#ifdef PTU5
|
||||||
#define SERIAL_PORT "ttymxc2"
|
#define SERIAL_PORT "ttymxc2"
|
||||||
@@ -65,7 +66,7 @@ int main(int argc, char *argv[]) {
|
|||||||
QCommandLineOption pluginDirectoryOption(QStringList() << "plugin-directory" << "plugin-directory",
|
QCommandLineOption pluginDirectoryOption(QStringList() << "plugin-directory" << "plugin-directory",
|
||||||
QCoreApplication::translate("main", "Where to find dc-plugin."),
|
QCoreApplication::translate("main", "Where to find dc-plugin."),
|
||||||
QCoreApplication::translate("main", "directory"));
|
QCoreApplication::translate("main", "directory"));
|
||||||
QString const pluginDefault = "./plugins";
|
QString const pluginDefault = "/usr/lib";
|
||||||
pluginDirectoryOption.setDefaultValue(pluginDefault);
|
pluginDirectoryOption.setDefaultValue(pluginDefault);
|
||||||
parser.addOption(pluginDirectoryOption);
|
parser.addOption(pluginDirectoryOption);
|
||||||
|
|
||||||
@@ -79,7 +80,7 @@ int main(int argc, char *argv[]) {
|
|||||||
QCommandLineOption workingDirectoryOption(QStringList() << "working-directory" << "working-directory",
|
QCommandLineOption workingDirectoryOption(QStringList() << "working-directory" << "working-directory",
|
||||||
QCoreApplication::translate("main", "working directory of update-script."),
|
QCoreApplication::translate("main", "working directory of update-script."),
|
||||||
QCoreApplication::translate("main", "directory"));
|
QCoreApplication::translate("main", "directory"));
|
||||||
QString const workingDirectoryDefault = ".";
|
QString const workingDirectoryDefault = "/opt/app/tools/atbupdate";
|
||||||
workingDirectoryOption.setDefaultValue(workingDirectoryDefault);
|
workingDirectoryOption.setDefaultValue(workingDirectoryDefault);
|
||||||
parser.addOption(workingDirectoryOption);
|
parser.addOption(workingDirectoryOption);
|
||||||
|
|
||||||
@@ -87,14 +88,6 @@ int main(int argc, char *argv[]) {
|
|||||||
QCoreApplication::translate("main", "Start ATBUpdateTool in dry-run-mode. No actual actions."));
|
QCoreApplication::translate("main", "Start ATBUpdateTool in dry-run-mode. No actual actions."));
|
||||||
parser.addOption(dryRunOption);
|
parser.addOption(dryRunOption);
|
||||||
|
|
||||||
// TODO:
|
|
||||||
// add some additional parameters
|
|
||||||
// --dry-run
|
|
||||||
// -d: only update device-controller firmware
|
|
||||||
// -j: only update json-files
|
|
||||||
// -o: only execute opkg-commnds
|
|
||||||
// -f: force. update_psa shall always perform a 'git pull'
|
|
||||||
|
|
||||||
// Process the actual command line arguments given by the user
|
// Process the actual command line arguments given by the user
|
||||||
parser.process(a);
|
parser.process(a);
|
||||||
QString plugInDir = parser.value(pluginDirectoryOption);
|
QString plugInDir = parser.value(pluginDirectoryOption);
|
||||||
@@ -103,9 +96,6 @@ int main(int argc, char *argv[]) {
|
|||||||
bool dryRun = parser.isSet(dryRunOption);
|
bool dryRun = parser.isSet(dryRunOption);
|
||||||
QString const rtPath = QCoreApplication::applicationDirPath();
|
QString const rtPath = QCoreApplication::applicationDirPath();
|
||||||
|
|
||||||
if (plugInDir == pluginDefault) {
|
|
||||||
plugInDir = (rtPath + "/" + pluginDefault);
|
|
||||||
}
|
|
||||||
if (!QDir(plugInDir).exists()) {
|
if (!QDir(plugInDir).exists()) {
|
||||||
qCritical() << plugInDir
|
qCritical() << plugInDir
|
||||||
<< "does not exists, but has to contain dc-library";
|
<< "does not exists, but has to contain dc-library";
|
||||||
@@ -137,6 +127,7 @@ int main(int argc, char *argv[]) {
|
|||||||
QThread::currentThread()->setObjectName("main thread");
|
QThread::currentThread()->setObjectName("main thread");
|
||||||
qInfo() << "Main thread" << QThread::currentThreadId();
|
qInfo() << "Main thread" << QThread::currentThreadId();
|
||||||
|
|
||||||
|
|
||||||
Worker worker(hw,
|
Worker worker(hw,
|
||||||
customerNr,
|
customerNr,
|
||||||
machineNr,
|
machineNr,
|
||||||
|
102
mainwindow.cpp
102
mainwindow.cpp
@@ -7,6 +7,7 @@
|
|||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QScrollBar>
|
||||||
|
|
||||||
MainWindow::MainWindow(Worker *worker, QWidget *parent)
|
MainWindow::MainWindow(Worker *worker, QWidget *parent)
|
||||||
: QMainWindow(parent)
|
: QMainWindow(parent)
|
||||||
@@ -15,6 +16,16 @@ MainWindow::MainWindow(Worker *worker, QWidget *parent)
|
|||||||
, m_width(70)
|
, m_width(70)
|
||||||
, m_progressRunning(false)
|
, m_progressRunning(false)
|
||||||
, m_progressValue(0) {
|
, m_progressValue(0) {
|
||||||
|
|
||||||
|
|
||||||
|
this->setStatusBar(new QStatusBar(this));
|
||||||
|
QFont f;
|
||||||
|
f.setStyleHint(QFont::Monospace);
|
||||||
|
f.setWeight(QFont::Bold);
|
||||||
|
f.setFamily("Misc Fixed");
|
||||||
|
f.setPixelSize(12);
|
||||||
|
this->statusBar()->setFont(f);
|
||||||
|
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
ui->updateProgress->setRange(0, 100);
|
ui->updateProgress->setRange(0, 100);
|
||||||
@@ -42,17 +53,15 @@ MainWindow::MainWindow(Worker *worker, QWidget *parent)
|
|||||||
m_exitTimer->setSingleShot(true);
|
m_exitTimer->setSingleShot(true);
|
||||||
m_exitTimer->start(1800 * 1000);
|
m_exitTimer->start(1800 * 1000);
|
||||||
|
|
||||||
connect(ui->exit, SIGNAL(clicked()), this, SLOT(onQuit()));
|
connect(ui->exit, SIGNAL(clicked()),this,SLOT(onQuit()));
|
||||||
connect(m_worker, SIGNAL(disableExit()), this, SLOT(onDisableExit()));
|
connect(m_worker, SIGNAL(disableExit()),this,SLOT(onDisableExit()));
|
||||||
connect(m_worker, SIGNAL(enableExit()), this, SLOT(onEnableExit()));
|
connect(m_worker, SIGNAL(enableExit()),this,SLOT(onEnableExit()));
|
||||||
connect(m_worker, SIGNAL(stopStartTimer()), this, SLOT(onStopStartTimer()));
|
connect(m_worker, SIGNAL(stopStartTimer()),this,SLOT(onStopStartTimer()));
|
||||||
connect(m_worker, SIGNAL(restartExitTimer()), this, SLOT(onRestartExitTimer()));
|
connect(m_worker, SIGNAL(restartExitTimer()),this,SLOT(onRestartExitTimer()));
|
||||||
connect(m_worker, SIGNAL(appendText(QString, QString)), this, SLOT(onAppendText(QString, QString)));
|
connect(m_worker, SIGNAL(appendText(QString,QString)),this,SLOT(onAppendText(QString,QString)));
|
||||||
connect(m_worker, SIGNAL(showErrorMessage(QString,QString)), this, SLOT(onShowErrorMessage(QString,QString)));
|
connect(m_worker, SIGNAL(showErrorMessage(QString,QString)),this, SLOT(onShowErrorMessage(QString,QString)));
|
||||||
connect(m_worker, SIGNAL(replaceLast(QString, QString)), this, SLOT(onReplaceLast(QString,QString)));
|
connect(m_worker, SIGNAL(replaceLast(QString,QString)),this,SLOT(onReplaceLast(QString,QString)));
|
||||||
|
connect(m_worker, SIGNAL(replaceLast(QStringList,QString)),this, SLOT(onReplaceLast(QStringList,QString)));
|
||||||
ui->updateStatus->setText(lst.join('\n'));
|
|
||||||
ui->updateStatus->setEnabled(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow() {
|
MainWindow::~MainWindow() {
|
||||||
@@ -137,10 +146,19 @@ void MainWindow::onQuit() {
|
|||||||
qApp->exit(m_worker->returnCode());
|
qApp->exit(m_worker->returnCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::scrollDownTextEdit() {
|
||||||
|
ui->updateStatus->setEnabled(true);
|
||||||
|
|
||||||
|
QTextCursor tmpCursor = ui->updateStatus->textCursor();
|
||||||
|
tmpCursor.movePosition(QTextCursor::End);
|
||||||
|
ui->updateStatus->setTextCursor(tmpCursor);
|
||||||
|
ui->updateStatus->ensureCursorVisible();
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::onAppendText(QString text, QString suffix) {
|
void MainWindow::onAppendText(QString text, QString suffix) {
|
||||||
QString editText = ui->updateStatus->toPlainText();
|
QString editText = ui->updateStatus->toPlainText();
|
||||||
if (!suffix.isNull() && suffix.size() > 0) {
|
if (!suffix.isNull() && suffix.size() > 0) {
|
||||||
qInfo() << "TEXT" << text << "SUFFIX" << suffix;
|
//qInfo() << "TEXT" << text << "SUFFIX" << suffix;
|
||||||
if (suffix == Worker::UPDATE_STEP_SUCCESS || suffix == Worker::UPDATE_STEP_FAIL) {
|
if (suffix == Worker::UPDATE_STEP_SUCCESS || suffix == Worker::UPDATE_STEP_FAIL) {
|
||||||
editText += QString("\n").leftJustified(m_width-3, '=');
|
editText += QString("\n").leftJustified(m_width-3, '=');
|
||||||
editText += " ";
|
editText += " ";
|
||||||
@@ -151,14 +169,44 @@ void MainWindow::onAppendText(QString text, QString suffix) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Utils::printLineEditInfo(editText.split('\n'));
|
Utils::printLineEditInfo(editText.split('\n'));
|
||||||
|
|
||||||
ui->updateStatus->setPlainText(editText.trimmed());
|
ui->updateStatus->setPlainText(editText.trimmed());
|
||||||
ui->updateStatus->setEnabled(true);
|
scrollDownTextEdit();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::onReplaceLast(QStringList newTextLines, QString suffix) {
|
||||||
|
int const s = newTextLines.size();
|
||||||
|
if (s > 0) {
|
||||||
|
QString editText = ui->updateStatus->toPlainText();
|
||||||
|
QStringList lines = editText.split('\n');
|
||||||
|
QString newText;
|
||||||
|
if (lines.size() >= s) {
|
||||||
|
for (int i = 0; i < s; ++i) {
|
||||||
|
lines.removeLast();
|
||||||
|
}
|
||||||
|
if (lines.size() > 0) {
|
||||||
|
newText = lines.join('\n');
|
||||||
|
newText += '\n';
|
||||||
|
}
|
||||||
|
QStringList newLines;
|
||||||
|
for (int i = 0; i < s; ++i) {
|
||||||
|
if (i == 0 && !suffix.isNull() && suffix.size() > 0 && suffix != "\n") {
|
||||||
|
newLines += Utils::rstrip(newTextLines.at(i).leftJustified(m_width-10) + suffix);
|
||||||
|
} else {
|
||||||
|
newLines += Utils::rstrip(newTextLines.at(i).leftJustified(m_width-10));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
lines += newLines;
|
||||||
|
newText += newLines.join(' ');
|
||||||
|
}
|
||||||
|
|
||||||
|
ui->updateStatus->setText(newText);
|
||||||
|
Utils::printLineEditInfo(lines);
|
||||||
|
scrollDownTextEdit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onReplaceLast(QString text, QString suffix) {
|
void MainWindow::onReplaceLast(QString text, QString suffix) {
|
||||||
qInfo() << "REPL TEXT" << text << "SUFFIX" << suffix;
|
//qInfo() << "REPL TEXT" << text << "SUFFIX" << suffix;
|
||||||
|
|
||||||
QString editText = ui->updateStatus->toPlainText();
|
QString editText = ui->updateStatus->toPlainText();
|
||||||
QStringList lines = editText.split('\n');
|
QStringList lines = editText.split('\n');
|
||||||
if (lines.size() > 0) {
|
if (lines.size() > 0) {
|
||||||
@@ -171,27 +219,11 @@ void MainWindow::onReplaceLast(QString text, QString suffix) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Utils::printLineEditInfo(lines);
|
Utils::printLineEditInfo(lines);
|
||||||
|
|
||||||
ui->updateStatus->setText(lines.join('\n').trimmed());
|
ui->updateStatus->setText(lines.join('\n').trimmed());
|
||||||
ui->updateStatus->setEnabled(true);
|
scrollDownTextEdit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onShowErrorMessage(QString title, QString text) {
|
void MainWindow::onShowErrorMessage(QString title, QString text) {
|
||||||
text = text.leftJustified(50, ' ');
|
this->statusBar()->showMessage( // timeout: 5000
|
||||||
QMessageBox msgBox(QMessageBox::NoIcon, title,
|
QString(title + ": " + text).leftJustified(80, ' '), 20000);
|
||||||
text, QMessageBox::Ok,
|
|
||||||
nullptr, Qt::FramelessWindowHint);
|
|
||||||
msgBox.setDefaultButton(QMessageBox::Ok);
|
|
||||||
msgBox.defaultButton()->setVisible(false);
|
|
||||||
|
|
||||||
QTimer *t = new QTimer(this);
|
|
||||||
connect(t, SIGNAL(timeout()), msgBox.defaultButton(), SLOT(click()));
|
|
||||||
t->setSingleShot(true);
|
|
||||||
t->start(5 * 1000);
|
|
||||||
|
|
||||||
if(msgBox.exec() == QMessageBox::Ok) {
|
|
||||||
// do something
|
|
||||||
} else {
|
|
||||||
// do something else
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
#include <QStatusBar>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
namespace Ui { class MainWindow; }
|
namespace Ui { class MainWindow; }
|
||||||
@@ -27,6 +28,7 @@ public:
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void onAppendText(QString, QString suffix = "");
|
void onAppendText(QString, QString suffix = "");
|
||||||
|
void onReplaceLast(QStringList, QString suffix = "");
|
||||||
void onReplaceLast(QString, QString suffix = "");
|
void onReplaceLast(QString, QString suffix = "");
|
||||||
void onShowErrorMessage(QString, QString);
|
void onShowErrorMessage(QString, QString);
|
||||||
void onStopStartTimer();
|
void onStopStartTimer();
|
||||||
@@ -38,6 +40,8 @@ private slots:
|
|||||||
void onQuit();
|
void onQuit();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void scrollDownTextEdit();
|
||||||
|
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
Worker *m_worker;
|
Worker *m_worker;
|
||||||
int m_width;
|
int m_width;
|
||||||
|
@@ -25,7 +25,7 @@
|
|||||||
<x>10</x>
|
<x>10</x>
|
||||||
<y>10</y>
|
<y>10</y>
|
||||||
<width>781</width>
|
<width>781</width>
|
||||||
<height>461</height>
|
<height>441</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
@@ -55,6 +55,15 @@
|
|||||||
<bold>true</bold>
|
<bold>true</bold>
|
||||||
</font>
|
</font>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="verticalScrollBarPolicy">
|
||||||
|
<enum>Qt::ScrollBarAsNeeded</enum>
|
||||||
|
</property>
|
||||||
|
<property name="horizontalScrollBarPolicy">
|
||||||
|
<enum>Qt::ScrollBarAsNeeded</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeAdjustPolicy">
|
||||||
|
<enum>QAbstractScrollArea::AdjustToContents</enum>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
@@ -2,13 +2,15 @@
|
|||||||
|
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QDir>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
|
|
||||||
Command::Command(QString const &command, int start_timeout, int finish_timeout)
|
Command::Command(QString const &command, int start_timeout, int finish_timeout)
|
||||||
: m_command(command.trimmed())
|
: m_command(command.trimmed())
|
||||||
, m_commandResult("")
|
, m_commandResult("")
|
||||||
, m_waitForStartTimeout(start_timeout)
|
, m_waitForStartTimeout(start_timeout)
|
||||||
, m_waitForFinishTimeout(finish_timeout) {
|
, m_waitForFinishTimeout(finish_timeout)
|
||||||
|
, m_exitCode(-1) {
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Command::getCommandResult() const {
|
QString Command::getCommandResult() const {
|
||||||
@@ -39,46 +41,64 @@ void Command::finished(int /*exitCode*/, QProcess::ExitStatus /*exitStatus*/) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Command::execute(QString workingDirectory, QStringList args) {
|
bool Command::execute(QString workingDirectory, QStringList args) {
|
||||||
|
|
||||||
|
if (!QDir::setCurrent(workingDirectory)) {
|
||||||
|
qCritical() << "SET WORKING_DIRECTORY" << workingDirectory
|
||||||
|
<< "FAILED FOR" << m_command;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
QScopedPointer<QProcess> p(new QProcess(this));
|
QScopedPointer<QProcess> p(new QProcess(this));
|
||||||
|
p->setWorkingDirectory(workingDirectory);
|
||||||
p->setProcessChannelMode(QProcess::MergedChannels);
|
p->setProcessChannelMode(QProcess::MergedChannels);
|
||||||
|
|
||||||
connect(&(*p), SIGNAL(readyReadStandardOutput()), this, SLOT(readyReadStandardOutput()));
|
connect(&(*p), SIGNAL(readyReadStandardOutput()), this, SLOT(readyReadStandardOutput()));
|
||||||
connect(&(*p), SIGNAL(readyReadStandardError()), this, SLOT(readyReadStandardError()));
|
connect(&(*p), SIGNAL(readyReadStandardError()), this, SLOT(readyReadStandardError()));
|
||||||
|
|
||||||
//qCritical() << "START COMMAND" << m_command << "WITH ARGS" << args
|
|
||||||
// << "IN" << workingDirectory;
|
|
||||||
|
|
||||||
p->setWorkingDirectory(workingDirectory);
|
|
||||||
if (!args.isEmpty()) {
|
if (!args.isEmpty()) {
|
||||||
|
qDebug() << "START COMMAND" << m_command << "WITH ARGS" << args
|
||||||
|
<< "IN" << p->workingDirectory();
|
||||||
p->start(m_command, args);
|
p->start(m_command, args);
|
||||||
} else {
|
} else {
|
||||||
|
qDebug() << "START COMMAND" << m_command
|
||||||
|
<< "IN" << p->workingDirectory();
|
||||||
p->start(m_command);
|
p->start(m_command);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p->waitForStarted(m_waitForStartTimeout)) {
|
if (p->waitForStarted(m_waitForStartTimeout)) {
|
||||||
//qDebug() << "PROCESS" << m_command << "STARTED";
|
qDebug() << "PROCESS" << m_command << "STARTED IN" << p->workingDirectory();
|
||||||
if (p->state() == QProcess::ProcessState::Running) {
|
if (p->state() == QProcess::ProcessState::Running) {
|
||||||
//qDebug() << "PROCESS" << m_command << "RUNNING";
|
qDebug() << "PROCESS" << m_command << "RUNNING IN" << p->workingDirectory();
|
||||||
if (p->waitForFinished(m_waitForFinishTimeout)) {
|
if (p->waitForFinished(m_waitForFinishTimeout)) {
|
||||||
//qDebug() << "PROCESS" << m_command << "FINISHED";
|
qDebug() << "PROCESS" << m_command << "FINISHED IN" << p->workingDirectory();
|
||||||
if (p->exitStatus() == QProcess::NormalExit) {
|
if (p->exitStatus() == QProcess::NormalExit) {
|
||||||
if (p->exitCode() == 0) {
|
if ((m_exitCode = p->exitCode()) == 0) {
|
||||||
|
qDebug() << "EXECUTED" << m_command
|
||||||
|
<< "with code" << m_exitCode
|
||||||
|
<< "IN" << p->workingDirectory();
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
qCritical() << "EXECUTED" << m_command << "with code" << p->exitCode();
|
qCritical() << "EXECUTED" << m_command
|
||||||
|
<< "with code" << m_exitCode
|
||||||
|
<< "IN" << p->workingDirectory();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
qCritical() << "PROCESS" << m_command << "CRASHED with code"
|
qCritical() << "PROCESS" << m_command << "CRASHED with code"
|
||||||
<< p->exitCode();
|
<< p->exitCode()
|
||||||
|
<< "IN" << p->workingDirectory();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
qCritical() << "PROCESS" << m_command << "DID NOT FINISH";
|
qCritical() << "PROCESS" << m_command
|
||||||
|
<< "DID NOT FINISH"
|
||||||
|
<< "IN" << p->workingDirectory();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
qCritical() << "WRONG PROCESS STATE" << p->state();
|
qCritical() << "WRONG PROCESS STATE" << p->state()
|
||||||
|
<< "IN" << p->workingDirectory();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
qCritical() << "PROCESS" << m_command << "TIMEOUT AT START";
|
qCritical() << "PROCESS" << m_command << "TIMEOUT AT START"
|
||||||
|
<< "IN" << p->workingDirectory();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@@ -16,15 +16,17 @@ class Command : public QObject {
|
|||||||
QString m_commandResult;
|
QString m_commandResult;
|
||||||
int m_waitForStartTimeout;
|
int m_waitForStartTimeout;
|
||||||
int m_waitForFinishTimeout;
|
int m_waitForFinishTimeout;
|
||||||
|
int m_exitCode;
|
||||||
public:
|
public:
|
||||||
explicit Command(QString const &command,
|
explicit Command(QString const &command,
|
||||||
int start_timeout = 100000,
|
int start_timeout = 100000,
|
||||||
int finish_timeout = 100000);
|
int finish_timeout = 100000);
|
||||||
|
|
||||||
QString getCommandResult() const;
|
QString getCommandResult() const;
|
||||||
|
QString command() const { return m_command; }
|
||||||
|
|
||||||
bool execute(QString workingDirectory, QStringList args = QStringList());
|
bool execute(QString workingDirectory, QStringList args = QStringList());
|
||||||
|
int exitCode() const { return m_exitCode; }
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void readyReadStandardOutput();
|
void readyReadStandardOutput();
|
||||||
|
@@ -77,3 +77,12 @@ QString Utils::getTariffLoadTime(QString fileName) {
|
|||||||
return "N/A";
|
return "N/A";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString Utils::rstrip(QString const &str) {
|
||||||
|
int n = str.size() - 1;
|
||||||
|
for (; n >= 0; --n) {
|
||||||
|
if (!str.at(n).isSpace()) {
|
||||||
|
return str.left(n + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
1
utils.h
1
utils.h
@@ -15,6 +15,7 @@ namespace Utils {
|
|||||||
void printInfoMsg(QString const &infoMsg);
|
void printInfoMsg(QString const &infoMsg);
|
||||||
void printLineEditInfo(QStringList const &lines);
|
void printLineEditInfo(QStringList const &lines);
|
||||||
QString getTariffLoadTime(QString fileName);
|
QString getTariffLoadTime(QString fileName);
|
||||||
|
QString rstrip(QString const &str);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // UTILS_H_INCLUDED
|
#endif // UTILS_H_INCLUDED
|
||||||
|
477
worker.cpp
477
worker.cpp
@@ -169,7 +169,7 @@ void Worker::privateUpdate() {
|
|||||||
int progress = (m_mainWindow->progressValue()/10) + 10;
|
int progress = (m_mainWindow->progressValue()/10) + 10;
|
||||||
setProgress(progress);
|
setProgress(progress);
|
||||||
|
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::UPDATE_PROCESS_SUCCESS,
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_CLONE_AND_CHECKOUT_SUCCESS,
|
||||||
QString("CLONED AND CHECKED OUT: ") + m_customerRepository);
|
QString("CLONED AND CHECKED OUT: ") + m_customerRepository);
|
||||||
|
|
||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
@@ -197,7 +197,7 @@ void Worker::privateUpdate() {
|
|||||||
|
|
||||||
emit replaceLast("Initializing customer environment", UPDATE_STEP_FAIL);
|
emit replaceLast("Initializing customer environment", UPDATE_STEP_FAIL);
|
||||||
|
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::UPDATE_PROCESS_FAILURE,
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_CLONE_AND_CHECKOUT_FAILURE,
|
||||||
QString("CLONE OR CHECKOUT FAILED: ") + m_customerRepository);
|
QString("CLONE OR CHECKOUT FAILED: ") + m_customerRepository);
|
||||||
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=") +
|
||||||
@@ -295,7 +295,7 @@ void Worker::privateUpdate() {
|
|||||||
m_returnCode = -7;
|
m_returnCode = -7;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_CHECKOUT_BRANCH_REQUEST_FAILURE,
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_CHECKOUT_BRANCH_FAILURE,
|
||||||
QString("Configuring customer environment failed"));
|
QString("Configuring customer environment failed"));
|
||||||
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=") +
|
||||||
@@ -315,7 +315,7 @@ void Worker::privateUpdate() {
|
|||||||
m_returnCode = -5;
|
m_returnCode = -5;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_BACKEND_CHECK_FAILURE,
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::BACKEND_CHECK_FAILURE,
|
||||||
QString("ISMAS backend not available"));
|
QString("ISMAS backend not available"));
|
||||||
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=") +
|
||||||
@@ -327,20 +327,38 @@ void Worker::privateUpdate() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_ismasClient.setProgressInPercent(100);
|
m_ismasClient.setProgressInPercent(100);
|
||||||
|
setProgress(100);
|
||||||
|
|
||||||
|
if (m_returnCode != 0) {
|
||||||
|
stopProgressLoop();
|
||||||
|
emit appendText(QString("UPDATE "), UPDATE_STEP_FAIL);
|
||||||
|
|
||||||
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::UPDATE_PROCESS_FAILURE,
|
||||||
|
QString("Update process failed"));
|
||||||
|
if (std::optional<QString> s = m_ismasClient.finalResult(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
||||||
|
"FINAL-UPDATE-RESULT",
|
||||||
|
m_updateStatus.m_statusDescription)) {
|
||||||
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
|
QString("#M=APISM#C=CMD_EVENT#J=") + s.value());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
emit appendText(QString("UPDATE "), UPDATE_STEP_SUCCESS);
|
||||||
|
|
||||||
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::UPDATE_PROCESS_SUCCESS,
|
||||||
|
QString("Update process succeeded"));
|
||||||
|
if (std::optional<QString> s = m_ismasClient.finalResult(IsmasClient::RESULT_CODE::SUCCESS,
|
||||||
|
"FINAL-UPDATE-RESULT",
|
||||||
|
m_updateStatus.m_statusDescription)) {
|
||||||
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
|
QString("#M=APISM#C=CMD_EVENT#J=") + s.value());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!sentIsmasLastVersionNotification) {
|
if (!sentIsmasLastVersionNotification) {
|
||||||
// try even if the backend is not connected
|
// try even if the backend is not connected
|
||||||
sendIsmasLastVersionNotification();
|
sendIsmasLastVersionNotification();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_returnCode != 0) {
|
|
||||||
stopProgressLoop();
|
|
||||||
emit appendText(QString("UPDATE "), UPDATE_STEP_FAIL);
|
|
||||||
} else {
|
|
||||||
emit appendText(QString("UPDATE "), UPDATE_STEP_SUCCESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
setProgress(100);
|
|
||||||
m_updateProcessRunning = false;
|
m_updateProcessRunning = false;
|
||||||
emit enableExit();
|
emit enableExit();
|
||||||
emit restartExitTimer();
|
emit restartExitTimer();
|
||||||
@@ -355,7 +373,7 @@ bool Worker::backendConnected() {
|
|||||||
emit appendText("\nConnecting backend ...");
|
emit appendText("\nConnecting backend ...");
|
||||||
|
|
||||||
if (false) { // so linker removes dead code
|
if (false) { // so linker removes dead code
|
||||||
for (int repeat = 0; repeat < 50; ++repeat) {
|
for (int repeat = 0; repeat < 100; ++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();
|
||||||
std::optional<QString> result
|
std::optional<QString> result
|
||||||
@@ -479,17 +497,34 @@ bool Worker::backendConnected() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define CHECK_UPDATE_TRIGGER_SET "Check update trigger ..."
|
||||||
|
|
||||||
bool Worker::updateTriggerSet() {
|
bool Worker::updateTriggerSet() {
|
||||||
if (m_withoutIsmasDirectPort) { // useful for testing
|
if (m_withoutIsmasDirectPort) { // useful for testing
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
emit appendText("\nUpdate trigger set ...");
|
emit appendText("\n" CHECK_UPDATE_TRIGGER_SET);
|
||||||
QString triggerValue("");
|
QString triggerValue("");
|
||||||
|
int const startMs = QTime::currentTime().msecsSinceStartOfDay();
|
||||||
|
|
||||||
for (int repeat = 0; repeat < 50; ++repeat) {
|
for (int repeat = 1; repeat <= 100; ++repeat) {
|
||||||
qInfo() << "UPDATE TRIGGER SET -> REPEAT" << repeat;
|
qInfo() << "UPDATE TRIGGER SET -> REPEAT" << repeat;
|
||||||
|
|
||||||
|
if (repeat > 1) {
|
||||||
|
int const durationMs = QTime::currentTime().msecsSinceStartOfDay() - startMs;
|
||||||
|
qInfo() << "REPEAT" << repeat
|
||||||
|
<< QString("DURATION: %1.%2s").arg(durationMs / 1000).arg(durationMs % 1000);
|
||||||
|
}
|
||||||
|
if ((repeat % 10) == 0) {
|
||||||
|
qInfo() << "CHECK UPDATE TRIGGER. RESTART APISM ...";
|
||||||
|
Command c("systemctl restart apism");
|
||||||
|
if (c.execute("/tmp")) {
|
||||||
|
QThread::sleep(20); // give APISM some time to reconnect
|
||||||
|
qInfo() << "CHECK UPDATE TRIGGER. RESTARTING APISM DONE";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
startProgressLoop();
|
startProgressLoop();
|
||||||
if (std::optional<QString> result
|
if (std::optional<QString> result
|
||||||
= IsmasClient::sendRequestReceiveResponse(
|
= IsmasClient::sendRequestReceiveResponse(
|
||||||
@@ -500,7 +535,7 @@ bool Worker::updateTriggerSet() {
|
|||||||
|
|
||||||
QString msg = result.value();
|
QString msg = result.value();
|
||||||
|
|
||||||
qInfo() << "REPEAT" << repeat << "APISM RESPONSE" << msg;
|
qInfo() << "REPEAT" << repeat << "APISM RESPONSE (" << msg << ")";
|
||||||
|
|
||||||
QJsonParseError parseError;
|
QJsonParseError parseError;
|
||||||
QJsonDocument document(QJsonDocument::fromJson(msg.toUtf8(), &parseError));
|
QJsonDocument document(QJsonDocument::fromJson(msg.toUtf8(), &parseError));
|
||||||
@@ -519,7 +554,7 @@ bool Worker::updateTriggerSet() {
|
|||||||
m_updateStatus.m_statusDescription));
|
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(CHECK_UPDATE_TRIGGER_SET, UPDATE_STEP_FAIL);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!document.isObject()) {
|
if (!document.isObject()) {
|
||||||
@@ -532,13 +567,25 @@ bool Worker::updateTriggerSet() {
|
|||||||
m_ismasClient.jsonParseFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
m_ismasClient.jsonParseFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
||||||
m_updateStatus.m_statusDescription));
|
m_updateStatus.m_statusDescription));
|
||||||
emit showErrorMessage("check update trigger", QString("not a json object") + msg);
|
emit showErrorMessage("check update trigger", QString("not a json object") + msg);
|
||||||
emit replaceLast("Update trigger set ...", UPDATE_STEP_FAIL);
|
emit replaceLast(CHECK_UPDATE_TRIGGER_SET, UPDATE_STEP_FAIL);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
progress += 1;
|
progress += 1;
|
||||||
setProgress(progress);
|
setProgress(progress);
|
||||||
|
|
||||||
QJsonObject obj = document.object();
|
QJsonObject obj = document.object();
|
||||||
|
|
||||||
|
// always look for an 'error' first
|
||||||
|
if (obj.contains("error")) {
|
||||||
|
progress += 1;
|
||||||
|
setProgress(progress);
|
||||||
|
QString value = obj.value("error").toString();
|
||||||
|
emit showErrorMessage("check update trigger", QString("REPEAT %1 error=<").arg(repeat) + value + ">");
|
||||||
|
qInfo() << "REPEAT" << repeat << "In updateTriggerSet() error=<"
|
||||||
|
<< value << ">";
|
||||||
|
QThread::sleep(6);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
// sanity check: cust_nr and machine_nr of PSA correct ?
|
// sanity check: cust_nr and machine_nr of PSA correct ?
|
||||||
// note: this check has to be done here, as the cust_nr and the machine_nr
|
// note: this check has to be done here, as the cust_nr and the machine_nr
|
||||||
// of the PSA are sent by ISMAS.
|
// of the PSA are sent by ISMAS.
|
||||||
@@ -561,7 +608,7 @@ bool Worker::updateTriggerSet() {
|
|||||||
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 showErrorMessage("check update trigger", m_updateStatus.m_statusDescription);
|
||||||
emit replaceLast("Update trigger set ...", UPDATE_STEP_FAIL);
|
emit replaceLast(CHECK_UPDATE_TRIGGER_SET, UPDATE_STEP_FAIL);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (machineNr != m_machineNr) {
|
if (machineNr != m_machineNr) {
|
||||||
@@ -574,7 +621,7 @@ bool Worker::updateTriggerSet() {
|
|||||||
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 showErrorMessage("check update trigger", m_updateStatus.m_statusDescription);
|
||||||
emit replaceLast("Update trigger set ...", UPDATE_STEP_FAIL);
|
emit replaceLast(CHECK_UPDATE_TRIGGER_SET, UPDATE_STEP_FAIL);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -589,7 +636,7 @@ bool Worker::updateTriggerSet() {
|
|||||||
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 showErrorMessage("check update trigger", m_updateStatus.m_statusDescription);
|
||||||
emit replaceLast("Update trigger set ...", UPDATE_STEP_FAIL);
|
emit replaceLast(CHECK_UPDATE_TRIGGER_SET, UPDATE_STEP_FAIL);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -601,7 +648,7 @@ bool Worker::updateTriggerSet() {
|
|||||||
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 showErrorMessage("check update trigger", m_updateStatus.m_statusDescription);
|
||||||
emit replaceLast("Update trigger set ...", UPDATE_STEP_FAIL);
|
emit replaceLast(CHECK_UPDATE_TRIGGER_SET, UPDATE_STEP_FAIL);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -613,7 +660,7 @@ bool Worker::updateTriggerSet() {
|
|||||||
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 showErrorMessage("check update trigger", m_updateStatus.m_statusDescription);
|
||||||
emit replaceLast("Update trigger set ...", UPDATE_STEP_FAIL);
|
emit replaceLast(CHECK_UPDATE_TRIGGER_SET, UPDATE_STEP_FAIL);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
progress += 1;
|
progress += 1;
|
||||||
@@ -640,25 +687,34 @@ bool Worker::updateTriggerSet() {
|
|||||||
m_ismasClient.updateOfPSAContinues("MACHINE-AND-CUSTOMER-CHECK",
|
m_ismasClient.updateOfPSAContinues("MACHINE-AND-CUSTOMER-CHECK",
|
||||||
m_updateStatus.m_statusDescription));
|
m_updateStatus.m_statusDescription));
|
||||||
|
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::UPDATE_TRIGGER_SET,
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_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, ""));
|
||||||
|
|
||||||
emit replaceLast("Update trigger set ...", UPDATE_STEP_OK);
|
emit replaceLast(CHECK_UPDATE_TRIGGER_SET, UPDATE_STEP_DONE);
|
||||||
return true;
|
return true;
|
||||||
|
} else
|
||||||
|
if (QRegExp("\\s*").exactMatch(triggerValue)) { // check for whitespace
|
||||||
|
stopProgressLoop();
|
||||||
|
int progress = (m_mainWindow->progressValue()/10) + 10;
|
||||||
|
progress += 1;
|
||||||
|
setProgress(progress);
|
||||||
|
emit showErrorMessage("check update trigger", "empty update-trigger");
|
||||||
|
QThread::sleep(6);
|
||||||
|
continue;
|
||||||
} else {
|
} else {
|
||||||
// if the download-button once has the wrong value, it will never recover
|
// if the download-button once has the wrong value, it will never recover
|
||||||
setProgress(100);
|
setProgress(100);
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_FAILURE,
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_FAILURE,
|
||||||
QString("TRIGGER-VALUE ") + triggerValue + " NOT 'WAIT'");
|
QString("TRIGGER-VALUE=<") + triggerValue + "> NOT 'WAIT'");
|
||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
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 showErrorMessage("check update trigger", m_updateStatus.m_statusDescription);
|
||||||
emit replaceLast("Update trigger set ...", UPDATE_STEP_FAIL);
|
emit replaceLast(CHECK_UPDATE_TRIGGER_SET, UPDATE_STEP_FAIL);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -669,7 +725,7 @@ bool Worker::updateTriggerSet() {
|
|||||||
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 replaceLast("Update trigger set ...", UPDATE_STEP_FAIL);
|
emit replaceLast(CHECK_UPDATE_TRIGGER_SET, UPDATE_STEP_FAIL);
|
||||||
emit showErrorMessage("check update trigger", m_updateStatus.m_statusDescription);
|
emit showErrorMessage("check update trigger", m_updateStatus.m_statusDescription);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -681,7 +737,7 @@ bool Worker::updateTriggerSet() {
|
|||||||
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 replaceLast("Update trigger set ...", UPDATE_STEP_FAIL);
|
emit replaceLast(CHECK_UPDATE_TRIGGER_SET, UPDATE_STEP_FAIL);
|
||||||
emit showErrorMessage("check update trigger", m_updateStatus.m_statusDescription);
|
emit showErrorMessage("check update trigger", m_updateStatus.m_statusDescription);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -693,20 +749,10 @@ bool Worker::updateTriggerSet() {
|
|||||||
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 replaceLast("Update trigger set ...", UPDATE_STEP_FAIL);
|
emit replaceLast(CHECK_UPDATE_TRIGGER_SET, UPDATE_STEP_FAIL);
|
||||||
emit showErrorMessage("check update trigger", m_updateStatus.m_statusDescription);
|
emit showErrorMessage("check update trigger", m_updateStatus.m_statusDescription);
|
||||||
return false;
|
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 {
|
} else {
|
||||||
stopProgressLoop();
|
stopProgressLoop();
|
||||||
int progress = (m_mainWindow->progressValue()/10) + 10;
|
int progress = (m_mainWindow->progressValue()/10) + 10;
|
||||||
@@ -718,14 +764,14 @@ bool Worker::updateTriggerSet() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setProgress(100);
|
setProgress(100);
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::UPDATE_TRIGGER_NOT_SET_OR_WRONG,
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_UPDATE_TRIGGER_NOT_SET_OR_WRONG,
|
||||||
QString("UPDATE-TRIGGER-NOT-SET-OR-WRONG: VALUE=(") +
|
QString("ISMAS_UPDATE-TRIGGER-NOT-SET-OR-WRONG: VALUE=(") +
|
||||||
triggerValue + ")");
|
triggerValue + ")");
|
||||||
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.errorUpdateTrigger(m_updateStatus.m_statusDescription, ""));
|
m_ismasClient.errorUpdateTrigger(m_updateStatus.m_statusDescription, ""));
|
||||||
|
|
||||||
emit replaceLast("Update trigger set ...", UPDATE_STEP_OK);
|
emit replaceLast(CHECK_UPDATE_TRIGGER_SET, UPDATE_STEP_FAIL);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -845,14 +891,18 @@ bool Worker::updateFiles(quint8 percent) {
|
|||||||
if (f.open(QIODevice::ReadOnly)) {
|
if (f.open(QIODevice::ReadOnly)) {
|
||||||
QTextStream in(&f);
|
QTextStream in(&f);
|
||||||
int cmdCount = 0;
|
int cmdCount = 0;
|
||||||
|
QStringList opkgCommands;
|
||||||
while (!in.atEnd()) {
|
while (!in.atEnd()) {
|
||||||
QString line = in.readLine();
|
QString line = in.readLine();
|
||||||
static const QRegularExpression comment("^\\s*#.*$");
|
static const QRegularExpression comment("^\\s*#.*$");
|
||||||
if (line.indexOf(comment, 0) == -1) {
|
if (line.indexOf(comment, 0) == -1) {
|
||||||
// found opkg command
|
// found opkg command
|
||||||
QString opkgCommand = line.trimmed();
|
QString opkgCommand = line.trimmed();
|
||||||
executeOpkgCommand(opkgCommand);
|
|
||||||
++cmdCount;
|
++cmdCount;
|
||||||
|
executeOpkgCommand(opkgCommand);
|
||||||
|
QString cmd = "\n " + opkgCommand;
|
||||||
|
emit appendText(cmd);
|
||||||
|
opkgCommands << cmd;
|
||||||
|
|
||||||
m_ismasClient.setProgressInPercent(++percent);
|
m_ismasClient.setProgressInPercent(++percent);
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::EXEC_OPKG_COMMAND,
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::EXEC_OPKG_COMMAND,
|
||||||
@@ -865,8 +915,10 @@ bool Worker::updateFiles(quint8 percent) {
|
|||||||
f.close();
|
f.close();
|
||||||
if (cmdCount > 0) {
|
if (cmdCount > 0) {
|
||||||
m_displayIndex = 1;
|
m_displayIndex = 1;
|
||||||
emit replaceLast(QString("(") + QString("%1").arg(m_displayIndex).rightJustified(2, ' ') + QString(")")
|
QString prepend = QString("(") + QString("%1").arg(m_displayIndex).rightJustified(2, ' ') + QString(")")
|
||||||
+ QString(" Update opkg pakets ... "), UPDATE_STEP_DONE);
|
+ QString(" Update opkg pakets ... ");
|
||||||
|
opkgCommands.prepend(prepend);
|
||||||
|
emit replaceLast(opkgCommands, UPDATE_STEP_DONE);
|
||||||
} else {
|
} else {
|
||||||
m_displayIndex = 1;
|
m_displayIndex = 1;
|
||||||
emit replaceLast(QString("(") + QString("%1").arg(m_displayIndex).rightJustified(2, ' ') + QString(")")
|
emit replaceLast(QString("(") + QString("%1").arg(m_displayIndex).rightJustified(2, ' ') + QString(")")
|
||||||
@@ -901,10 +953,16 @@ bool Worker::updateFiles(quint8 percent) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Worker::syncCustomerRepositoryAndFS() {
|
bool Worker::syncCustomerRepositoryAndFS() {
|
||||||
|
// this step is currently needed only for updating tariff-files
|
||||||
setProgress(0);
|
setProgress(0);
|
||||||
emit appendText("\nSync customer environment with filesystem ...");
|
emit appendText("\nSync customer environment with filesystem ...");
|
||||||
if (QDir(m_customerRepository).exists()) {
|
if (QDir(m_customerRepository).exists()) {
|
||||||
if (QDir::setCurrent(m_customerRepository)) {
|
if (QDir::setCurrent(m_customerRepository)) {
|
||||||
|
Command md("bash");
|
||||||
|
if (!md.execute(m_customerRepository,
|
||||||
|
QStringList() << "-c" << "mkdir -p /etc/psa_config /etc/psa_update /etc/dc /etc/psa_tariff")) {
|
||||||
|
qCritical() << "COULD NOT EXECUTE '" << md.command() << "' exitCode=(" << md.exitCode() << ")";
|
||||||
|
}
|
||||||
int progress = 10;
|
int progress = 10;
|
||||||
setProgress(progress);
|
setProgress(progress);
|
||||||
QString const params("-vv "
|
QString const params("-vv "
|
||||||
@@ -935,7 +993,7 @@ bool Worker::syncCustomerRepositoryAndFS() {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Utils::printCriticalErrorMsg(QString("CMD ") + cmd + " FAILED: "
|
Utils::printCriticalErrorMsg(QString("CMD ") + cmd + " FAILED: "
|
||||||
+ c.getCommandResult());
|
+ c.getCommandResult() + QString(" EXIT_CODE=(%1)").arg(c.exitCode()));
|
||||||
error = true;
|
error = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1080,6 +1138,17 @@ PSAInstalled Worker::getPSAInstalled() {
|
|||||||
QString absPathName;
|
QString absPathName;
|
||||||
QString absPathNameRepository;
|
QString absPathNameRepository;
|
||||||
|
|
||||||
|
psaInstalled.versionInfo.lastCommit = "";
|
||||||
|
psaInstalled.versionInfo.reason = "";
|
||||||
|
psaInstalled.versionInfo.created = "";
|
||||||
|
|
||||||
|
QStringList versionInfo = m_gc.gitShowReason();
|
||||||
|
if (versionInfo.size() == 3) {
|
||||||
|
psaInstalled.versionInfo.lastCommit = versionInfo.at(0);
|
||||||
|
psaInstalled.versionInfo.reason = versionInfo.at(1);
|
||||||
|
psaInstalled.versionInfo.created = versionInfo.at(2);
|
||||||
|
}
|
||||||
|
|
||||||
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);
|
||||||
@@ -1142,89 +1211,95 @@ PSAInstalled Worker::getPSAInstalled() {
|
|||||||
return psaInstalled;
|
return psaInstalled;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Worker::sendCmdSendVersionToIsmas() {
|
|
||||||
|
|
||||||
QStringList const dcVersion = getDCVersion();
|
|
||||||
QString const deviceControllerVersionHW = dcVersion.first();
|
|
||||||
QString const deviceControllerVersionSW = dcVersion.last();
|
|
||||||
|
|
||||||
qInfo() << "CURRENT DC-HW-VERSION: " << deviceControllerVersionHW;
|
|
||||||
qInfo() << "CURRENT DC-SW-VERSION: " << deviceControllerVersionSW;
|
|
||||||
|
|
||||||
QString const deviceControllerGitBlob = "N/A";
|
|
||||||
QString const deviceControllerGitLastCommit = "N/A";
|
|
||||||
|
|
||||||
PSAInstalled psaInstalled;
|
|
||||||
QString printSysDir("/etc/psa_config");
|
|
||||||
QString tariffSysDir("/etc/psa_tariff");
|
|
||||||
QString absPathName;
|
|
||||||
|
|
||||||
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);
|
|
||||||
psaInstalled.tariff.size = getFileSize(absPathName);
|
|
||||||
psaInstalled.tariff.zone = m_zoneNr;
|
|
||||||
}
|
|
||||||
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;
|
|
||||||
psaInstalled.hw.cpuSerial = m_cpuSerial;
|
|
||||||
|
|
||||||
psaInstalled.dc.versionHW = deviceControllerVersionHW;
|
|
||||||
psaInstalled.dc.versionSW = deviceControllerVersionSW;
|
|
||||||
psaInstalled.dc.gitBlob = "N/A";
|
|
||||||
psaInstalled.dc.gitLastCommit = "N/A";
|
|
||||||
psaInstalled.dc.size = -1;
|
|
||||||
|
|
||||||
psaInstalled.sw.raucVersion = m_raucVersion;
|
|
||||||
psaInstalled.sw.opkgVersion = m_opkgVersion;
|
|
||||||
psaInstalled.sw.atbQTVersion = m_atbqtVersion;
|
|
||||||
|
|
||||||
psaInstalled.pluginVersion.deviceController = m_pluginVersionATBDeciceController;
|
|
||||||
psaInstalled.pluginVersion.ingenicoISelfCC = m_pluginVersionIngenicoISelf;
|
|
||||||
psaInstalled.pluginVersion.mobilisisCalculatePrice = m_pluginVersionMobilisisCalc;
|
|
||||||
psaInstalled.pluginVersion.mobilisisCalculatePriceConfigUi = m_pluginVersionMobilisisCalcConfig;
|
|
||||||
psaInstalled.pluginVersion.prmCalculatePrice = m_pluginVersionPrmCalc;
|
|
||||||
psaInstalled.pluginVersion.prmCalculatePriceConfigUi = m_pluginVersionPrmCalcConfig;
|
|
||||||
psaInstalled.pluginVersion.tcpZVT = m_pluginVersionTcpZvt;
|
|
||||||
|
|
||||||
psaInstalled.cash.name = "DC2C_cash.json";
|
|
||||||
absPathName = QDir::cleanPath(printSysDir + QDir::separator() + psaInstalled.cash.name);
|
|
||||||
psaInstalled.cash.blob = m_gc.gitBlob(absPathName);
|
|
||||||
psaInstalled.cash.size = getFileSize(absPathName);
|
|
||||||
|
|
||||||
psaInstalled.conf.name = "DC2C_conf.json";
|
|
||||||
absPathName = QDir::cleanPath(printSysDir + QDir::separator() + psaInstalled.conf.name);
|
|
||||||
psaInstalled.conf.blob = m_gc.gitBlob(absPathName);
|
|
||||||
psaInstalled.conf.size = getFileSize(absPathName);
|
|
||||||
|
|
||||||
psaInstalled.device.name = "DC2C_device.json";
|
|
||||||
absPathName = QDir::cleanPath(printSysDir + QDir::separator() + psaInstalled.device.name);
|
|
||||||
psaInstalled.device.blob = m_gc.gitBlob(absPathName);
|
|
||||||
psaInstalled.device.size = getFileSize(absPathName);
|
|
||||||
|
|
||||||
for (int i=0; i < 32; ++i) {
|
|
||||||
QString const &n = QString("%1").arg(i+1).rightJustified(2, '0');
|
|
||||||
psaInstalled.print[i].name = QString("DC2C_print%1.json").arg(n);
|
|
||||||
absPathName = QDir::cleanPath(printSysDir + QDir::separator() + psaInstalled.print[i].name);
|
|
||||||
psaInstalled.print[i].blob = m_gc.gitBlob(absPathName);
|
|
||||||
psaInstalled.print[i].size = getFileSize(absPathName);
|
|
||||||
}
|
|
||||||
|
|
||||||
// QByteArray data = "#M=APISM#C=CMD_SENDVERSION#J=";
|
|
||||||
return m_ismasClient.updateOfPSASendVersion(psaInstalled);
|
|
||||||
}
|
|
||||||
|
|
||||||
/************************************************************************************************
|
/************************************************************************************************
|
||||||
* operators
|
* operators
|
||||||
*/
|
*/
|
||||||
QDebug operator<< (QDebug debug, UpdateStatus status) {
|
QDebug operator<< (QDebug debug, UpdateStatus status) {
|
||||||
switch(status.m_updateStatus) {
|
switch(status.m_updateStatus) {
|
||||||
|
case UPDATE_STATUS::ISMAS_SEND_LAST_VERSION_FAILED:
|
||||||
|
debug << QString("UPDATE_STATUS::ISMAS_SEND_LAST_VERSION_FAILED: ")
|
||||||
|
<< status.m_statusDescription;
|
||||||
|
break;
|
||||||
|
case UPDATE_STATUS::SAVE_LOG_FILES_FAILED:
|
||||||
|
debug << QString("UPDATE_STATUS::SAVE_LOG_FILES_FAILED: ")
|
||||||
|
<< status.m_statusDescription;
|
||||||
|
break;
|
||||||
|
case UPDATE_STATUS::GIT_CHECK_FILES_TO_UPDATE_SUCCESS:
|
||||||
|
debug << QString("UPDATE_STATUS::GIT_CHECK_FILES_TO_UPDATE_SUCCESS: ")
|
||||||
|
<< status.m_statusDescription;
|
||||||
|
break;
|
||||||
|
case UPDATE_STATUS::PSA_UPDATE_FILES_FAILED:
|
||||||
|
debug << QString("UPDATE_STATUS::PSA_UPDATE_FILES_FAILED: ")
|
||||||
|
<< status.m_statusDescription;
|
||||||
|
break;
|
||||||
|
case UPDATE_STATUS::RSYNC_UPDATES_SUCCESS:
|
||||||
|
debug << QString("UPDATE_STATUS::RSYNC_UPDATES_SUCCESS: ")
|
||||||
|
<< status.m_statusDescription;
|
||||||
|
break;
|
||||||
|
case UPDATE_STATUS::RSYNC_UPDATES_FAILURE:
|
||||||
|
debug << QString("UPDATE_STATUS::RSYNC_UPDATES_FAILURE: ")
|
||||||
|
<< status.m_statusDescription;
|
||||||
|
break;
|
||||||
|
case UPDATE_STATUS::EXEC_OPKG_COMMAND:
|
||||||
|
debug << QString("UPDATE_STATUS::EXEC_OPKG_COMMAND: ")
|
||||||
|
<< status.m_statusDescription;
|
||||||
|
break;
|
||||||
|
case UPDATE_STATUS::GIT_CLONE_AND_CHECKOUT_SUCCESS:
|
||||||
|
debug << QString("UPDATE_STATUS::GIT_CLONE_AND_CHECKOUT_SUCCESS: ")
|
||||||
|
<< status.m_statusDescription;
|
||||||
|
break;
|
||||||
|
case UPDATE_STATUS::GIT_CLONE_AND_CHECKOUT_FAILURE:
|
||||||
|
debug << QString("UPDATE_STATUS::GIT_CLONE_AND_CHECKOUT_FAILURE: ")
|
||||||
|
<< status.m_statusDescription;
|
||||||
|
break;
|
||||||
|
case UPDATE_STATUS::NOT_DEFINED:
|
||||||
|
debug << QString("UPDATE_STATUS::NOT_DEFINED: ")
|
||||||
|
<< status.m_statusDescription;
|
||||||
|
break;
|
||||||
|
case UPDATE_STATUS::UPDATE_PROCESS_FAILURE:
|
||||||
|
debug << QString("UPDATE_STATUS::UPDATE_PROCESS_FAILURE: ")
|
||||||
|
<< status.m_statusDescription;
|
||||||
|
break;
|
||||||
|
case UPDATE_STATUS::ISMAS_UPDATE_TRIGGER_SET_FAILURE:
|
||||||
|
debug << QString("UPDATE_STATUS::ISMAS_UPDATE_TRIGGER_FAILURE: ")
|
||||||
|
<< status.m_statusDescription;
|
||||||
|
break;
|
||||||
|
case UPDATE_STATUS::GIT_CHECKOUT_BRANCH_FAILURE:
|
||||||
|
debug << QString("UPDATE_STATUS::GIT_CHECKOUT_BRANCH_FAILURE: ")
|
||||||
|
<< status.m_statusDescription;
|
||||||
|
break;
|
||||||
|
case UPDATE_STATUS::GIT_CHECKOUT_BRANCH:
|
||||||
|
debug << QString("UPDATE_STATUS::GIT_CHECKOUT_BRANCH: ")
|
||||||
|
<< status.m_statusDescription;
|
||||||
|
break;
|
||||||
|
case UPDATE_STATUS::ISMAS_UPDATE_TRIGGER_NOT_SET_OR_WRONG:
|
||||||
|
debug << QString("UPDATE_STATUS::ISMAS_UPDATE_TRIGGER_NOT_SET_OR_WRONG: ")
|
||||||
|
<< status.m_statusDescription;
|
||||||
|
break;
|
||||||
|
case UPDATE_STATUS::ISMAS_UPDATE_TRIGGER_SET:
|
||||||
|
debug << QString("UPDATE_STATUS::ISMAS_UPDATE_TRIGGER_SET: ")
|
||||||
|
<< status.m_statusDescription;
|
||||||
|
break;
|
||||||
|
case UPDATE_STATUS::ISMAS_SANITY_CHECK_OK:
|
||||||
|
debug << QString("UPDATE_STATUS::ISMAS_SANITY_CHECK_OK: ")
|
||||||
|
<< status.m_statusDescription;
|
||||||
|
break;
|
||||||
|
case UPDATE_STATUS::JSON_PARSE_FAILURE:
|
||||||
|
debug << QString("UPDATE_STATUS::JSON_PARSE_FAILURE: ")
|
||||||
|
<< status.m_statusDescription;
|
||||||
|
break;
|
||||||
|
case UPDATE_STATUS::BACKEND_CHECK:
|
||||||
|
debug << QString("UPDATE_STATUS::BACKEND_CHECK: ")
|
||||||
|
<< status.m_statusDescription;
|
||||||
|
break;
|
||||||
|
case UPDATE_STATUS::BACKEND_CHECK_FAILURE:
|
||||||
|
debug << QString("UPDATE_STATUS::BACKEND_CHECK_FAILURE: ")
|
||||||
|
<< status.m_statusDescription;
|
||||||
|
break;
|
||||||
|
case UPDATE_STATUS::BACKEND_NOT_CONNECTED:
|
||||||
|
debug << QString("UPDATE_STATUS::BACKEND_NOT_CONNECTED: ")
|
||||||
|
<< status.m_statusDescription;
|
||||||
|
break;
|
||||||
case UPDATE_STATUS::UPDATE_PROCESS_SUCCESS:
|
case UPDATE_STATUS::UPDATE_PROCESS_SUCCESS:
|
||||||
debug << QString("UPDATE_STATUS::UPDATE_PROCESS_SUCCESS: ")
|
debug << QString("UPDATE_STATUS::UPDATE_PROCESS_SUCCESS: ")
|
||||||
<< status.m_statusDescription;
|
<< status.m_statusDescription;
|
||||||
@@ -1237,14 +1312,6 @@ QDebug operator<< (QDebug debug, UpdateStatus status) {
|
|||||||
debug << QString("UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_FAILURE: ")
|
debug << QString("UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_FAILURE: ")
|
||||||
<< status.m_statusDescription;
|
<< status.m_statusDescription;
|
||||||
break;
|
break;
|
||||||
case UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_TIMEOUT:
|
|
||||||
debug << QString("UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_: ")
|
|
||||||
<< status.m_statusDescription;
|
|
||||||
break;
|
|
||||||
case UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_SUCCESS:
|
|
||||||
debug << QString("UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_SUCCESS: ")
|
|
||||||
<< status.m_statusDescription;
|
|
||||||
break;
|
|
||||||
case UPDATE_STATUS::GIT_FETCH_UPDATES:
|
case UPDATE_STATUS::GIT_FETCH_UPDATES:
|
||||||
debug << QString("UPDATE_STATUS::GIT_FETCH_UPDATES: ")
|
debug << QString("UPDATE_STATUS::GIT_FETCH_UPDATES: ")
|
||||||
<< status.m_statusDescription;
|
<< status.m_statusDescription;
|
||||||
@@ -1253,45 +1320,109 @@ QDebug operator<< (QDebug debug, UpdateStatus status) {
|
|||||||
debug << QString("UPDATE_STATUS::GIT_FETCH_UPDATES_REQUEST_FAILURE: ")
|
debug << QString("UPDATE_STATUS::GIT_FETCH_UPDATES_REQUEST_FAILURE: ")
|
||||||
<< status.m_statusDescription;
|
<< status.m_statusDescription;
|
||||||
break;
|
break;
|
||||||
case UPDATE_STATUS::GIT_FETCH_UPDATES_REQUEST_SUCCESS:
|
|
||||||
debug << QString("UPDATE_STATUS::GIT_FETCH_UPDATES_REQUEST_SUCCESS: ")
|
|
||||||
<< status.m_statusDescription;
|
|
||||||
break;
|
|
||||||
case UPDATE_STATUS::ISMAS_RESPONSE_RECEIVED:
|
case UPDATE_STATUS::ISMAS_RESPONSE_RECEIVED:
|
||||||
debug << QString("UPDATE_STATUS::ISMAS_RESPONSE_RECEIVED: ")
|
debug << QString("UPDATE_STATUS::ISMAS_RESPONSE_RECEIVED: ")
|
||||||
<< status.m_statusDescription;
|
<< status.m_statusDescription;
|
||||||
break;
|
break;
|
||||||
case UPDATE_STATUS::GIT_PULL_UPDATES_SUCCESS:
|
|
||||||
debug << QString("UPDATE_STATUS::GIT_PULL_UPDATES_REQUEST: ")
|
|
||||||
<< status.m_statusDescription;
|
|
||||||
break;
|
|
||||||
case UPDATE_STATUS::GIT_PULL_UPDATES_FAILURE:
|
|
||||||
debug << QString("UPDATE_STATUS::GIT_PULL_UPDATES_FAILURE: ")
|
|
||||||
<< status.m_statusDescription;
|
|
||||||
break;
|
|
||||||
case UPDATE_STATUS::EXEC_OPKG_COMMANDS:
|
case UPDATE_STATUS::EXEC_OPKG_COMMANDS:
|
||||||
debug << QString("UPDATE_STATUS::EXEC_OPKG_COMMANDS: ")
|
debug << QString("UPDATE_STATUS::EXEC_OPKG_COMMANDS: ")
|
||||||
<< status.m_statusDescription;
|
<< status.m_statusDescription;
|
||||||
break;
|
break;
|
||||||
case UPDATE_STATUS::EXEC_OPKG_COMMANDS_SUCCESS:
|
// default:;
|
||||||
debug << QString("UPDATE_STATUS::EXEC_OPKG_COMMANDS_SUCCESS: ")
|
|
||||||
<< status.m_statusDescription;
|
|
||||||
break;
|
|
||||||
case UPDATE_STATUS::EXEC_OPKG_COMMAND_SUCCESS:
|
|
||||||
debug << QString("UPDATE_STATUS::EXEC_OPKG_COMMAND_SUCCESS: ")
|
|
||||||
<< status.m_statusDescription;
|
|
||||||
break;
|
|
||||||
case UPDATE_STATUS::EXEC_OPKG_COMMAND_FAILURE:
|
|
||||||
debug << QString("UPDATE_STATUS::EXEC_OPKG_COMMAND_FAILURE: ")
|
|
||||||
<< status.m_statusDescription;
|
|
||||||
break;
|
|
||||||
default:;
|
|
||||||
}
|
}
|
||||||
return debug;
|
return debug;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString& operator<< (QString& str, UpdateStatus status) {
|
QString& operator<< (QString& str, UpdateStatus status) {
|
||||||
switch(status.m_updateStatus) {
|
switch(status.m_updateStatus) {
|
||||||
|
case UPDATE_STATUS::ISMAS_SEND_LAST_VERSION_FAILED:
|
||||||
|
str = QString("UPDATE_STATUS::ISMAS_SEND_LAST_VERSION_FAILED: ");
|
||||||
|
str += status.m_statusDescription;
|
||||||
|
break;
|
||||||
|
case UPDATE_STATUS::SAVE_LOG_FILES_FAILED:
|
||||||
|
str = QString("UPDATE_STATUS::SAVE_LOG_FILES_FAILED: ");
|
||||||
|
str += status.m_statusDescription;
|
||||||
|
break;
|
||||||
|
case UPDATE_STATUS::GIT_CHECK_FILES_TO_UPDATE_SUCCESS:
|
||||||
|
str = QString("UPDATE_STATUS::GIT_CHECK_FILES_TO_UPDATE_SUCCESS: ");
|
||||||
|
str += status.m_statusDescription;
|
||||||
|
break;
|
||||||
|
case UPDATE_STATUS::PSA_UPDATE_FILES_FAILED:
|
||||||
|
str = QString("UPDATE_STATUS::PSA_UPDATE_FILES_FAILED: ");
|
||||||
|
str += status.m_statusDescription;
|
||||||
|
break;
|
||||||
|
case UPDATE_STATUS::RSYNC_UPDATES_SUCCESS:
|
||||||
|
str = QString("UPDATE_STATUS::RSYNC_UPDATES_SUCCESS: ");
|
||||||
|
str += status.m_statusDescription;
|
||||||
|
break;
|
||||||
|
case UPDATE_STATUS::RSYNC_UPDATES_FAILURE:
|
||||||
|
str = QString("UPDATE_STATUS::RSYNC_UPDATES_FAILURE: ");
|
||||||
|
str += status.m_statusDescription;
|
||||||
|
break;
|
||||||
|
case UPDATE_STATUS::EXEC_OPKG_COMMAND:
|
||||||
|
str = QString("UPDATE_STATUS::EXEC_OPKG_COMMAND: ");
|
||||||
|
str += status.m_statusDescription;
|
||||||
|
break;
|
||||||
|
case UPDATE_STATUS::GIT_CLONE_AND_CHECKOUT_SUCCESS:
|
||||||
|
str = QString("UPDATE_STATUS::GIT_CLONE_AND_CHECKOUT_SUCCESS: ");
|
||||||
|
str += status.m_statusDescription;
|
||||||
|
break;
|
||||||
|
case UPDATE_STATUS::GIT_CLONE_AND_CHECKOUT_FAILURE:
|
||||||
|
str = QString("UPDATE_STATUS::GIT_CLONE_AND_CHECKOUT_FAILURE: ");
|
||||||
|
str += status.m_statusDescription;
|
||||||
|
break;
|
||||||
|
case UPDATE_STATUS::NOT_DEFINED:
|
||||||
|
str = QString("UPDATE_STATUS::NOT_DEFINED: ");
|
||||||
|
str += status.m_statusDescription;
|
||||||
|
break;
|
||||||
|
case UPDATE_STATUS::UPDATE_PROCESS_FAILURE:
|
||||||
|
str = QString("UPDATE_STATUS::UPDATE_PROCESS_FAILURE: ");
|
||||||
|
str += status.m_statusDescription;
|
||||||
|
break;
|
||||||
|
case UPDATE_STATUS::ISMAS_UPDATE_TRIGGER_SET_FAILURE:
|
||||||
|
str = QString("UPDATE_STATUS::ISMAS_UPDATE_TRIGGER_FAILURE: ");
|
||||||
|
str += status.m_statusDescription;
|
||||||
|
break;
|
||||||
|
case UPDATE_STATUS::GIT_CHECKOUT_BRANCH_FAILURE:
|
||||||
|
str = QString("UPDATE_STATUS::GIT_CHECKOUT_BRANCH_FAILURE: ");
|
||||||
|
str += status.m_statusDescription;
|
||||||
|
break;
|
||||||
|
case UPDATE_STATUS::GIT_CHECKOUT_BRANCH:
|
||||||
|
str = QString("UPDATE_STATUS::GIT_CHECKOUT_BRANCH: ");
|
||||||
|
str += status.m_statusDescription;
|
||||||
|
break;
|
||||||
|
case UPDATE_STATUS::ISMAS_UPDATE_TRIGGER_NOT_SET_OR_WRONG:
|
||||||
|
str = QString("UPDATE_STATUS::ISMAS_UPDATE_TRIGGER_NOT_SET_OR_WRONG: ");
|
||||||
|
str += status.m_statusDescription;
|
||||||
|
break;
|
||||||
|
case UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_FAILURE:
|
||||||
|
str = QString("UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_FAILURE: ");
|
||||||
|
str += status.m_statusDescription;
|
||||||
|
break;
|
||||||
|
case UPDATE_STATUS::ISMAS_UPDATE_TRIGGER_SET:
|
||||||
|
str = QString("UPDATE_STATUS::ISMAS_UPDATE_TRIGGER_SET: ");
|
||||||
|
str += status.m_statusDescription;
|
||||||
|
break;
|
||||||
|
case UPDATE_STATUS::ISMAS_SANITY_CHECK_OK:
|
||||||
|
str = QString("UPDATE_STATUS::ISMAS_SANITY_CHECK_OK: ");
|
||||||
|
str += status.m_statusDescription;
|
||||||
|
break;
|
||||||
|
case UPDATE_STATUS::JSON_PARSE_FAILURE:
|
||||||
|
str = QString("UPDATE_STATUS::JSON_PARSE_FAILURE: ");
|
||||||
|
str += status.m_statusDescription;
|
||||||
|
break;
|
||||||
|
case UPDATE_STATUS::BACKEND_CHECK:
|
||||||
|
str = QString("UPDATE_STATUS::BACKEND_CHECK: ");
|
||||||
|
str += status.m_statusDescription;
|
||||||
|
break;
|
||||||
|
case UPDATE_STATUS::BACKEND_CHECK_FAILURE:
|
||||||
|
str = QString("UPDATE_STATUS::BACKEND_CHECK_FAILURE: ");
|
||||||
|
str += status.m_statusDescription;
|
||||||
|
break;
|
||||||
|
case UPDATE_STATUS::BACKEND_NOT_CONNECTED:
|
||||||
|
str = QString("UPDATE_STATUS::BACKEND_NOT_CONNECTED: ");
|
||||||
|
str += status.m_statusDescription;
|
||||||
|
break;
|
||||||
case UPDATE_STATUS::UPDATE_PROCESS_SUCCESS:
|
case UPDATE_STATUS::UPDATE_PROCESS_SUCCESS:
|
||||||
str = QString("UPDATE_STATUS::UPDATE_PROCESS_SUCCESS: ");
|
str = QString("UPDATE_STATUS::UPDATE_PROCESS_SUCCESS: ");
|
||||||
str += status.m_statusDescription;
|
str += status.m_statusDescription;
|
||||||
@@ -1300,10 +1431,6 @@ QString& operator<< (QString& str, UpdateStatus status) {
|
|||||||
str = QString("UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_PENDING: ");
|
str = QString("UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_PENDING: ");
|
||||||
str += status.m_statusDescription;
|
str += status.m_statusDescription;
|
||||||
break;
|
break;
|
||||||
case UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_SUCCESS:
|
|
||||||
str = QString("UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_SUCCESS: ");
|
|
||||||
str += status.m_statusDescription;
|
|
||||||
break;
|
|
||||||
case UPDATE_STATUS::GIT_FETCH_UPDATES:
|
case UPDATE_STATUS::GIT_FETCH_UPDATES:
|
||||||
str = QString("UPDATE_STATUS::GIT_FETCH_UPDATES: ");
|
str = QString("UPDATE_STATUS::GIT_FETCH_UPDATES: ");
|
||||||
str += status.m_statusDescription;
|
str += status.m_statusDescription;
|
||||||
@@ -1312,18 +1439,6 @@ QString& operator<< (QString& str, UpdateStatus status) {
|
|||||||
str = QString("UPDATE_STATUS::GIT_FETCH_UPDATES_REQUEST_FAILURE: ");
|
str = QString("UPDATE_STATUS::GIT_FETCH_UPDATES_REQUEST_FAILURE: ");
|
||||||
str += status.m_statusDescription;
|
str += status.m_statusDescription;
|
||||||
break;
|
break;
|
||||||
case UPDATE_STATUS::GIT_FETCH_UPDATES_REQUEST_SUCCESS:
|
|
||||||
str = QString("UPDATE_STATUS::GIT_FETCH_UPDATES_REQUEST_SUCCESS: ");
|
|
||||||
str += status.m_statusDescription;
|
|
||||||
break;
|
|
||||||
case UPDATE_STATUS::GIT_PULL_UPDATES_SUCCESS:
|
|
||||||
str = QString("UPDATE_STATUS::GIT_PULL_UPDATES_SUCCESS: ");
|
|
||||||
str += status.m_statusDescription;
|
|
||||||
break;
|
|
||||||
case UPDATE_STATUS::GIT_PULL_UPDATES_FAILURE:
|
|
||||||
str = QString("UPDATE_STATUS::GIT_PULL_UPDATES_FAILURE: ");
|
|
||||||
str += status.m_statusDescription;
|
|
||||||
break;
|
|
||||||
case UPDATE_STATUS::ISMAS_RESPONSE_RECEIVED:
|
case UPDATE_STATUS::ISMAS_RESPONSE_RECEIVED:
|
||||||
str = QString("UPDATE_STATUS::ISMAS_RESPONSE_RECEIVED: ");
|
str = QString("UPDATE_STATUS::ISMAS_RESPONSE_RECEIVED: ");
|
||||||
str += status.m_statusDescription;
|
str += status.m_statusDescription;
|
||||||
@@ -1332,19 +1447,7 @@ QString& operator<< (QString& str, UpdateStatus status) {
|
|||||||
str = QString("UPDATE_STATUS::EXEC_OPKG_COMMANDS: ");
|
str = QString("UPDATE_STATUS::EXEC_OPKG_COMMANDS: ");
|
||||||
str += status.m_statusDescription;
|
str += status.m_statusDescription;
|
||||||
break;
|
break;
|
||||||
case UPDATE_STATUS::EXEC_OPKG_COMMANDS_SUCCESS:
|
//default:;
|
||||||
str = QString("UPDATE_STATUS::EXEC_OPKG_COMMANDS_SUCCESS: ");
|
|
||||||
str += status.m_statusDescription;
|
|
||||||
break;
|
|
||||||
case UPDATE_STATUS::EXEC_OPKG_COMMAND_SUCCESS:
|
|
||||||
str = QString("UPDATE_STATUS::EXEC_OPKG_COMMAND_SUCCESS: ");
|
|
||||||
str += status.m_statusDescription;
|
|
||||||
break;
|
|
||||||
case UPDATE_STATUS::EXEC_OPKG_COMMAND_FAILURE:
|
|
||||||
str = QString("UPDATE_STATUS::EXEC_OPKG_COMMAND_FAILURE: ");
|
|
||||||
str += status.m_statusDescription;
|
|
||||||
break;
|
|
||||||
default:;
|
|
||||||
}
|
}
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
38
worker.h
38
worker.h
@@ -23,55 +23,27 @@
|
|||||||
|
|
||||||
enum class UPDATE_STATUS : quint8 {
|
enum class UPDATE_STATUS : quint8 {
|
||||||
NOT_DEFINED,
|
NOT_DEFINED,
|
||||||
STEP_OK,
|
|
||||||
STEP_DONE,
|
|
||||||
STEP_FAIL,
|
|
||||||
ISMAS_WAIT_STATE_CHECK_PENDING,
|
ISMAS_WAIT_STATE_CHECK_PENDING,
|
||||||
ISMAS_WAIT_STATE_CHECK_FAILURE,
|
ISMAS_WAIT_STATE_CHECK_FAILURE,
|
||||||
ISMAS_WAIT_STATE_CHECK_TIMEOUT,
|
|
||||||
ISMAS_WAIT_STATE_CHECK_SUCCESS,
|
|
||||||
ISMAS_RESPONSE_RECEIVED,
|
ISMAS_RESPONSE_RECEIVED,
|
||||||
BACKEND_CONNECTED,
|
|
||||||
BACKEND_CHECK,
|
BACKEND_CHECK,
|
||||||
BACKEND_CHECK_FAILURE,
|
BACKEND_CHECK_FAILURE,
|
||||||
ISMAS_BACKEND_CHECK_FAILURE,
|
|
||||||
BACKEND_NOT_CONNECTED,
|
BACKEND_NOT_CONNECTED,
|
||||||
UPDATE_TRIGGER_SET,
|
ISMAS_UPDATE_TRIGGER_SET,
|
||||||
UPDATE_TRIGGER_NOT_SET_OR_WRONG,
|
ISMAS_UPDATE_TRIGGER_NOT_SET_OR_WRONG,
|
||||||
GIT_CLONE_AND_CHECKOUT_SUCCESS,
|
GIT_CLONE_AND_CHECKOUT_SUCCESS,
|
||||||
GIT_CLONE_AND_CHECKOUT_FAILURE,
|
GIT_CLONE_AND_CHECKOUT_FAILURE,
|
||||||
GIT_CHECKOUT_BRANCH,
|
GIT_CHECKOUT_BRANCH,
|
||||||
GIT_CHECKOUT_BRANCH_REQUEST_FAILURE,
|
GIT_CHECKOUT_BRANCH_FAILURE,
|
||||||
GIT_CHECKOUT_BRANCH_NOT_EXISTS,
|
|
||||||
GIT_CHECKOUT_BRANCH_CHECKOUT_ERROR,
|
|
||||||
GIT_FETCH_UPDATES,
|
GIT_FETCH_UPDATES,
|
||||||
GIT_FETCH_UPDATES_REQUEST_FAILURE,
|
GIT_FETCH_UPDATES_REQUEST_FAILURE,
|
||||||
GIT_FETCH_UPDATES_REQUEST_SUCCESS,
|
|
||||||
GIT_PULL_UPDATES_SUCCESS,
|
|
||||||
GIT_PULL_UPDATES_FAILURE,
|
|
||||||
EXEC_OPKG_COMMAND,
|
EXEC_OPKG_COMMAND,
|
||||||
EXEC_OPKG_COMMANDS,
|
EXEC_OPKG_COMMANDS,
|
||||||
EXEC_OPKG_COMMAND_FAILURE,
|
|
||||||
EXEC_OPKG_COMMAND_SUCCESS,
|
|
||||||
EXEC_OPKG_COMMANDS_SUCCESS,
|
|
||||||
RSYNC_UPDATES,
|
|
||||||
RSYNC_UPDATES_FAILURE,
|
RSYNC_UPDATES_FAILURE,
|
||||||
RSYNC_UPDATES_SUCESS,
|
RSYNC_UPDATES_SUCCESS,
|
||||||
DEVICE_CONTROLLER_UPDATE,
|
|
||||||
DEVICE_CONTROLLER_UPDATE_FAILURE,
|
|
||||||
DEVICE_CONTROLLER_UPDATE_SUCCESS,
|
|
||||||
JSON_UPDATE,
|
|
||||||
JSON_UPDATE_FAILURE,
|
|
||||||
JSON_PARSE_FAILURE,
|
JSON_PARSE_FAILURE,
|
||||||
JSON_UPDATE_SUCCESS,
|
|
||||||
UPDATE_PROCESS_SUCCESS,
|
UPDATE_PROCESS_SUCCESS,
|
||||||
UPDATE_PROCESS_FAILURE,
|
UPDATE_PROCESS_FAILURE,
|
||||||
ISMAS_UPDATE_INFO_CONFIRM,
|
|
||||||
ISMAS_UPDATE_INFO_CONFIRM_FAILURE,
|
|
||||||
ISMAS_UPDATE_INFO_CONFIRM_SUCCESS,
|
|
||||||
ISMAS_CURRENT_PSA_STATUS_CONFIRM,
|
|
||||||
ISMAS_CURRENT_PSA_STATUS_CONFIRM_FAILURE,
|
|
||||||
ISMAS_CURRENT_PSA_STATUS_CONFIRM_SUCCESS,
|
|
||||||
ISMAS_SANITY_CHECK_OK,
|
ISMAS_SANITY_CHECK_OK,
|
||||||
ISMAS_UPDATE_TRIGGER_SET_FAILURE,
|
ISMAS_UPDATE_TRIGGER_SET_FAILURE,
|
||||||
PSA_UPDATE_FILES_FAILED,
|
PSA_UPDATE_FILES_FAILED,
|
||||||
@@ -195,6 +167,7 @@ public:
|
|||||||
signals:
|
signals:
|
||||||
void appendText(QString, QString suffix = "");
|
void appendText(QString, QString suffix = "");
|
||||||
void replaceLast(QString, QString);
|
void replaceLast(QString, QString);
|
||||||
|
void replaceLast(QStringList, QString);
|
||||||
void showErrorMessage(QString title, QString description);
|
void showErrorMessage(QString title, QString description);
|
||||||
void stopStartTimer();
|
void stopStartTimer();
|
||||||
void restartExitTimer();
|
void restartExitTimer();
|
||||||
@@ -216,7 +189,6 @@ private slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
PSAInstalled getPSAInstalled();
|
PSAInstalled getPSAInstalled();
|
||||||
QString sendCmdSendVersionToIsmas();
|
|
||||||
void privateUpdate();
|
void privateUpdate();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user