Compare commits
24 Commits
v1.1.1
...
631ade1954
Author | SHA1 | Date | |
---|---|---|---|
631ade1954 | |||
337bdd1bb0 | |||
978cc16304 | |||
bea8242d6f | |||
56daa84a14 | |||
17ddfd0ddd | |||
2ac8c4cfc6 | |||
0559ff64e2 | |||
385a7b7b00 | |||
503b7c64f9 | |||
beec9c2f9d | |||
5263b7de0f | |||
9b4d0494c8 | |||
0f2ee0349f | |||
e700a40875 | |||
1eba5338e4 | |||
f20be9ddcf | |||
7631c05e22 | |||
ad93e536f0 | |||
259da8200e | |||
8d528f0f55 | |||
66d0214720 | |||
86064979b4 | |||
86c996d7ac |
@@ -15,7 +15,7 @@ DEFINES += QT_DEPRECATED_WARNINGS
|
||||
# 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.
|
||||
#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
|
||||
|
||||
|
@@ -114,6 +114,47 @@ bool GitClient::gitCloneAndCheckoutBranch() {
|
||||
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
|
||||
wieder geloscht, so wird sie im diff nicht angezeigt.
|
||||
|
@@ -50,6 +50,7 @@ class GitClient : public QObject {
|
||||
std::optional<QStringList> gitMerge();
|
||||
|
||||
QString gitLastCommit(QString fileName);
|
||||
QStringList gitShowReason();
|
||||
QString gitBlob(QString fileName);
|
||||
QString gitCommitForBlob(QString blob);
|
||||
bool gitIsFileTracked(QString file2name);
|
||||
|
@@ -137,7 +137,12 @@ IsmasClient::sendRequestReceiveResponse(int port, QString const &request) {
|
||||
so_linger.l_onoff = 1;
|
||||
so_linger.l_linger = 0;
|
||||
|
||||
int maxfdp1;
|
||||
fd_set rset;
|
||||
fd_set wset;
|
||||
|
||||
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_RCVTIMEO, &tv, sizeof(tv));
|
||||
int flag = 1;
|
||||
@@ -151,24 +156,56 @@ IsmasClient::sendRequestReceiveResponse(int port, QString const &request) {
|
||||
int loop = 0;
|
||||
int bytesWritten = 0;
|
||||
while (bytesWritten < bytesToWrite) {
|
||||
int n = ::sendto(sockfd, buf+bytesWritten, bytesToWrite-bytesWritten, 0, NULL, 0);
|
||||
if (n >= 0) {
|
||||
bytesWritten += n;
|
||||
} else {
|
||||
if (errno == EWOULDBLOCK) {
|
||||
if (++loop < 10) {
|
||||
QThread::msleep(500);
|
||||
continue;
|
||||
}
|
||||
printErrorMessage(port, clientIP, clientPort,
|
||||
QString("WRITE TIMEOUT %1(").arg(loop) + strerror(errno) + ")");
|
||||
::close(sockfd);
|
||||
return std::nullopt;
|
||||
} else
|
||||
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("WRITE INTERRUPTED BY SIGNAL (1) (") + strerror(errno) + ")");
|
||||
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);
|
||||
if (n >= 0) {
|
||||
bytesWritten += n;
|
||||
} else {
|
||||
if (errno == EWOULDBLOCK) {
|
||||
if (++loop < 10) {
|
||||
QThread::msleep(500);
|
||||
continue;
|
||||
}
|
||||
printErrorMessage(port, clientIP, clientPort,
|
||||
QString("WRITE TIMEOUT %1(").arg(loop) + strerror(errno) + ")");
|
||||
::close(sockfd);
|
||||
return std::nullopt;
|
||||
} else
|
||||
if (errno == EINTR) {
|
||||
printErrorMessage(port, clientIP, clientPort,
|
||||
QString("WRITE INTERRUPTED BY SIGNAL (1) (") + strerror(errno) + ")");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -180,7 +217,7 @@ IsmasClient::sendRequestReceiveResponse(int port, QString const &request) {
|
||||
// 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;
|
||||
bzero(buf, sizeof(buf));
|
||||
@@ -188,33 +225,69 @@ IsmasClient::sendRequestReceiveResponse(int port, QString const &request) {
|
||||
int bytesRead = 0;
|
||||
while (bytesRead < bytesToRead) {
|
||||
errno = 0;
|
||||
int n = ::recvfrom(sockfd, buf+bytesRead, bytesToRead-bytesRead,
|
||||
0, NULL, NULL);
|
||||
if (n > 0) { //
|
||||
bytesRead += n;
|
||||
} else
|
||||
if (n == 0) {
|
||||
// The return value will be 0 when the peer has performed an orderly shutdown.
|
||||
printErrorMessage(port, clientIP, clientPort,
|
||||
QString("PEER CLOSED CONNECTION (") + strerror(errno) + ")");
|
||||
::close(sockfd);
|
||||
return std::nullopt;
|
||||
} else
|
||||
if (n < 0) {
|
||||
if (errno == EWOULDBLOCK) {
|
||||
if (++loop < 10) {
|
||||
QThread::msleep(500);
|
||||
continue;
|
||||
}
|
||||
printErrorMessage(port, clientIP, clientPort,
|
||||
QString("READ TIMEOUT %1(").arg(loop) + strerror(errno) + ")");
|
||||
::close(sockfd);
|
||||
return std::nullopt;
|
||||
}
|
||||
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,
|
||||
0, NULL, NULL);
|
||||
if (n > 0) { //
|
||||
bytesRead += n;
|
||||
} else
|
||||
if (n == 0) {
|
||||
// The return value will be 0 when the peer has performed an orderly shutdown.
|
||||
printErrorMessage(port, clientIP, clientPort,
|
||||
QString("PEER CLOSED CONNECTION (") + strerror(errno) + ") START AT" +
|
||||
selectStart + " NOW " + QDateTime::currentDateTime().toString(Qt::ISODateWithMs));
|
||||
::close(sockfd);
|
||||
return std::nullopt;
|
||||
} else
|
||||
if (n < 0) {
|
||||
if (errno == EWOULDBLOCK) { // check just in case
|
||||
if (++loop < 10) {
|
||||
QThread::msleep(500);
|
||||
continue;
|
||||
}
|
||||
printErrorMessage(port, clientIP, clientPort,
|
||||
QString("READ TIMEOUT %1(").arg(loop) + strerror(errno) + ")");
|
||||
::close(sockfd);
|
||||
return std::nullopt;
|
||||
}
|
||||
if (errno == EINTR) {
|
||||
printErrorMessage(port, clientIP, clientPort,
|
||||
QString("INTERRUPTED BY SIGNAL (2) (") + strerror(errno) + ")");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -345,13 +418,11 @@ QString IsmasClient::updateOfPSASendVersion(PSAInstalled const &psa) {
|
||||
static char buf[4096*2];
|
||||
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=
|
||||
snprintf(buf, sizeof(buf)-1,
|
||||
"{"
|
||||
"\"VERSION_INFO\" : {"
|
||||
"\"REASON\":\"%s\","
|
||||
"\"CREATED\":\"%s\","
|
||||
"\"HASH\":\"%s\""
|
||||
"},"
|
||||
@@ -559,8 +630,9 @@ QString IsmasClient::updateOfPSASendVersion(PSAInstalled const &psa) {
|
||||
"}"
|
||||
"}"
|
||||
"}",
|
||||
ts.toStdString().c_str(),
|
||||
sendVersionHash.toStdString().c_str(),
|
||||
psa.versionInfo.reason.toStdString().c_str(),
|
||||
psa.versionInfo.created.toStdString().c_str(),
|
||||
psa.versionInfo.lastCommit.toStdString().c_str(),
|
||||
|
||||
psa.tariff.version.toStdString().c_str(),
|
||||
psa.tariff.project.toStdString().c_str(),
|
||||
|
@@ -7,6 +7,12 @@
|
||||
#include <optional>
|
||||
|
||||
struct PSAInstalled {
|
||||
struct VersionInfo {
|
||||
QString created;
|
||||
QString reason;
|
||||
QString lastCommit;
|
||||
} versionInfo;
|
||||
|
||||
struct Tariff {
|
||||
QString name;
|
||||
QString version;
|
||||
|
119
main.cpp
119
main.cpp
@@ -31,6 +31,7 @@
|
||||
#include "utils.h"
|
||||
|
||||
#include <QThread>
|
||||
#include <QtWidgets>
|
||||
|
||||
#ifdef PTU5
|
||||
#define SERIAL_PORT "ttymxc2"
|
||||
@@ -38,6 +39,93 @@
|
||||
#define SERIAL_PORT "ttyUSB0"
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
static QGraphicsProxyWidget *createItem(const QSizeF &minimum = QSizeF(100.0, 100.0),
|
||||
const QSizeF &preferred = QSize(150.0, 100.0),
|
||||
const QSizeF &maximum = QSizeF(200.0, 100.0),
|
||||
const QString &name = "0")
|
||||
{
|
||||
QGraphicsProxyWidget *w = new QGraphicsProxyWidget;
|
||||
w->setWidget(new QPushButton(name));
|
||||
w->setData(0, name);
|
||||
w->setMinimumSize(minimum);
|
||||
w->setPreferredSize(preferred);
|
||||
w->setMaximumSize(maximum);
|
||||
|
||||
w->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
||||
return w;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
|
||||
QGraphicsScene scene;
|
||||
scene.setSceneRect(0, 0, 800, 480);
|
||||
|
||||
QSizeF minSize(30, 100);
|
||||
QSizeF prefSize(210, 100);
|
||||
QSizeF maxSize(300, 100);
|
||||
|
||||
QGraphicsProxyWidget *a = createItem(minSize, prefSize, maxSize, "A");
|
||||
QGraphicsProxyWidget *b = createItem(minSize, prefSize, maxSize, "B");
|
||||
QGraphicsProxyWidget *c = createItem(minSize, prefSize, maxSize, "C");
|
||||
QGraphicsProxyWidget *d = createItem(minSize, prefSize, maxSize, "D");
|
||||
QGraphicsProxyWidget *e = createItem(minSize, prefSize, maxSize, "E");
|
||||
QGraphicsProxyWidget *f = createItem(QSizeF(30, 50), QSizeF(150, 50), maxSize, "F (overflow)");
|
||||
QGraphicsProxyWidget *g = createItem(QSizeF(30, 50), QSizeF(30, 100), maxSize, "G (overflow)");
|
||||
|
||||
QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout;
|
||||
l->setSpacing(0);
|
||||
|
||||
QGraphicsWidget *w = new QGraphicsWidget(0, Qt::Window);
|
||||
w->setPos(20, 20);
|
||||
w->setLayout(l);
|
||||
|
||||
// vertical
|
||||
l->addAnchor(a, Qt::AnchorTop, l, Qt::AnchorTop);
|
||||
l->addAnchor(b, Qt::AnchorTop, l, Qt::AnchorTop);
|
||||
|
||||
l->addAnchor(c, Qt::AnchorTop, a, Qt::AnchorBottom);
|
||||
l->addAnchor(c, Qt::AnchorTop, b, Qt::AnchorBottom);
|
||||
l->addAnchor(c, Qt::AnchorBottom, d, Qt::AnchorTop);
|
||||
l->addAnchor(c, Qt::AnchorBottom, e, Qt::AnchorTop);
|
||||
|
||||
l->addAnchor(d, Qt::AnchorBottom, l, Qt::AnchorBottom);
|
||||
l->addAnchor(e, Qt::AnchorBottom, l, Qt::AnchorBottom);
|
||||
|
||||
l->addAnchor(c, Qt::AnchorTop, f, Qt::AnchorTop);
|
||||
l->addAnchor(c, Qt::AnchorVerticalCenter, f, Qt::AnchorBottom);
|
||||
l->addAnchor(f, Qt::AnchorBottom, g, Qt::AnchorTop);
|
||||
l->addAnchor(c, Qt::AnchorBottom, g, Qt::AnchorBottom);
|
||||
|
||||
// horizontal
|
||||
l->addAnchor(l, Qt::AnchorLeft, a, Qt::AnchorLeft);
|
||||
l->addAnchor(l, Qt::AnchorLeft, d, Qt::AnchorLeft);
|
||||
l->addAnchor(a, Qt::AnchorRight, b, Qt::AnchorLeft);
|
||||
|
||||
l->addAnchor(a, Qt::AnchorRight, c, Qt::AnchorLeft);
|
||||
l->addAnchor(c, Qt::AnchorRight, e, Qt::AnchorLeft);
|
||||
|
||||
l->addAnchor(b, Qt::AnchorRight, l, Qt::AnchorRight);
|
||||
l->addAnchor(e, Qt::AnchorRight, l, Qt::AnchorRight);
|
||||
l->addAnchor(d, Qt::AnchorRight, e, Qt::AnchorLeft);
|
||||
|
||||
l->addAnchor(l, Qt::AnchorLeft, f, Qt::AnchorLeft);
|
||||
l->addAnchor(l, Qt::AnchorLeft, g, Qt::AnchorLeft);
|
||||
l->addAnchor(f, Qt::AnchorRight, g, Qt::AnchorRight);
|
||||
|
||||
|
||||
scene.addItem(w);
|
||||
scene.setBackgroundBrush(Qt::darkGreen);
|
||||
QGraphicsView view(&scene);
|
||||
|
||||
view.show();
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
#endif
|
||||
|
||||
// argv[1]: file to send to dc
|
||||
int main(int argc, char *argv[]) {
|
||||
QByteArray const value = qgetenv("LC_ALL");
|
||||
@@ -52,6 +140,22 @@ int main(int argc, char *argv[]) {
|
||||
QApplication::setApplicationName("ATBUpdateTool");
|
||||
QApplication::setApplicationVersion(APP_VERSION);
|
||||
|
||||
#if 0
|
||||
// vorbereitend
|
||||
QGraphicsScene scene;
|
||||
scene.setSceneRect(0, 0, 800, 480);
|
||||
|
||||
QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout;
|
||||
l->setSpacing(0);
|
||||
|
||||
QGraphicsWidget *w = new QGraphicsWidget(0, Qt::Window);
|
||||
w->setPos(20, 20);
|
||||
w->setLayout(l);
|
||||
|
||||
QGraphicsView view(&scene);
|
||||
// view.show();
|
||||
#endif
|
||||
|
||||
if (!messageHandlerInstalled()) { // change internal qt-QDebug-handling
|
||||
atbInstallMessageHandler(atbDebugOutput);
|
||||
setDebugLevel(LOG_NOTICE);
|
||||
@@ -65,7 +169,7 @@ int main(int argc, char *argv[]) {
|
||||
QCommandLineOption pluginDirectoryOption(QStringList() << "plugin-directory" << "plugin-directory",
|
||||
QCoreApplication::translate("main", "Where to find dc-plugin."),
|
||||
QCoreApplication::translate("main", "directory"));
|
||||
QString const pluginDefault = "./plugins";
|
||||
QString const pluginDefault = "/usr/lib";
|
||||
pluginDirectoryOption.setDefaultValue(pluginDefault);
|
||||
parser.addOption(pluginDirectoryOption);
|
||||
|
||||
@@ -79,7 +183,7 @@ int main(int argc, char *argv[]) {
|
||||
QCommandLineOption workingDirectoryOption(QStringList() << "working-directory" << "working-directory",
|
||||
QCoreApplication::translate("main", "working directory of update-script."),
|
||||
QCoreApplication::translate("main", "directory"));
|
||||
QString const workingDirectoryDefault = ".";
|
||||
QString const workingDirectoryDefault = "/opt/app/tools/atbupdate";
|
||||
workingDirectoryOption.setDefaultValue(workingDirectoryDefault);
|
||||
parser.addOption(workingDirectoryOption);
|
||||
|
||||
@@ -87,14 +191,6 @@ int main(int argc, char *argv[]) {
|
||||
QCoreApplication::translate("main", "Start ATBUpdateTool in dry-run-mode. No actual actions."));
|
||||
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
|
||||
parser.process(a);
|
||||
QString plugInDir = parser.value(pluginDirectoryOption);
|
||||
@@ -103,9 +199,6 @@ int main(int argc, char *argv[]) {
|
||||
bool dryRun = parser.isSet(dryRunOption);
|
||||
QString const rtPath = QCoreApplication::applicationDirPath();
|
||||
|
||||
if (plugInDir == pluginDefault) {
|
||||
plugInDir = (rtPath + "/" + pluginDefault);
|
||||
}
|
||||
if (!QDir(plugInDir).exists()) {
|
||||
qCritical() << plugInDir
|
||||
<< "does not exists, but has to contain dc-library";
|
||||
|
@@ -7,6 +7,7 @@
|
||||
#include <QDateTime>
|
||||
#include <QMessageBox>
|
||||
#include <QDebug>
|
||||
#include <QScrollBar>
|
||||
|
||||
MainWindow::MainWindow(Worker *worker, QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
@@ -42,17 +43,15 @@ MainWindow::MainWindow(Worker *worker, QWidget *parent)
|
||||
m_exitTimer->setSingleShot(true);
|
||||
m_exitTimer->start(1800 * 1000);
|
||||
|
||||
connect(ui->exit, SIGNAL(clicked()), this, SLOT(onQuit()));
|
||||
connect(m_worker, SIGNAL(disableExit()), this, SLOT(onDisableExit()));
|
||||
connect(m_worker, SIGNAL(enableExit()), this, SLOT(onEnableExit()));
|
||||
connect(m_worker, SIGNAL(stopStartTimer()), this, SLOT(onStopStartTimer()));
|
||||
connect(m_worker, SIGNAL(restartExitTimer()), this, SLOT(onRestartExitTimer()));
|
||||
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(replaceLast(QString, QString)), this, SLOT(onReplaceLast(QString,QString)));
|
||||
|
||||
ui->updateStatus->setText(lst.join('\n'));
|
||||
ui->updateStatus->setEnabled(true);
|
||||
connect(ui->exit, SIGNAL(clicked()),this,SLOT(onQuit()));
|
||||
connect(m_worker, SIGNAL(disableExit()),this,SLOT(onDisableExit()));
|
||||
connect(m_worker, SIGNAL(enableExit()),this,SLOT(onEnableExit()));
|
||||
connect(m_worker, SIGNAL(stopStartTimer()),this,SLOT(onStopStartTimer()));
|
||||
connect(m_worker, SIGNAL(restartExitTimer()),this,SLOT(onRestartExitTimer()));
|
||||
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(replaceLast(QString,QString)),this,SLOT(onReplaceLast(QString,QString)));
|
||||
connect(m_worker, SIGNAL(replaceLast(QStringList,QString)),this, SLOT(onReplaceLast(QStringList,QString)));
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow() {
|
||||
@@ -137,10 +136,19 @@ void MainWindow::onQuit() {
|
||||
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) {
|
||||
QString editText = ui->updateStatus->toPlainText();
|
||||
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) {
|
||||
editText += QString("\n").leftJustified(m_width-3, '=');
|
||||
editText += " ";
|
||||
@@ -151,14 +159,44 @@ void MainWindow::onAppendText(QString text, QString suffix) {
|
||||
}
|
||||
|
||||
Utils::printLineEditInfo(editText.split('\n'));
|
||||
|
||||
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) {
|
||||
qInfo() << "REPL TEXT" << text << "SUFFIX" << suffix;
|
||||
|
||||
//qInfo() << "REPL TEXT" << text << "SUFFIX" << suffix;
|
||||
QString editText = ui->updateStatus->toPlainText();
|
||||
QStringList lines = editText.split('\n');
|
||||
if (lines.size() > 0) {
|
||||
@@ -171,16 +209,21 @@ void MainWindow::onReplaceLast(QString text, QString suffix) {
|
||||
}
|
||||
|
||||
Utils::printLineEditInfo(lines);
|
||||
|
||||
ui->updateStatus->setText(lines.join('\n').trimmed());
|
||||
ui->updateStatus->setEnabled(true);
|
||||
scrollDownTextEdit();
|
||||
}
|
||||
|
||||
void MainWindow::onShowErrorMessage(QString title, QString text) {
|
||||
text = text.leftJustified(50, ' ');
|
||||
QMessageBox msgBox(QMessageBox::NoIcon, title,
|
||||
text, QMessageBox::Ok,
|
||||
nullptr, Qt::FramelessWindowHint);
|
||||
this, Qt::FramelessWindowHint);
|
||||
msgBox.resize(100, 50);
|
||||
|
||||
// msg.setStyleSheet("background-color: rgb(0, 0, 0);")
|
||||
// msg.setStyleSheet("text-color: rgb(255, 255, 255);")
|
||||
|
||||
msgBox.setStyleSheet("QMessageBox{border: 1px solid black; background-color:white}");
|
||||
msgBox.setDefaultButton(QMessageBox::Ok);
|
||||
msgBox.defaultButton()->setVisible(false);
|
||||
|
||||
@@ -189,6 +232,9 @@ void MainWindow::onShowErrorMessage(QString title, QString text) {
|
||||
t->setSingleShot(true);
|
||||
t->start(5 * 1000);
|
||||
|
||||
msgBox.show();
|
||||
msgBox.move(0, 0);
|
||||
|
||||
if(msgBox.exec() == QMessageBox::Ok) {
|
||||
// do something
|
||||
} else {
|
||||
|
@@ -27,6 +27,7 @@ public:
|
||||
|
||||
public slots:
|
||||
void onAppendText(QString, QString suffix = "");
|
||||
void onReplaceLast(QStringList, QString suffix = "");
|
||||
void onReplaceLast(QString, QString suffix = "");
|
||||
void onShowErrorMessage(QString, QString);
|
||||
void onStopStartTimer();
|
||||
@@ -38,6 +39,8 @@ private slots:
|
||||
void onQuit();
|
||||
|
||||
private:
|
||||
void scrollDownTextEdit();
|
||||
|
||||
Ui::MainWindow *ui;
|
||||
Worker *m_worker;
|
||||
int m_width;
|
||||
|
@@ -55,6 +55,15 @@
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</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>
|
||||
</item>
|
||||
</layout>
|
||||
|
@@ -2,13 +2,15 @@
|
||||
|
||||
#include <QProcess>
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QRegularExpression>
|
||||
|
||||
Command::Command(QString const &command, int start_timeout, int finish_timeout)
|
||||
: m_command(command.trimmed())
|
||||
, m_commandResult("")
|
||||
, m_waitForStartTimeout(start_timeout)
|
||||
, m_waitForFinishTimeout(finish_timeout) {
|
||||
, m_waitForFinishTimeout(finish_timeout)
|
||||
, m_exitCode(-1) {
|
||||
}
|
||||
|
||||
QString Command::getCommandResult() const {
|
||||
@@ -39,46 +41,64 @@ void Command::finished(int /*exitCode*/, QProcess::ExitStatus /*exitStatus*/) {
|
||||
}
|
||||
|
||||
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));
|
||||
p->setWorkingDirectory(workingDirectory);
|
||||
p->setProcessChannelMode(QProcess::MergedChannels);
|
||||
|
||||
connect(&(*p), SIGNAL(readyReadStandardOutput()), this, SLOT(readyReadStandardOutput()));
|
||||
connect(&(*p), SIGNAL(readyReadStandardError()), this, SLOT(readyReadStandardError()));
|
||||
|
||||
//qCritical() << "START COMMAND" << m_command << "WITH ARGS" << args
|
||||
// << "IN" << workingDirectory;
|
||||
|
||||
p->setWorkingDirectory(workingDirectory);
|
||||
if (!args.isEmpty()) {
|
||||
qDebug() << "START COMMAND" << m_command << "WITH ARGS" << args
|
||||
<< "IN" << p->workingDirectory();
|
||||
p->start(m_command, args);
|
||||
} else {
|
||||
qDebug() << "START COMMAND" << m_command
|
||||
<< "IN" << p->workingDirectory();
|
||||
p->start(m_command);
|
||||
}
|
||||
|
||||
if (p->waitForStarted(m_waitForStartTimeout)) {
|
||||
//qDebug() << "PROCESS" << m_command << "STARTED";
|
||||
qDebug() << "PROCESS" << m_command << "STARTED IN" << p->workingDirectory();
|
||||
if (p->state() == QProcess::ProcessState::Running) {
|
||||
//qDebug() << "PROCESS" << m_command << "RUNNING";
|
||||
qDebug() << "PROCESS" << m_command << "RUNNING IN" << p->workingDirectory();
|
||||
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->exitCode() == 0) {
|
||||
if ((m_exitCode = p->exitCode()) == 0) {
|
||||
qDebug() << "EXECUTED" << m_command
|
||||
<< "with code" << m_exitCode
|
||||
<< "IN" << p->workingDirectory();
|
||||
return true;
|
||||
} else {
|
||||
qCritical() << "EXECUTED" << m_command << "with code" << p->exitCode();
|
||||
qCritical() << "EXECUTED" << m_command
|
||||
<< "with code" << m_exitCode
|
||||
<< "IN" << p->workingDirectory();
|
||||
}
|
||||
} else {
|
||||
qCritical() << "PROCESS" << m_command << "CRASHED with code"
|
||||
<< p->exitCode();
|
||||
<< p->exitCode()
|
||||
<< "IN" << p->workingDirectory();
|
||||
}
|
||||
} else {
|
||||
qCritical() << "PROCESS" << m_command << "DID NOT FINISH";
|
||||
qCritical() << "PROCESS" << m_command
|
||||
<< "DID NOT FINISH"
|
||||
<< "IN" << p->workingDirectory();
|
||||
}
|
||||
} else {
|
||||
qCritical() << "WRONG PROCESS STATE" << p->state();
|
||||
qCritical() << "WRONG PROCESS STATE" << p->state()
|
||||
<< "IN" << p->workingDirectory();
|
||||
}
|
||||
} else {
|
||||
qCritical() << "PROCESS" << m_command << "TIMEOUT AT START";
|
||||
qCritical() << "PROCESS" << m_command << "TIMEOUT AT START"
|
||||
<< "IN" << p->workingDirectory();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@@ -16,15 +16,17 @@ class Command : public QObject {
|
||||
QString m_commandResult;
|
||||
int m_waitForStartTimeout;
|
||||
int m_waitForFinishTimeout;
|
||||
|
||||
int m_exitCode;
|
||||
public:
|
||||
explicit Command(QString const &command,
|
||||
int start_timeout = 100000,
|
||||
int finish_timeout = 100000);
|
||||
|
||||
QString getCommandResult() const;
|
||||
QString command() const { return m_command; }
|
||||
|
||||
bool execute(QString workingDirectory, QStringList args = QStringList());
|
||||
int exitCode() const { return m_exitCode; }
|
||||
|
||||
private slots:
|
||||
void readyReadStandardOutput();
|
||||
|
@@ -77,3 +77,12 @@ QString Utils::getTariffLoadTime(QString fileName) {
|
||||
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 printLineEditInfo(QStringList const &lines);
|
||||
QString getTariffLoadTime(QString fileName);
|
||||
QString rstrip(QString const &str);
|
||||
}
|
||||
|
||||
#endif // UTILS_H_INCLUDED
|
||||
|
443
worker.cpp
443
worker.cpp
@@ -169,7 +169,7 @@ void Worker::privateUpdate() {
|
||||
int progress = (m_mainWindow->progressValue()/10) + 10;
|
||||
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);
|
||||
|
||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||
@@ -197,7 +197,7 @@ void Worker::privateUpdate() {
|
||||
|
||||
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);
|
||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||
@@ -295,7 +295,7 @@ void Worker::privateUpdate() {
|
||||
m_returnCode = -7;
|
||||
}
|
||||
} 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"));
|
||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||
@@ -315,7 +315,7 @@ void Worker::privateUpdate() {
|
||||
m_returnCode = -5;
|
||||
}
|
||||
} else {
|
||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_BACKEND_CHECK_FAILURE,
|
||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::BACKEND_CHECK_FAILURE,
|
||||
QString("ISMAS backend not available"));
|
||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||
@@ -373,7 +373,7 @@ bool Worker::backendConnected() {
|
||||
emit appendText("\nConnecting backend ...");
|
||||
|
||||
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={}";
|
||||
startProgressLoop();
|
||||
std::optional<QString> result
|
||||
@@ -497,17 +497,34 @@ bool Worker::backendConnected() {
|
||||
return false;
|
||||
}
|
||||
|
||||
#define CHECK_UPDATE_TRIGGER_SET "Check update trigger ..."
|
||||
|
||||
bool Worker::updateTriggerSet() {
|
||||
if (m_withoutIsmasDirectPort) { // useful for testing
|
||||
return true;
|
||||
}
|
||||
|
||||
emit appendText("\nUpdate trigger set ...");
|
||||
emit appendText("\n" CHECK_UPDATE_TRIGGER_SET);
|
||||
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;
|
||||
|
||||
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();
|
||||
if (std::optional<QString> result
|
||||
= IsmasClient::sendRequestReceiveResponse(
|
||||
@@ -518,7 +535,7 @@ bool Worker::updateTriggerSet() {
|
||||
|
||||
QString msg = result.value();
|
||||
|
||||
qInfo() << "REPEAT" << repeat << "APISM RESPONSE" << msg;
|
||||
qInfo() << "REPEAT" << repeat << "APISM RESPONSE (" << msg << ")";
|
||||
|
||||
QJsonParseError parseError;
|
||||
QJsonDocument document(QJsonDocument::fromJson(msg.toUtf8(), &parseError));
|
||||
@@ -537,7 +554,7 @@ bool Worker::updateTriggerSet() {
|
||||
m_updateStatus.m_statusDescription));
|
||||
emit showErrorMessage("check update trigger",
|
||||
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;
|
||||
}
|
||||
if (!document.isObject()) {
|
||||
@@ -550,13 +567,25 @@ bool Worker::updateTriggerSet() {
|
||||
m_ismasClient.jsonParseFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
||||
m_updateStatus.m_statusDescription));
|
||||
emit showErrorMessage("check update trigger", QString("not a json object") + msg);
|
||||
emit replaceLast("Update trigger set ...", UPDATE_STEP_FAIL);
|
||||
emit replaceLast(CHECK_UPDATE_TRIGGER_SET, UPDATE_STEP_FAIL);
|
||||
return false;
|
||||
}
|
||||
progress += 1;
|
||||
setProgress(progress);
|
||||
|
||||
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 ?
|
||||
// note: this check has to be done here, as the cust_nr and the machine_nr
|
||||
// of the PSA are sent by ISMAS.
|
||||
@@ -579,7 +608,7 @@ bool Worker::updateTriggerSet() {
|
||||
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);
|
||||
emit replaceLast(CHECK_UPDATE_TRIGGER_SET, UPDATE_STEP_FAIL);
|
||||
return false;
|
||||
}
|
||||
if (machineNr != m_machineNr) {
|
||||
@@ -592,7 +621,7 @@ bool Worker::updateTriggerSet() {
|
||||
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);
|
||||
emit replaceLast(CHECK_UPDATE_TRIGGER_SET, UPDATE_STEP_FAIL);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -607,7 +636,7 @@ bool Worker::updateTriggerSet() {
|
||||
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);
|
||||
emit replaceLast(CHECK_UPDATE_TRIGGER_SET, UPDATE_STEP_FAIL);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
@@ -619,7 +648,7 @@ bool Worker::updateTriggerSet() {
|
||||
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);
|
||||
emit replaceLast(CHECK_UPDATE_TRIGGER_SET, UPDATE_STEP_FAIL);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
@@ -631,7 +660,7 @@ bool Worker::updateTriggerSet() {
|
||||
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);
|
||||
emit replaceLast(CHECK_UPDATE_TRIGGER_SET, UPDATE_STEP_FAIL);
|
||||
return false;
|
||||
}
|
||||
progress += 1;
|
||||
@@ -658,25 +687,34 @@ bool Worker::updateTriggerSet() {
|
||||
m_ismasClient.updateOfPSAContinues("MACHINE-AND-CUSTOMER-CHECK",
|
||||
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. "));
|
||||
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);
|
||||
emit replaceLast(CHECK_UPDATE_TRIGGER_SET, UPDATE_STEP_DONE);
|
||||
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 {
|
||||
// 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'");
|
||||
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);
|
||||
emit replaceLast(CHECK_UPDATE_TRIGGER_SET, UPDATE_STEP_FAIL);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
@@ -687,7 +725,7 @@ bool Worker::updateTriggerSet() {
|
||||
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 replaceLast(CHECK_UPDATE_TRIGGER_SET, UPDATE_STEP_FAIL);
|
||||
emit showErrorMessage("check update trigger", m_updateStatus.m_statusDescription);
|
||||
return false;
|
||||
}
|
||||
@@ -699,7 +737,7 @@ bool Worker::updateTriggerSet() {
|
||||
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 replaceLast(CHECK_UPDATE_TRIGGER_SET, UPDATE_STEP_FAIL);
|
||||
emit showErrorMessage("check update trigger", m_updateStatus.m_statusDescription);
|
||||
return false;
|
||||
}
|
||||
@@ -711,20 +749,10 @@ bool Worker::updateTriggerSet() {
|
||||
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 replaceLast(CHECK_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;
|
||||
@@ -736,14 +764,14 @@ bool Worker::updateTriggerSet() {
|
||||
}
|
||||
|
||||
setProgress(100);
|
||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::UPDATE_TRIGGER_NOT_SET_OR_WRONG,
|
||||
QString("UPDATE-TRIGGER-NOT-SET-OR-WRONG: VALUE=(") +
|
||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_UPDATE_TRIGGER_NOT_SET_OR_WRONG,
|
||||
QString("ISMAS_UPDATE-TRIGGER-NOT-SET-OR-WRONG: VALUE=(") +
|
||||
triggerValue + ")");
|
||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -863,14 +891,18 @@ bool Worker::updateFiles(quint8 percent) {
|
||||
if (f.open(QIODevice::ReadOnly)) {
|
||||
QTextStream in(&f);
|
||||
int cmdCount = 0;
|
||||
QStringList opkgCommands;
|
||||
while (!in.atEnd()) {
|
||||
QString line = in.readLine();
|
||||
static const QRegularExpression comment("^\\s*#.*$");
|
||||
if (line.indexOf(comment, 0) == -1) {
|
||||
// found opkg command
|
||||
QString opkgCommand = line.trimmed();
|
||||
executeOpkgCommand(opkgCommand);
|
||||
++cmdCount;
|
||||
executeOpkgCommand(opkgCommand);
|
||||
QString cmd = "\n " + opkgCommand;
|
||||
emit appendText(cmd);
|
||||
opkgCommands << cmd;
|
||||
|
||||
m_ismasClient.setProgressInPercent(++percent);
|
||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::EXEC_OPKG_COMMAND,
|
||||
@@ -883,8 +915,10 @@ bool Worker::updateFiles(quint8 percent) {
|
||||
f.close();
|
||||
if (cmdCount > 0) {
|
||||
m_displayIndex = 1;
|
||||
emit replaceLast(QString("(") + QString("%1").arg(m_displayIndex).rightJustified(2, ' ') + QString(")")
|
||||
+ QString(" Update opkg pakets ... "), UPDATE_STEP_DONE);
|
||||
QString prepend = QString("(") + QString("%1").arg(m_displayIndex).rightJustified(2, ' ') + QString(")")
|
||||
+ QString(" Update opkg pakets ... ");
|
||||
opkgCommands.prepend(prepend);
|
||||
emit replaceLast(opkgCommands, UPDATE_STEP_DONE);
|
||||
} else {
|
||||
m_displayIndex = 1;
|
||||
emit replaceLast(QString("(") + QString("%1").arg(m_displayIndex).rightJustified(2, ' ') + QString(")")
|
||||
@@ -919,10 +953,16 @@ bool Worker::updateFiles(quint8 percent) {
|
||||
}
|
||||
|
||||
bool Worker::syncCustomerRepositoryAndFS() {
|
||||
// this step is currently needed only for updating tariff-files
|
||||
setProgress(0);
|
||||
emit appendText("\nSync customer environment with filesystem ...");
|
||||
if (QDir(m_customerRepository).exists()) {
|
||||
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;
|
||||
setProgress(progress);
|
||||
QString const params("-vv "
|
||||
@@ -953,7 +993,7 @@ bool Worker::syncCustomerRepositoryAndFS() {
|
||||
}
|
||||
} else {
|
||||
Utils::printCriticalErrorMsg(QString("CMD ") + cmd + " FAILED: "
|
||||
+ c.getCommandResult());
|
||||
+ c.getCommandResult() + QString(" EXIT_CODE=(%1)").arg(c.exitCode()));
|
||||
error = true;
|
||||
}
|
||||
}
|
||||
@@ -1098,6 +1138,17 @@ PSAInstalled Worker::getPSAInstalled() {
|
||||
QString absPathName;
|
||||
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) {
|
||||
QString const &n = QString("%1").arg(m_zoneNr).rightJustified(2, '0');
|
||||
psaInstalled.tariff.name = QString("tariff%1.json").arg(n);
|
||||
@@ -1160,89 +1211,95 @@ PSAInstalled Worker::getPSAInstalled() {
|
||||
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
|
||||
*/
|
||||
QDebug operator<< (QDebug debug, UpdateStatus status) {
|
||||
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:
|
||||
debug << QString("UPDATE_STATUS::UPDATE_PROCESS_SUCCESS: ")
|
||||
<< status.m_statusDescription;
|
||||
@@ -1255,14 +1312,6 @@ QDebug operator<< (QDebug debug, UpdateStatus status) {
|
||||
debug << QString("UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_FAILURE: ")
|
||||
<< status.m_statusDescription;
|
||||
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:
|
||||
debug << QString("UPDATE_STATUS::GIT_FETCH_UPDATES: ")
|
||||
<< status.m_statusDescription;
|
||||
@@ -1271,45 +1320,109 @@ QDebug operator<< (QDebug debug, UpdateStatus status) {
|
||||
debug << QString("UPDATE_STATUS::GIT_FETCH_UPDATES_REQUEST_FAILURE: ")
|
||||
<< status.m_statusDescription;
|
||||
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:
|
||||
debug << QString("UPDATE_STATUS::ISMAS_RESPONSE_RECEIVED: ")
|
||||
<< status.m_statusDescription;
|
||||
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:
|
||||
debug << QString("UPDATE_STATUS::EXEC_OPKG_COMMANDS: ")
|
||||
<< status.m_statusDescription;
|
||||
break;
|
||||
case UPDATE_STATUS::EXEC_OPKG_COMMANDS_SUCCESS:
|
||||
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:;
|
||||
// default:;
|
||||
}
|
||||
return debug;
|
||||
}
|
||||
|
||||
QString& operator<< (QString& str, UpdateStatus status) {
|
||||
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:
|
||||
str = QString("UPDATE_STATUS::UPDATE_PROCESS_SUCCESS: ");
|
||||
str += status.m_statusDescription;
|
||||
@@ -1318,10 +1431,6 @@ QString& operator<< (QString& str, UpdateStatus status) {
|
||||
str = QString("UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_PENDING: ");
|
||||
str += status.m_statusDescription;
|
||||
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:
|
||||
str = QString("UPDATE_STATUS::GIT_FETCH_UPDATES: ");
|
||||
str += status.m_statusDescription;
|
||||
@@ -1330,18 +1439,6 @@ QString& operator<< (QString& str, UpdateStatus status) {
|
||||
str = QString("UPDATE_STATUS::GIT_FETCH_UPDATES_REQUEST_FAILURE: ");
|
||||
str += status.m_statusDescription;
|
||||
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:
|
||||
str = QString("UPDATE_STATUS::ISMAS_RESPONSE_RECEIVED: ");
|
||||
str += status.m_statusDescription;
|
||||
@@ -1350,19 +1447,7 @@ QString& operator<< (QString& str, UpdateStatus status) {
|
||||
str = QString("UPDATE_STATUS::EXEC_OPKG_COMMANDS: ");
|
||||
str += status.m_statusDescription;
|
||||
break;
|
||||
case UPDATE_STATUS::EXEC_OPKG_COMMANDS_SUCCESS:
|
||||
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:;
|
||||
//default:;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
38
worker.h
38
worker.h
@@ -23,55 +23,27 @@
|
||||
|
||||
enum class UPDATE_STATUS : quint8 {
|
||||
NOT_DEFINED,
|
||||
STEP_OK,
|
||||
STEP_DONE,
|
||||
STEP_FAIL,
|
||||
ISMAS_WAIT_STATE_CHECK_PENDING,
|
||||
ISMAS_WAIT_STATE_CHECK_FAILURE,
|
||||
ISMAS_WAIT_STATE_CHECK_TIMEOUT,
|
||||
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,
|
||||
ISMAS_UPDATE_TRIGGER_SET,
|
||||
ISMAS_UPDATE_TRIGGER_NOT_SET_OR_WRONG,
|
||||
GIT_CLONE_AND_CHECKOUT_SUCCESS,
|
||||
GIT_CLONE_AND_CHECKOUT_FAILURE,
|
||||
GIT_CHECKOUT_BRANCH,
|
||||
GIT_CHECKOUT_BRANCH_REQUEST_FAILURE,
|
||||
GIT_CHECKOUT_BRANCH_NOT_EXISTS,
|
||||
GIT_CHECKOUT_BRANCH_CHECKOUT_ERROR,
|
||||
GIT_CHECKOUT_BRANCH_FAILURE,
|
||||
GIT_FETCH_UPDATES,
|
||||
GIT_FETCH_UPDATES_REQUEST_FAILURE,
|
||||
GIT_FETCH_UPDATES_REQUEST_SUCCESS,
|
||||
GIT_PULL_UPDATES_SUCCESS,
|
||||
GIT_PULL_UPDATES_FAILURE,
|
||||
EXEC_OPKG_COMMAND,
|
||||
EXEC_OPKG_COMMANDS,
|
||||
EXEC_OPKG_COMMAND_FAILURE,
|
||||
EXEC_OPKG_COMMAND_SUCCESS,
|
||||
EXEC_OPKG_COMMANDS_SUCCESS,
|
||||
RSYNC_UPDATES,
|
||||
RSYNC_UPDATES_FAILURE,
|
||||
RSYNC_UPDATES_SUCESS,
|
||||
DEVICE_CONTROLLER_UPDATE,
|
||||
DEVICE_CONTROLLER_UPDATE_FAILURE,
|
||||
DEVICE_CONTROLLER_UPDATE_SUCCESS,
|
||||
JSON_UPDATE,
|
||||
JSON_UPDATE_FAILURE,
|
||||
RSYNC_UPDATES_SUCCESS,
|
||||
JSON_PARSE_FAILURE,
|
||||
JSON_UPDATE_SUCCESS,
|
||||
UPDATE_PROCESS_SUCCESS,
|
||||
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_UPDATE_TRIGGER_SET_FAILURE,
|
||||
PSA_UPDATE_FILES_FAILED,
|
||||
@@ -195,6 +167,7 @@ public:
|
||||
signals:
|
||||
void appendText(QString, QString suffix = "");
|
||||
void replaceLast(QString, QString);
|
||||
void replaceLast(QStringList, QString);
|
||||
void showErrorMessage(QString title, QString description);
|
||||
void stopStartTimer();
|
||||
void restartExitTimer();
|
||||
@@ -216,7 +189,6 @@ private slots:
|
||||
|
||||
private:
|
||||
PSAInstalled getPSAInstalled();
|
||||
QString sendCmdSendVersionToIsmas();
|
||||
void privateUpdate();
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user