Compare commits
No commits in common. "042e6dfa38ff8bfd8c153d3c3dbbfc7311430b97" and "4ff3b0efdfb8f0289b471916000f7b1cbb639e66" have entirely different histories.
042e6dfa38
...
4ff3b0efdf
@ -48,9 +48,8 @@ bool GitClient::gitCloneCustomerRepository() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
qCritical() << QString(80, '*');
|
qCritical() << "ERROR CLONE RESULT HAS WRONG FORMAT. CLONE_RESULT="
|
||||||
qCritical() << "ERROR CLONE RESULT HAS WRONG FORMAT. CLONE_RESULT=" << result;
|
<< result;
|
||||||
qCritical() << QString(80, '*');
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -97,9 +96,7 @@ bool GitClient::gitCheckoutBranch() {
|
|||||||
Command c(gitCommand);
|
Command c(gitCommand);
|
||||||
return c.execute(m_customerRepository); // execute command in customerRepo
|
return c.execute(m_customerRepository); // execute command in customerRepo
|
||||||
}
|
}
|
||||||
qCritical() << QString(80, '*');
|
|
||||||
qCritical() << "ERROR" << m_customerRepository << "DOES NOT EXIST";
|
qCritical() << "ERROR" << m_customerRepository << "DOES NOT EXIST";
|
||||||
qCritical() << QString(80, '*');
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,12 +108,12 @@ bool GitClient::gitCloneAndCheckoutBranch() {
|
|||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
// TODO
|
// TODO
|
||||||
|
// m_worker->terminateUpdateProcess();
|
||||||
}
|
}
|
||||||
//}
|
//}
|
||||||
} else {
|
} else {
|
||||||
qCritical() << QString(80, '*');
|
// TODO
|
||||||
qInfo() << "CLONE" << m_repositoryPath << "AND CHECKOUT FAILED";
|
//m_worker->terminateUpdateProcess();
|
||||||
qCritical() << QString(80, '*');
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -135,41 +132,23 @@ std::optional<QStringList> GitClient::gitDiff(QString const &commits) {
|
|||||||
if (c.execute(m_customerRepository)) { // execute command in local customerRepo
|
if (c.execute(m_customerRepository)) { // execute command in local customerRepo
|
||||||
QString s = c.getCommandResult().trimmed();
|
QString s = c.getCommandResult().trimmed();
|
||||||
QStringList lines = Update::split(s, '\n');
|
QStringList lines = Update::split(s, '\n');
|
||||||
|
|
||||||
qInfo() << QString(80, '*');
|
|
||||||
qInfo() << "GIT DIFF RESULT" << lines;
|
|
||||||
qInfo() << QString(80, '*');
|
|
||||||
|
|
||||||
QStringList fileNames;
|
QStringList fileNames;
|
||||||
// each line has the format "etc/psa_config/DC2C_print01.json | 1 +
|
// each line has the format "etc/psa_config/DC2C_print01.json | 1 +
|
||||||
// or the format "etc/psa_config/DC2C_print01.json (new) | 1 +
|
// or the format "etc/psa_config/DC2C_print01.json (new) | 1 +
|
||||||
// the filenames are relativ to the repository
|
// the filenames are relativ to the repository
|
||||||
for (int i = 0; i < lines.size(); ++i) {
|
for (int i = 0; i < lines.size(); ++i) {
|
||||||
QString const &line = lines.at(i);
|
// TODO: koennte auch (delete) kommen ?
|
||||||
int newIndex = line.indexOf("(new"); // for new files
|
int newIndex = lines.at(i).indexOf("(new)"); // for new files
|
||||||
int goneIndex = line.indexOf("(gone"); // for removed files
|
// int goneIndex = lines.at(i).indexOf("(gone)"); // for removed files
|
||||||
int modeIndex = line.indexOf("(mode");
|
|
||||||
// int pipeIndex = line.indexOf('|');
|
|
||||||
if (newIndex != -1) {
|
if (newIndex != -1) {
|
||||||
QString file = line.left(newIndex).trimmed();
|
QString fileName = lines.at(i).mid(0, newIndex).trimmed();
|
||||||
qInfo() << "FILE (NEW)" << file;
|
fileNames << fileName;
|
||||||
fileNames << file;
|
} else {
|
||||||
} else
|
int pipeIndex = lines.at(i).indexOf('|');
|
||||||
if (modeIndex != -1) {
|
if (pipeIndex != -1) {
|
||||||
QString const file = line.left(modeIndex).trimmed();
|
QString fileName = lines.at(i).mid(0, pipeIndex).trimmed();
|
||||||
qInfo() << "FILE (MODE)" << file;
|
fileNames << fileName;
|
||||||
fileNames << file;
|
}
|
||||||
} else
|
|
||||||
//if (pipeIndex != -1) {
|
|
||||||
// QString const file = line.left(pipeIndex).trimmed();
|
|
||||||
// qInfo() << "FILE (PIPE)" << file;
|
|
||||||
// fileNames << file;
|
|
||||||
//} else
|
|
||||||
if (goneIndex != -1) {
|
|
||||||
QString const file = line.left(goneIndex).trimmed();
|
|
||||||
qCritical() << QString(80, '*');
|
|
||||||
qCritical() << "FILE (GONE)" << file;
|
|
||||||
qCritical() << QString(80, '*');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!fileNames.isEmpty()) {
|
if (!fileNames.isEmpty()) {
|
||||||
@ -185,9 +164,8 @@ std::optional<QStringList> GitClient::gitDiff(QString const &commits) {
|
|||||||
*/
|
*/
|
||||||
std::optional<QString> GitClient::gitFetch() {
|
std::optional<QString> GitClient::gitFetch() {
|
||||||
if (QDir(m_customerRepository).exists()) {
|
if (QDir(m_customerRepository).exists()) {
|
||||||
qCritical() << QString(80, '*');
|
|
||||||
qInfo() << "BRANCH NAME" << m_branchName;
|
qCritical() << "BRANCH NAME" << m_branchName;
|
||||||
qCritical() << QString(80, '*');
|
|
||||||
|
|
||||||
Command c("git fetch");
|
Command c("git fetch");
|
||||||
if (c.execute(m_customerRepository)) {
|
if (c.execute(m_customerRepository)) {
|
||||||
@ -220,39 +198,26 @@ std::optional<QString> GitClient::gitFetch() {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
emit m_worker->showErrorMessage("git fetch",
|
emit m_worker->showErrorMessage("git fetch",
|
||||||
"no regex-match for commits");
|
"regex-match for commits");
|
||||||
qCritical() << QString(80, '*');
|
|
||||||
qCritical() << "NO REGEX MATCH FOR COMMITS";
|
|
||||||
qCritical() << QString(80, '*');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!found) {
|
if (!found) {
|
||||||
emit m_worker->showErrorMessage("git fetch",
|
emit m_worker->showErrorMessage("git fetch",
|
||||||
QString("unkown branch name ") + m_branchName);
|
QString("unkown branch name ") + m_branchName);
|
||||||
qCritical() << QString(80, '*');
|
|
||||||
qCritical() << "UNKNOWN BRANCH NAME" << m_branchName;
|
|
||||||
qCritical() << QString(80, '*');
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
emit m_worker->showErrorMessage("git fetch",
|
emit m_worker->showErrorMessage("git fetch",
|
||||||
QString("wrong format for result of 'git fetch' ") + s);
|
QString("wrong format for result of 'git fetch' ") + s);
|
||||||
qCritical() << QString(80, '*');
|
|
||||||
qCritical() << "WRONG FORMAT FOR RESULT OF 'GIT FETCH'" << s;
|
|
||||||
qCritical() << QString(80, '*');
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
emit m_worker->showErrorMessage("git fetch", "empty result for 'git fetch'");
|
emit m_worker->showErrorMessage("git fetch",
|
||||||
qCritical() << QString(80, '*');
|
"empty result for 'git fetch'");
|
||||||
qCritical() << "EMPTY RESULT FOR 'GIT FETCH'";
|
|
||||||
qCritical() << QString(80, '*');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
emit m_worker->showErrorMessage("git fetch", QString("repository ") + m_customerRepository + " does not exist");
|
emit m_worker->showErrorMessage("git fetch",
|
||||||
qCritical() << QString(80, '*');
|
QString("repository ") + m_customerRepository + " does not exist");
|
||||||
qCritical() << "REPOSITORY" << m_customerRepository << "DOES NOT EXIST";
|
|
||||||
qCritical() << QString(80, '*');
|
|
||||||
}
|
}
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
@ -273,9 +238,7 @@ bool GitClient::gitPull() {
|
|||||||
qInfo() << "PULLED INTO" << m_customerRepository;
|
qInfo() << "PULLED INTO" << m_customerRepository;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
qCritical() << QString(80, '*');
|
|
||||||
qCritical() << "PULL INTO" << m_customerRepository << "FAILED";
|
qCritical() << "PULL INTO" << m_customerRepository << "FAILED";
|
||||||
qCritical() << QString(80, '*');
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -148,7 +148,6 @@ IsmasClient::sendRequestReceiveResponse(int port, QString const &request) {
|
|||||||
int const bytesToWrite = strlen(request.toStdString().c_str());
|
int const bytesToWrite = strlen(request.toStdString().c_str());
|
||||||
strncpy(buf, request.toStdString().c_str(), sizeof(buf)-1);
|
strncpy(buf, request.toStdString().c_str(), sizeof(buf)-1);
|
||||||
|
|
||||||
int loop = 0;
|
|
||||||
int bytesWritten = 0;
|
int bytesWritten = 0;
|
||||||
while (bytesWritten < bytesToWrite) {
|
while (bytesWritten < bytesToWrite) {
|
||||||
int n = ::sendto(sockfd, buf+bytesWritten, bytesToWrite-bytesWritten, 0, NULL, 0);
|
int n = ::sendto(sockfd, buf+bytesWritten, bytesToWrite-bytesWritten, 0, NULL, 0);
|
||||||
@ -156,18 +155,14 @@ IsmasClient::sendRequestReceiveResponse(int port, QString const &request) {
|
|||||||
bytesWritten += n;
|
bytesWritten += n;
|
||||||
} else {
|
} else {
|
||||||
if (errno == EWOULDBLOCK) {
|
if (errno == EWOULDBLOCK) {
|
||||||
if (++loop < 10) {
|
|
||||||
QThread::msleep(500);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
printErrorMessage(port, clientIP, clientPort,
|
printErrorMessage(port, clientIP, clientPort,
|
||||||
QString("WRITE TIMEOUT %1(").arg(loop) + strerror(errno) + ")");
|
QString("TIMEOUT (") + strerror(errno) + ")");
|
||||||
::close(sockfd);
|
::close(sockfd);
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
} else
|
} else
|
||||||
if (errno == EINTR) {
|
if (errno == EINTR) {
|
||||||
printErrorMessage(port, clientIP, clientPort,
|
printErrorMessage(port, clientIP, clientPort,
|
||||||
QString("WRITE INTERRUPTED BY SIGNAL (1) (") + strerror(errno) + ")");
|
QString("INTERRUPTED BY SIGNAL (1) (") + strerror(errno) + ")");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -182,7 +177,6 @@ IsmasClient::sendRequestReceiveResponse(int port, QString const &request) {
|
|||||||
|
|
||||||
printInfoMessage(port, clientIP, clientPort, QString("MESSAGE SENT ") + buf);
|
printInfoMessage(port, clientIP, clientPort, QString("MESSAGE SENT ") + buf);
|
||||||
|
|
||||||
loop = 0;
|
|
||||||
bzero(buf, sizeof(buf));
|
bzero(buf, sizeof(buf));
|
||||||
int bytesToRead = sizeof(buf)-1;
|
int bytesToRead = sizeof(buf)-1;
|
||||||
int bytesRead = 0;
|
int bytesRead = 0;
|
||||||
@ -202,12 +196,8 @@ IsmasClient::sendRequestReceiveResponse(int port, QString const &request) {
|
|||||||
} else
|
} else
|
||||||
if (n < 0) {
|
if (n < 0) {
|
||||||
if (errno == EWOULDBLOCK) {
|
if (errno == EWOULDBLOCK) {
|
||||||
if (++loop < 10) {
|
|
||||||
QThread::msleep(500);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
printErrorMessage(port, clientIP, clientPort,
|
printErrorMessage(port, clientIP, clientPort,
|
||||||
QString("READ TIMEOUT %1(").arg(loop) + strerror(errno) + ")");
|
QString("TIMEOUT (") + strerror(errno) + ")");
|
||||||
::close(sockfd);
|
::close(sockfd);
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
@ -224,8 +214,8 @@ IsmasClient::sendRequestReceiveResponse(int port, QString const &request) {
|
|||||||
if (int idx = response.indexOf("{\"error\":\"ISMAS is offline\"}")) {
|
if (int idx = response.indexOf("{\"error\":\"ISMAS is offline\"}")) {
|
||||||
response = response.mid(0, idx);
|
response = response.mid(0, idx);
|
||||||
} else
|
} else
|
||||||
if (response.contains("RECORD")) { // RECORD SAVED or RECORD WRITE ABORTED
|
if (response == "RECORD SAVED") {
|
||||||
printInfoMessage(port, clientIP, clientPort, QString("IGNORED '") + response + "' RESPONSE");
|
printInfoMessage(port, clientIP, clientPort, "IGNORED 'RECORD SAVED' RESPONSE");
|
||||||
::close(sockfd);
|
::close(sockfd);
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
@ -293,15 +283,6 @@ QString IsmasClient::errorBackendNotConnected(QString const &info,
|
|||||||
version.toStdString().c_str());
|
version.toStdString().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
QString IsmasClient::errorGitClone(int percent, QString const &info, QString const &version) {
|
|
||||||
return updateNewsToIsmas("U0003",
|
|
||||||
percent,
|
|
||||||
RESULT_CODE::INSTALL_ERROR,
|
|
||||||
"CLONE CUSTOMER REPOSITORY FAILED",
|
|
||||||
info.toStdString().c_str(),
|
|
||||||
version.toStdString().c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
QString IsmasClient::backendConnected(QString const &info, QString const &version) {
|
QString IsmasClient::backendConnected(QString const &info, QString const &version) {
|
||||||
return updateNewsToIsmas("U0010",
|
return updateNewsToIsmas("U0010",
|
||||||
m_progressInPercent,
|
m_progressInPercent,
|
||||||
|
@ -144,7 +144,6 @@ public:
|
|||||||
QString cloneAndCheckoutCustomerRepository(QString const &info, QString const &version = QString()); // clone and checkout customer repository
|
QString cloneAndCheckoutCustomerRepository(QString const &info, QString const &version = QString()); // clone and checkout customer repository
|
||||||
QString checkoutBranch(QString const &info, QString const &version = QString()); // checkout branch
|
QString checkoutBranch(QString const &info, QString const &version = QString()); // checkout branch
|
||||||
QString errorBackendNotConnected(QString const &info, QString const &version = QString()); // checkout branch
|
QString errorBackendNotConnected(QString const &info, QString const &version = QString()); // checkout branch
|
||||||
QString errorGitClone(int percent, QString const &info, QString const &version = QString());
|
|
||||||
QString backendConnected(QString const &info, QString const &version = QString());
|
QString backendConnected(QString const &info, QString const &version = QString());
|
||||||
QString updateTriggerSet(QString const &info, QString const &version = QString());
|
QString updateTriggerSet(QString const &info, QString const &version = QString());
|
||||||
QString errorUpdateTrigger(QString const &info, QString const &version = QString());
|
QString errorUpdateTrigger(QString const &info, QString const &version = QString());
|
||||||
|
@ -32,9 +32,15 @@ MainWindow::MainWindow(Worker *worker, QWidget *parent)
|
|||||||
ui->updateStatus->setText(lst.join('\n'));
|
ui->updateStatus->setText(lst.join('\n'));
|
||||||
ui->updateStatus->setEnabled(true);
|
ui->updateStatus->setEnabled(true);
|
||||||
|
|
||||||
|
ui->reserved_1->setVisible(false);
|
||||||
|
ui->reserved_2->setVisible(false);
|
||||||
|
ui->reserved_3->setVisible(false);
|
||||||
|
ui->reserved_4->setVisible(false);
|
||||||
|
ui->reserved_5->setVisible(false);
|
||||||
|
ui->reserved_6->setVisible(false);
|
||||||
|
|
||||||
m_startTimer = new QTimer(this);
|
m_startTimer = new QTimer(this);
|
||||||
// connect(m_startTimer, SIGNAL(timeout()), ui->start, SLOT(click()));
|
connect(m_startTimer, SIGNAL(timeout()), ui->start, SLOT(click()));
|
||||||
connect(m_startTimer, SIGNAL(timeout()), m_worker, SLOT(update()));
|
|
||||||
m_startTimer->setSingleShot(true);
|
m_startTimer->setSingleShot(true);
|
||||||
m_startTimer->start(5 * 1000);
|
m_startTimer->start(5 * 1000);
|
||||||
|
|
||||||
@ -43,6 +49,9 @@ 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(m_startTimer, SIGNAL(timeout()), ui->start, SLOT(click()));
|
||||||
|
connect(m_exitTimer, SIGNAL(timeout()), ui->exit, SLOT(click()));
|
||||||
|
connect(ui->start, SIGNAL(clicked()), m_worker, SLOT(update()));
|
||||||
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()));
|
||||||
@ -127,7 +136,7 @@ void MainWindow::onEnableExit() {
|
|||||||
|
|
||||||
void MainWindow::onRestartExitTimer() {
|
void MainWindow::onRestartExitTimer() {
|
||||||
m_exitTimer->stop();
|
m_exitTimer->stop();
|
||||||
m_exitTimer->start(60 * 1000);
|
m_exitTimer->start(10 * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onQuit() {
|
void MainWindow::onQuit() {
|
||||||
@ -138,64 +147,39 @@ void MainWindow::onQuit() {
|
|||||||
|
|
||||||
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.size() > 0) {
|
||||||
qInfo() << "TEXT" << text << "SUFFIX" << suffix;
|
|
||||||
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 += " ";
|
||||||
}
|
|
||||||
editText += (QString("\n") + text).leftJustified(m_width - (2 + suffix.size()) ) + suffix;
|
editText += (QString("\n") + text).leftJustified(m_width - (2 + suffix.size()) ) + suffix;
|
||||||
} else {
|
} else {
|
||||||
editText += text.leftJustified(m_width-9);
|
editText += text.leftJustified(m_width-9);
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList const lines = editText.split('\n');
|
QStringList lines = editText.split('\n');
|
||||||
for (int i=0; i<lines.size(); ++i) {
|
for (int i=0; i<lines.size(); ++i) {
|
||||||
qInfo() << lines.at(i);
|
qDebug() << lines.at(i);
|
||||||
} qInfo() << ""; qInfo() << "";
|
} qDebug() << ""; qDebug() << "";
|
||||||
|
|
||||||
ui->updateStatus->setPlainText(editText.trimmed());
|
ui->updateStatus->setPlainText(editText);
|
||||||
ui->updateStatus->setEnabled(true);
|
ui->updateStatus->setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onReplaceLast(QString text, QString suffix) {
|
void MainWindow::onReplaceLast(QString text, QString 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) {
|
||||||
lines.removeLast();
|
lines.removeLast();
|
||||||
if (!suffix.isNull() && suffix.size() > 0 && suffix != "\n") {
|
|
||||||
lines += text.leftJustified(m_width-10) + suffix;
|
lines += text.leftJustified(m_width-10) + suffix;
|
||||||
} else {
|
|
||||||
lines += text.leftJustified(m_width-10);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i=0; i<lines.size(); ++i) {
|
for (int i=0; i<lines.size(); ++i) {
|
||||||
qInfo() << lines.at(i);
|
qDebug() << lines.at(i);
|
||||||
} qInfo() << ""; qInfo() << "";
|
} qDebug() << ""; qDebug() << "";
|
||||||
|
|
||||||
ui->updateStatus->setText(lines.join('\n').trimmed());
|
ui->updateStatus->setText(lines.join('\n'));
|
||||||
ui->updateStatus->setEnabled(true);
|
ui->updateStatus->setEnabled(true);
|
||||||
}
|
}
|
||||||
void MainWindow::onShowErrorMessage(QString title, QString text) {
|
|
||||||
text = text.leftJustified(50, ' ');
|
|
||||||
QMessageBox msgBox(QMessageBox::NoIcon, title,
|
|
||||||
text, QMessageBox::Ok,
|
|
||||||
nullptr, Qt::FramelessWindowHint);
|
|
||||||
msgBox.setDefaultButton(QMessageBox::Ok);
|
|
||||||
msgBox.setStyleSheet("QDialog {background-color: red;}"
|
|
||||||
"QPushButton {background-color: blue;}");
|
|
||||||
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) {
|
void MainWindow::onShowErrorMessage(QString title, QString text) {
|
||||||
// do something
|
QMessageBox::critical(this, title, text, QMessageBox::Ok);
|
||||||
} else {
|
|
||||||
// do something else
|
|
||||||
}
|
|
||||||
disconnect(t, SIGNAL(timeout()), msgBox.defaultButton(), SLOT(click()));
|
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ public:
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void onAppendText(QString, QString suffix = "");
|
void onAppendText(QString, QString suffix = "");
|
||||||
void onReplaceLast(QString, QString suffix = "");
|
void onReplaceLast(QString, QString);
|
||||||
void onShowErrorMessage(QString, QString);
|
void onShowErrorMessage(QString, QString);
|
||||||
void onStopStartTimer();
|
void onStopStartTimer();
|
||||||
void onRestartExitTimer();
|
void onRestartExitTimer();
|
||||||
|
@ -22,41 +22,114 @@
|
|||||||
<widget class="QWidget" name="layoutWidget">
|
<widget class="QWidget" name="layoutWidget">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>10</x>
|
<x>11</x>
|
||||||
<y>10</y>
|
<y>11</y>
|
||||||
<width>781</width>
|
<width>781</width>
|
||||||
<height>461</height>
|
<height>461</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="3" column="2">
|
<item row="2" column="0">
|
||||||
|
<widget class="QPushButton" name="start">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<family>Terminus</family>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Start</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
<widget class="QPushButton" name="exit">
|
<widget class="QPushButton" name="exit">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Exit</string>
|
<string>Exit</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="1">
|
<item row="2" column="2">
|
||||||
<widget class="QProgressBar" name="updateProgress">
|
<widget class="QPushButton" name="reserved_1">
|
||||||
<property name="value">
|
<property name="enabled">
|
||||||
<number>1</number>
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="0" rowspan="3" colspan="3">
|
<item row="2" column="3">
|
||||||
|
<widget class="QPushButton" name="reserved_2">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="4">
|
||||||
|
<widget class="QPushButton" name="reserved_3">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="5">
|
||||||
|
<widget class="QPushButton" name="reserved_4">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="6">
|
||||||
|
<widget class="QPushButton" name="reserved_6">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="7">
|
||||||
|
<widget class="QPushButton" name="reserved_5">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0" colspan="8">
|
||||||
<widget class="QTextEdit" name="updateStatus">
|
<widget class="QTextEdit" name="updateStatus">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>true</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="font">
|
<property name="font">
|
||||||
<font>
|
<font>
|
||||||
<family>Misc Fixed</family>
|
<family>Monospace</family>
|
||||||
<pointsize>11</pointsize>
|
<pointsize>14</pointsize>
|
||||||
|
<weight>75</weight>
|
||||||
<bold>true</bold>
|
<bold>true</bold>
|
||||||
</font>
|
</font>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="1" column="0" colspan="8">
|
||||||
|
<widget class="QProgressBar" name="updateProgress">
|
||||||
|
<property name="value">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
|
73
update.cpp
73
update.cpp
@ -8,7 +8,6 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QRegExp>
|
|
||||||
|
|
||||||
//#include <iostream>
|
//#include <iostream>
|
||||||
//#include <fstream>
|
//#include <fstream>
|
||||||
@ -351,25 +350,21 @@ bool Update::downloadBinaryToDC(QString const &bFile) const {
|
|||||||
10 : bl_stopBL() // leave bl and start (the new) application
|
10 : bl_stopBL() // leave bl and start (the new) application
|
||||||
*/
|
*/
|
||||||
bool Update::updateBinary(char const *fileToSendToDC) {
|
bool Update::updateBinary(char const *fileToSendToDC) {
|
||||||
qInfo() << "UPDATING DEVICE CONTROLLER BINARY" << fileToSendToDC;
|
qInfo() << "updating device controller binary" << fileToSendToDC;
|
||||||
QFile fn(fileToSendToDC);
|
QFile fn(fileToSendToDC);
|
||||||
bool r;
|
bool r;
|
||||||
if ((r = fn.exists()) == true) {
|
if ((r = fn.exists()) == true) {
|
||||||
QFileInfo fi(fn);
|
QString const linkTarget = fn.symLinkTarget();
|
||||||
qInfo() << " UPDATING BINARY" << fi.fileName() << "(size=" << fi.size() << ")";
|
QFileInfo fi(linkTarget);
|
||||||
if ((r = updateDC(fileToSendToDC)) == true) {
|
qInfo() << " updating binary (size=" << linkTarget << fi.size() << ")";
|
||||||
qCritical() << QString(80, '*');
|
if ((r = updateDC(linkTarget)) == true) {
|
||||||
qInfo() << " UPDATING BINARY" << fi.fileName() << "(size=" << fi.size() << ") DONE";
|
qInfo() << " updating binary (size=" << linkTarget << fi.size() << ") done";
|
||||||
qCritical() << QString(80, '*');
|
|
||||||
} else {
|
} else {
|
||||||
qCritical() << QString(80, '*');
|
qCritical() << "updating binary (size=" << linkTarget << fi.size() << ")... FAILED";
|
||||||
qCritical() << " UPDATING BINARY" << fi.fileName() << "(size=" << fi.size() << ") FAILED";
|
|
||||||
qCritical() << QString(80, '*');
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
qCritical() << QString(80, '*');
|
qCritical() << "symlink" << fileToSendToDC
|
||||||
qCritical() << fileToSendToDC << "does not exist -> NO UPDATE OF DC FIRMWARE";
|
<< "does not exist -> NO UPDATE OF DC FIRMWARE";
|
||||||
qCritical() << QString(80, '*');
|
|
||||||
}
|
}
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
@ -519,6 +514,7 @@ void Update::finished(int /*exitCode*/, QProcess::ExitStatus /*exitStatus*/) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
|
bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
|
||||||
|
|
||||||
//
|
//
|
||||||
// ACHTUNG !!!
|
// ACHTUNG !!!
|
||||||
//
|
//
|
||||||
@ -527,6 +523,11 @@ bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
|
|||||||
bool serialOpened = false;
|
bool serialOpened = false;
|
||||||
bool serialOpen = false;
|
bool serialOpen = false;
|
||||||
|
|
||||||
|
if (filesToWorkOn.size() == 0) {
|
||||||
|
qCritical() << "NOTHING TO UPDATE";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (!serialOpen) {
|
if (!serialOpen) {
|
||||||
if (!isSerialOpen()) { // open serial only if not already open
|
if (!isSerialOpen()) { // open serial only if not already open
|
||||||
if ((serialOpened = openSerial(baudrateMap.value(m_baudrate), m_baudrate, m_serialInterface)) == false) {
|
if ((serialOpened = openSerial(baudrateMap.value(m_baudrate), m_baudrate, m_serialInterface)) == false) {
|
||||||
@ -536,23 +537,18 @@ bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
serialOpen = true;
|
serialOpen = true;
|
||||||
qInfo() << "SERIAL OPEN" << m_serialInterface << "(BAUDRATE=" << m_baudrate << ")";
|
qCritical() << "SERIAL OPEN" << m_serialInterface << "(BAUDRATE=" << m_baudrate << ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool res = false;
|
|
||||||
QList<QString>::const_iterator it;
|
QList<QString>::const_iterator it;
|
||||||
for (it = filesToWorkOn.cbegin(); it != filesToWorkOn.cend(); ++it) {
|
for (it = filesToWorkOn.cbegin(); it != filesToWorkOn.cend(); ++it) {
|
||||||
m_worker->startProgressLoop();
|
bool res = false;
|
||||||
QString fToWorkOn = (*it).trimmed();
|
QString fToWorkOn = (*it).trimmed();
|
||||||
fToWorkOn = QDir::cleanPath(m_customerRepository + QDir::separator() + fToWorkOn);
|
|
||||||
|
|
||||||
static const QRegularExpression version("^.*dc2c[.][0-9][0-9][.][0-9][0-9][.]bin.*$");
|
if (fToWorkOn.contains("dc2c", Qt::CaseInsensitive) &&
|
||||||
if (fToWorkOn.contains(version)) {
|
fToWorkOn.endsWith(".bin", Qt::CaseInsensitive)) {
|
||||||
|
|
||||||
qInfo() << QString(80, '*');
|
|
||||||
qInfo() << "DO-UPDATE FILE-TO-WORK-ON" << fToWorkOn;
|
|
||||||
qInfo() << QString(80, '*');
|
|
||||||
|
|
||||||
|
qDebug() << "sending sw/hw-requests...";
|
||||||
for (int i=0; i < 3; ++i) { // send explicit reuests to get
|
for (int i=0; i < 3; ++i) { // send explicit reuests to get
|
||||||
// current SW/HW-versions
|
// current SW/HW-versions
|
||||||
m_hw->request_DC2_SWversion();
|
m_hw->request_DC2_SWversion();
|
||||||
@ -562,16 +558,12 @@ bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
|
|||||||
|
|
||||||
QString const hwVersion = m_hw->dc_getHWversion().toLower();
|
QString const hwVersion = m_hw->dc_getHWversion().toLower();
|
||||||
QString const fwVersion = m_hw->dc_getSWversion().toLower();
|
QString const fwVersion = m_hw->dc_getSWversion().toLower();
|
||||||
|
|
||||||
qInfo() << "current dc-hardware-version" << hwVersion;
|
qInfo() << "current dc-hardware-version" << hwVersion;
|
||||||
qInfo() << "current dc-firmware-version" << fwVersion;
|
qInfo() << "current dc-firmware-version" << fwVersion;
|
||||||
|
|
||||||
QFile fn(fToWorkOn);
|
QFile fn(fToWorkOn);
|
||||||
QFileInfo finfo(fn);
|
QFileInfo linkTarget(fn.symLinkTarget());
|
||||||
if (!fn.exists()) { // check for broken link
|
if (!linkTarget.exists()) { // check for broken link
|
||||||
qCritical() << QString(80, '*');
|
|
||||||
qCritical() << "FILE-TO-WORK-ON" << fn << "DOES NOT EXIST";
|
|
||||||
qCritical() << QString(80, '*');
|
|
||||||
res = false;
|
res = false;
|
||||||
} else {
|
} else {
|
||||||
if (false) {
|
if (false) {
|
||||||
@ -582,12 +574,13 @@ bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
|
|||||||
} else {
|
} else {
|
||||||
res = true;
|
res = true;
|
||||||
|
|
||||||
qInfo() << "DOWNLOADING" << finfo.completeBaseName() << "TO DC";
|
qCritical() << "downloading" << fToWorkOn.trimmed() << "->"
|
||||||
|
<< linkTarget.completeBaseName() << "to DC";
|
||||||
#if UPDATE_DC == 1
|
#if UPDATE_DC == 1
|
||||||
m_hw->dc_autoRequest(false);// default: turn auto-request setting off
|
m_hw->dc_autoRequest(false);// default: turn auto-request setting off
|
||||||
QThread::sleep(1); // wait to be sure that there are no more
|
QThread::sleep(1); // wait to be sure that there are no more
|
||||||
// commands sent to dc-hardware
|
// commands sent to dc-hardware
|
||||||
qInfo() << "SET AUTO-REQUEST=FALSE";
|
qDebug() << "SET AUTO-REQUEST=FALSE";
|
||||||
|
|
||||||
if ((res = updateBinary(fToWorkOn.toStdString().c_str())) == true) {
|
if ((res = updateBinary(fToWorkOn.toStdString().c_str())) == true) {
|
||||||
qCritical() << "downloaded binary" << fToWorkOn;
|
qCritical() << "downloaded binary" << fToWorkOn;
|
||||||
@ -598,13 +591,13 @@ bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_hw->dc_autoRequest(true); // turn auto-request setting on
|
m_hw->dc_autoRequest(true); // turn auto-request setting on
|
||||||
qInfo() << "SET AUTO-REQUEST=TRUE";
|
qDebug() << "SET AUTO-REQUEST=TRUE";
|
||||||
qInfo() << "WAIT 10 SECS TO RECEIVE RESPONSES...";
|
qDebug() << "WAIT 10 SECS TO RECEIVE RESPONSES...";
|
||||||
|
|
||||||
QThread::sleep(10); // wait to be sure that responses
|
QThread::sleep(10); // wait to be sure that responses
|
||||||
// have been received
|
// have been received
|
||||||
qInfo() << "updated dc-hardware-version" << m_hw->dc_getHWversion();
|
qCritical() << "updated dc-hardware-version" << m_hw->dc_getHWversion();
|
||||||
qInfo() << "updated dc-firmware-version" << m_hw->dc_getSWversion();
|
qCritical() << "updated dc-firmware-version" << m_hw->dc_getSWversion();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -667,16 +660,10 @@ bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
|
|||||||
qCritical() << "UNKNOWN JSON FILE NAME" << fToWorkOn;
|
qCritical() << "UNKNOWN JSON FILE NAME" << fToWorkOn;
|
||||||
res = false;
|
res = false;
|
||||||
}
|
}
|
||||||
m_worker->stopProgressLoop();
|
|
||||||
m_worker->setProgress(100);
|
|
||||||
|
|
||||||
if (res == false) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} // for (it = openLines.cbegin(); it != openLines.end(); ++it) {
|
} // for (it = openLines.cbegin(); it != openLines.end(); ++it) {
|
||||||
|
|
||||||
m_hw->dc_autoRequest(true); // ALWAYS turn autoRequest ON
|
m_hw->dc_autoRequest(true); // ALWAYS turn autoRequest ON
|
||||||
qDebug() << "SET AUTO-REQUEST=TRUE";
|
qDebug() << "SET AUTO-REQUEST=TRUE";
|
||||||
|
|
||||||
return res;
|
return true;
|
||||||
}
|
}
|
||||||
|
423
worker.cpp
423
worker.cpp
@ -69,8 +69,7 @@ Worker::Worker(hwinf *hw,
|
|||||||
, m_filesToUpdate()
|
, m_filesToUpdate()
|
||||||
, m_updateProcessRunning(false)
|
, m_updateProcessRunning(false)
|
||||||
, m_returnCode(0)
|
, m_returnCode(0)
|
||||||
, m_progressValue(0)
|
, m_progressValue{0} {
|
||||||
, m_withoutIsmasDirectPort(false) /* useful for testing */ {
|
|
||||||
|
|
||||||
QDir::setCurrent(m_workingDirectory);
|
QDir::setCurrent(m_workingDirectory);
|
||||||
|
|
||||||
@ -138,35 +137,42 @@ void Worker::update() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Worker::privateUpdate() {
|
void Worker::privateUpdate() {
|
||||||
|
QPushButton *start = qobject_cast<QPushButton *>(QObject::sender());
|
||||||
|
start->setEnabled(false);
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
emit appendText("\nConnecting backend ...");
|
||||||
|
|
||||||
|
for (int i=0;i <= 100; ++i) {
|
||||||
|
setProgress(i);
|
||||||
|
QThread::msleep(100);
|
||||||
|
}
|
||||||
|
emit replaceLast("Connecting backend ...", UPDATE_STEP_OK);
|
||||||
|
emit appendText(QString("UPDATE "), UPDATE_STEP_SUCCESS);
|
||||||
|
emit appendText(QString("UPDATE "), UPDATE_STEP_FAIL);
|
||||||
|
setProgress(0);
|
||||||
|
|
||||||
|
startProgressLoop();
|
||||||
|
QThread::sleep(5); // long running process
|
||||||
|
stopProgressLoop();
|
||||||
|
for (int i=m_mainWindow->progressValue()/10; i <= 100; ++i) {
|
||||||
|
setProgress(i);
|
||||||
|
QThread::msleep(100);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
emit stopStartTimer();
|
||||||
|
emit disableExit();
|
||||||
m_updateProcessRunning = true;
|
m_updateProcessRunning = true;
|
||||||
|
|
||||||
bool sentIsmasLastVersionNotification = false;
|
bool sentIsmasLastVersionNotification = false;
|
||||||
|
|
||||||
//emit appendText("\nRestart APISM ...");
|
|
||||||
//startProgressLoop();
|
|
||||||
//Command c("systemctl restart apism");
|
|
||||||
//if (c.execute("/tmp")) {
|
|
||||||
// QThread::sleep(10); // give APISM some time to reconnect
|
|
||||||
// stopProgressLoop();
|
|
||||||
// emit replaceLast("Restart APISM ...", UPDATE_STEP_DONE);
|
|
||||||
//} else {
|
|
||||||
// stopProgressLoop();
|
|
||||||
// emit replaceLast("Restart APISM ...", UPDATE_STEP_FAIL);
|
|
||||||
//}
|
|
||||||
|
|
||||||
emit disableExit();
|
|
||||||
|
|
||||||
m_returnCode = -1;
|
m_returnCode = -1;
|
||||||
QDir customerRepository(m_customerRepository);
|
QDir customerRepository(m_customerRepository);
|
||||||
if (!customerRepository.exists()) {
|
if (!customerRepository.exists()) {
|
||||||
emit appendText("\nInitializing customer environment ...");
|
|
||||||
startProgressLoop();
|
|
||||||
if (m_gc.gitCloneAndCheckoutBranch()) {
|
if (m_gc.gitCloneAndCheckoutBranch()) {
|
||||||
stopProgressLoop();
|
emit appendText("\nInitializing customer environment", UPDATE_STEP_DONE);
|
||||||
emit replaceLast("Initializing customer environment", UPDATE_STEP_DONE);
|
|
||||||
|
|
||||||
int progress = (m_mainWindow->progressValue()/10) + 10;
|
|
||||||
setProgress(progress);
|
|
||||||
|
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::UPDATE_PROCESS_SUCCESS,
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::UPDATE_PROCESS_SUCCESS,
|
||||||
QString("CLONED AND CHECKED OUT: ") + m_customerRepository);
|
QString("CLONED AND CHECKED OUT: ") + m_customerRepository);
|
||||||
@ -176,90 +182,82 @@ void Worker::privateUpdate() {
|
|||||||
m_ismasClient.cloneAndCheckoutCustomerRepository(
|
m_ismasClient.cloneAndCheckoutCustomerRepository(
|
||||||
m_updateStatus.m_statusDescription));
|
m_updateStatus.m_statusDescription));
|
||||||
|
|
||||||
setProgress(progress + 10);
|
|
||||||
|
|
||||||
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.updateOfPSASucceeded(""));
|
m_ismasClient.updateOfPSASucceeded(""));
|
||||||
|
|
||||||
|
emit appendText(QString(""), UPDATE_STEP_SUCCESS);
|
||||||
|
|
||||||
setProgress(100);
|
setProgress(100);
|
||||||
m_ismasClient.setProgressInPercent(100);
|
m_ismasClient.setProgressInPercent(100);
|
||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
QString("#M=APISM#C=CMD_EVENT#J=") + m_ismasClient.updateOfPSAActivated());
|
QString("#M=APISM#C=CMD_EVENT#J=") + m_ismasClient.updateOfPSAActivated());
|
||||||
|
|
||||||
m_returnCode = 0;
|
m_returnCode = 0;
|
||||||
} else {
|
|
||||||
stopProgressLoop();
|
|
||||||
|
|
||||||
int progress = (m_mainWindow->progressValue()/10) + 10;
|
|
||||||
setProgress(progress);
|
|
||||||
|
|
||||||
emit replaceLast("Initializing customer environment", UPDATE_STEP_FAIL);
|
|
||||||
|
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::UPDATE_PROCESS_FAILURE,
|
|
||||||
QString("CLONE OR CHECKOUT FAILED: ") + m_customerRepository);
|
|
||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
|
||||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
|
||||||
m_ismasClient.errorGitClone(100, m_updateStatus.m_statusDescription));
|
|
||||||
|
|
||||||
m_returnCode = -3;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
qInfo() << "CHECKOUT BRANCH...";
|
qCritical() << "CHECKOUT BRANCH...";
|
||||||
emit appendText("\nInitializing customer environment ...");
|
// checkout branch
|
||||||
startProgressLoop();
|
|
||||||
if (m_gc.gitCheckoutBranch()) {
|
if (m_gc.gitCheckoutBranch()) {
|
||||||
stopProgressLoop();
|
int progress = 10;
|
||||||
emit replaceLast("Initializing customer environment ...", UPDATE_STEP_DONE);
|
m_ismasClient.setProgressInPercent(progress);
|
||||||
setProgress(100);
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_CHECKOUT_BRANCH,
|
||||||
|
QString("CHECKED OUT BRANCH: ") + m_gc.branchName());
|
||||||
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
|
m_ismasClient.checkoutBranch(
|
||||||
|
m_updateStatus.m_statusDescription, ""));
|
||||||
|
setProgress(progress);
|
||||||
|
|
||||||
m_ismasClient.setProgressInPercent(10);
|
qCritical() << "CHECKED OUT BRANCH";
|
||||||
//m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_CHECKOUT_BRANCH,
|
if (backendConnected()) { qCritical() << "BACKEND CONNECTED";
|
||||||
// QString("CHECKED OUT BRANCH: ") + m_gc.branchName());
|
progress = 20;
|
||||||
//IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
setProgress(progress);
|
||||||
// QString("#M=APISM#C=CMD_EVENT#J=") +
|
m_ismasClient.setProgressInPercent(progress);
|
||||||
// m_ismasClient.checkoutBranch(
|
if (updateTriggerSet()) { qCritical() << "UPDATE TRIGGER SET";
|
||||||
// m_updateStatus.m_statusDescription, ""));
|
progress = 30;
|
||||||
|
setProgress(progress);
|
||||||
qInfo() << "CHECKED OUT BRANCH";
|
m_ismasClient.setProgressInPercent(progress);
|
||||||
if (backendConnected()) {
|
if (customerEnvironment()) { qCritical() << "CUSTOMER ENVIRONMENT";
|
||||||
m_ismasClient.setProgressInPercent(20);
|
progress = 40;
|
||||||
if (updateTriggerSet()) {
|
setProgress(progress);
|
||||||
m_ismasClient.setProgressInPercent(30);
|
m_ismasClient.setProgressInPercent(progress);
|
||||||
if (customerEnvironment()) {
|
if (filesToUpdate()) { qCritical() << "FILES TO UPDATE";
|
||||||
m_ismasClient.setProgressInPercent(40);
|
progress = 50;
|
||||||
if (filesToUpdate()) {
|
setProgress(progress);
|
||||||
m_ismasClient.setProgressInPercent(50);
|
m_ismasClient.setProgressInPercent(progress);
|
||||||
if (updateFiles(50)) {
|
if (updateFiles(progress)) { qCritical() << "UPDATE FILES";
|
||||||
m_ismasClient.setProgressInPercent(60);
|
progress = 60;
|
||||||
if (syncCustomerRepositoryAndFS()) {
|
setProgress(progress);
|
||||||
m_ismasClient.setProgressInPercent(70);
|
m_ismasClient.setProgressInPercent(progress);
|
||||||
if (sendIsmasLastVersionNotification()) {
|
if (syncCustomerRepositoryAndFS()) { qCritical() << "SYNC REPOSITORY";
|
||||||
m_ismasClient.setProgressInPercent(80);
|
progress = 70;
|
||||||
|
setProgress(progress);
|
||||||
|
m_ismasClient.setProgressInPercent(progress);
|
||||||
|
if (sendIsmasLastVersionNotification()) { qCritical() << "SEND LAST NOTIFICATION";
|
||||||
|
progress = 80;
|
||||||
|
setProgress(progress);
|
||||||
|
m_ismasClient.setProgressInPercent(progress);
|
||||||
sentIsmasLastVersionNotification = true;
|
sentIsmasLastVersionNotification = true;
|
||||||
if (saveLogFile()) {
|
if (saveLogFile()) { qCritical() << "SAVE LOG FILE";
|
||||||
m_ismasClient.setProgressInPercent(90);
|
progress = 90;
|
||||||
|
setProgress(progress);
|
||||||
|
m_ismasClient.setProgressInPercent(progress);
|
||||||
|
emit appendText(QString("Update process "), UPDATE_STEP_SUCCESS);
|
||||||
|
|
||||||
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.updateOfPSASucceeded(""));
|
m_ismasClient.updateOfPSASucceeded(""));
|
||||||
|
|
||||||
// mark update as activated -> this resets the WAIT button
|
// mark update as activated -> this resets the WAIT button
|
||||||
m_ismasClient.setProgressInPercent(95);
|
progress = 100;
|
||||||
|
setProgress(progress);
|
||||||
|
|
||||||
|
m_ismasClient.setProgressInPercent(progress);
|
||||||
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.updateOfPSAActivated());
|
m_ismasClient.updateOfPSAActivated());
|
||||||
|
|
||||||
m_returnCode = 0;
|
m_returnCode = 0;
|
||||||
} else {
|
|
||||||
m_returnCode = -12;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
m_returnCode = -11;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
m_returnCode = -10;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
m_returnCode = -9;
|
m_returnCode = -9;
|
||||||
}
|
}
|
||||||
@ -278,8 +276,18 @@ void Worker::privateUpdate() {
|
|||||||
} else {
|
} else {
|
||||||
m_returnCode = -4;
|
m_returnCode = -4;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
m_returnCode = -3;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
m_returnCode = -2;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
m_returnCode = -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setProgress(100);
|
||||||
m_ismasClient.setProgressInPercent(100);
|
m_ismasClient.setProgressInPercent(100);
|
||||||
|
|
||||||
if (!sentIsmasLastVersionNotification) {
|
if (!sentIsmasLastVersionNotification) {
|
||||||
@ -288,54 +296,37 @@ void Worker::privateUpdate() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (m_returnCode != 0) {
|
if (m_returnCode != 0) {
|
||||||
stopProgressLoop();
|
emit appendText(QString("Update process "), UPDATE_STEP_FAIL);
|
||||||
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Worker::backendConnected() {
|
bool Worker::backendConnected() {
|
||||||
if (m_withoutIsmasDirectPort) { // useful for testing
|
static int repeat = 0;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
emit appendText("\nConnecting backend ...");
|
if (repeat < 3) {
|
||||||
|
qCritical() << "In backendConnected() -> #M=APISM#C=REQ_SELF#J={}";
|
||||||
for (int repeat = 0; repeat < 50; ++repeat) {
|
|
||||||
qInfo() << "REPEAT" << repeat << "In backendConnected() -> #M=APISM#C=REQ_SELF#J={}";
|
|
||||||
startProgressLoop();
|
|
||||||
std::optional<QString> result
|
std::optional<QString> result
|
||||||
= IsmasClient::sendRequestReceiveResponse(
|
= IsmasClient::sendRequestReceiveResponse(
|
||||||
IsmasClient::APISM::DIRECT_PORT, "#M=APISM#C=REQ_SELF#J={}");
|
IsmasClient::APISM::DIRECT_PORT, "#M=APISM#C=REQ_SELF#J={}");
|
||||||
if (result) {
|
if (result) {
|
||||||
stopProgressLoop();
|
|
||||||
int progress = (m_mainWindow->progressValue()/10) + 10;
|
|
||||||
setProgress(progress);
|
|
||||||
|
|
||||||
QString msg = result.value();
|
QString msg = result.value();
|
||||||
qInfo() << "In backendConnected() -> APISM response" << msg;
|
qCritical() << "In backendConnected() -> APISM response" << msg;
|
||||||
QJsonParseError parseError;
|
QJsonParseError parseError;
|
||||||
QJsonDocument document(QJsonDocument::fromJson(msg.toUtf8(), &parseError));
|
QJsonDocument document(QJsonDocument::fromJson(msg.toUtf8(), &parseError));
|
||||||
if (parseError.error != QJsonParseError::NoError) {
|
if (parseError.error != QJsonParseError::NoError) {
|
||||||
qCritical() << "(2) INVALID JSON MSG: PARSING FAILED (msg=" << msg << "):"
|
qCritical() << "(2) INVALID JSON MSG: PARSING FAILED (msg=" << msg << "):"
|
||||||
<< parseError.error << parseError.errorString();
|
<< parseError.error << parseError.errorString();
|
||||||
emit replaceLast("Connecting backend ...", UPDATE_STEP_FAIL);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!document.isObject()) {
|
if (!document.isObject()) {
|
||||||
qCritical() << "FILE IS NOT A JSON OBJECT!";
|
qCritical() << "FILE IS NOT A JSON OBJECT!";
|
||||||
emit replaceLast("Connecting backend ...", UPDATE_STEP_FAIL);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
setProgress(progress + 1);
|
|
||||||
|
|
||||||
QJsonObject obj = document.object();
|
QJsonObject obj = document.object();
|
||||||
QStringList keys = obj.keys();
|
QStringList keys = obj.keys();
|
||||||
for (QString const& key : keys ) {
|
for (QString const& key : keys ) {
|
||||||
@ -345,36 +336,30 @@ bool Worker::backendConnected() {
|
|||||||
obj = v.toObject();
|
obj = v.toObject();
|
||||||
bool ismas = obj.value("ISMAS").toBool();
|
bool ismas = obj.value("ISMAS").toBool();
|
||||||
QString status = obj.value("Broker").toString();
|
QString status = obj.value("Broker").toString();
|
||||||
qInfo() << "REPEAT" << repeat << "In backendConnected() Broker=<"
|
|
||||||
<< status << ">, ISMAS=<" << (ismas ? "true>" : "false>");
|
qCritical() << "In backendConnected() STATUS" << status;
|
||||||
|
|
||||||
if (ismas) {
|
if (ismas) {
|
||||||
if (status == "Connected") {
|
if (status == "Connected") {
|
||||||
// do not send, as this would result in a corrupted wait button
|
// do not send, as this would result in a corrupted wait button
|
||||||
// but update the user-interface
|
// but update the user-interface
|
||||||
setProgress(100);
|
emit appendText("\nBackend connected", UPDATE_STEP_OK);
|
||||||
emit replaceLast("Connecting backend ...", UPDATE_STEP_OK);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
emit showErrorMessage("Check backend connection",
|
if (status.startsWith("Connecting") || status.startsWith("Re-Connecting")) {
|
||||||
QString ("REPEAT %1 Broker=<").arg(repeat)
|
QThread::sleep(1);
|
||||||
+ status + ">, ISMAS=<" + (ismas ? "true>" : "false>"));
|
++repeat;
|
||||||
QThread::sleep(6);
|
return backendConnected();
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
}
|
emit appendText("\nBackend connected", UPDATE_STEP_FAIL);
|
||||||
}
|
|
||||||
} else {
|
|
||||||
stopProgressLoop();
|
|
||||||
int progress = (m_mainWindow->progressValue()/10) + 10;
|
|
||||||
setProgress(progress);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
setProgress(100);
|
|
||||||
|
|
||||||
emit replaceLast("Connecting backend", UPDATE_STEP_FAIL);
|
|
||||||
emit showErrorMessage("Error", "Backend not available");
|
emit showErrorMessage("Error", "Backend not available");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
qCritical() << "In backendConnected() ERROR";
|
||||||
|
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::BACKEND_NOT_CONNECTED,
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::BACKEND_NOT_CONNECTED,
|
||||||
QString("NO BACKEND CONNECTION"));
|
QString("NO BACKEND CONNECTION"));
|
||||||
@ -386,26 +371,18 @@ bool Worker::backendConnected() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Worker::updateTriggerSet() {
|
bool Worker::updateTriggerSet() {
|
||||||
if (m_withoutIsmasDirectPort) { // useful for testing
|
// nmap -Pn 62.141.45.68 -p 8883
|
||||||
return true;
|
// Host is up (0.053s latency).
|
||||||
}
|
//
|
||||||
|
// PORT STATE SERVICE
|
||||||
|
// 8883/tcp open secure-mqtt
|
||||||
|
|
||||||
emit appendText("\nUpdate trigger set ...");
|
|
||||||
QString triggerValue("");
|
QString triggerValue("");
|
||||||
|
|
||||||
for (int repeat = 0; repeat < 50; ++repeat) {
|
|
||||||
startProgressLoop();
|
|
||||||
if (std::optional<QString> result
|
if (std::optional<QString> result
|
||||||
= IsmasClient::sendRequestReceiveResponse(
|
= IsmasClient::sendRequestReceiveResponse(
|
||||||
IsmasClient::APISM::DIRECT_PORT, "#M=APISM#C=REQ_ISMASPARAMETER#J={}")) {
|
IsmasClient::APISM::DIRECT_PORT, "#M=APISM#C=REQ_ISMASPARAMETER#J={}")) {
|
||||||
stopProgressLoop();
|
|
||||||
int progress = (m_mainWindow->progressValue()/10) + 10;
|
|
||||||
setProgress(progress);
|
|
||||||
|
|
||||||
QString msg = result.value();
|
QString msg = result.value();
|
||||||
|
|
||||||
qInfo() << "REPEAT" << repeat << "APISM RESPONSE" << msg;
|
|
||||||
|
|
||||||
QJsonParseError parseError;
|
QJsonParseError parseError;
|
||||||
QJsonDocument document(QJsonDocument::fromJson(msg.toUtf8(), &parseError));
|
QJsonDocument document(QJsonDocument::fromJson(msg.toUtf8(), &parseError));
|
||||||
if (parseError.error != QJsonParseError::NoError) {
|
if (parseError.error != QJsonParseError::NoError) {
|
||||||
@ -413,23 +390,17 @@ bool Worker::updateTriggerSet() {
|
|||||||
<< parseError.error << parseError.errorString();
|
<< parseError.error << parseError.errorString();
|
||||||
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);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!document.isObject()) {
|
if (!document.isObject()) {
|
||||||
qCritical() << "FILE IS NOT A JSON OBJECT!";
|
qCritical() << "FILE IS NOT A JSON OBJECT!";
|
||||||
emit showErrorMessage("check update trigger",
|
emit showErrorMessage("check update trigger",
|
||||||
QString("not a json object") + msg);
|
QString("not a json object") + msg);
|
||||||
emit replaceLast("Update trigger set ...", UPDATE_STEP_FAIL);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
setProgress(progress + 1);
|
|
||||||
|
|
||||||
QJsonObject obj = document.object();
|
QJsonObject obj = document.object();
|
||||||
// sanity check: cust_nr and machine_nr of PSA correct ?
|
// sanity check: cust_nr and machine_nr of PSA correct ?
|
||||||
// note: this check has to be done here, as the cust_nr and the machine_nr
|
|
||||||
// of the PSA are sent by ISMAS.
|
|
||||||
if (obj.contains("Dev_ID")) {
|
if (obj.contains("Dev_ID")) {
|
||||||
QJsonValue v = obj.value("Dev_ID");
|
QJsonValue v = obj.value("Dev_ID");
|
||||||
if (v.isObject()) {
|
if (v.isObject()) {
|
||||||
@ -449,11 +420,9 @@ 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);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (machineNr != m_machineNr) {
|
if (machineNr != m_machineNr) {
|
||||||
setProgress(100);
|
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_FAILURE,
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_FAILURE,
|
||||||
QString("MACHINE-NR (%1) != LOCAL MACHINE-NR (%2)")
|
QString("MACHINE-NR (%1) != LOCAL MACHINE-NR (%2)")
|
||||||
.arg(machineNr).arg(m_machineNr));
|
.arg(machineNr).arg(m_machineNr));
|
||||||
@ -463,15 +432,11 @@ 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);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setProgress(progress + 1);
|
|
||||||
|
|
||||||
if (obj.contains("Fileupload")) {
|
if (obj.contains("Fileupload")) {
|
||||||
QJsonValue v = obj.value("Fileupload");
|
QJsonValue v = obj.value("Fileupload");
|
||||||
if (v.isObject()) {
|
if (v.isObject()) {
|
||||||
@ -480,13 +445,9 @@ bool Worker::updateTriggerSet() {
|
|||||||
v = obj.value("TRG");
|
v = obj.value("TRG");
|
||||||
if (v.isString()) {
|
if (v.isString()) {
|
||||||
triggerValue = v.toString();
|
triggerValue = v.toString();
|
||||||
|
|
||||||
qInfo() << "REPEAT" << repeat
|
|
||||||
<< "In updateTriggerSet() TRG value=<"
|
|
||||||
<< triggerValue << ">";
|
|
||||||
|
|
||||||
if (triggerValue == "WAIT") {
|
if (triggerValue == "WAIT") {
|
||||||
setProgress(100);
|
emit appendText("\nUpdate trigger set", UPDATE_STEP_OK);
|
||||||
|
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::UPDATE_TRIGGER_SET,
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::UPDATE_TRIGGER_SET,
|
||||||
QString("UPDATE TRIGGER SET. CONTINUE. "));
|
QString("UPDATE TRIGGER SET. CONTINUE. "));
|
||||||
|
|
||||||
@ -494,14 +455,11 @@ bool Worker::updateTriggerSet() {
|
|||||||
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);
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
emit showErrorMessage("check update trigger",
|
emit showErrorMessage("check update trigger",
|
||||||
QString ("TRG value=<") + triggerValue
|
QString ("TRG key=<") + triggerValue
|
||||||
+ ">\n(reset download button?)");
|
+ ">\n(reset download button?)");
|
||||||
QThread::sleep(6);
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -511,158 +469,76 @@ bool Worker::updateTriggerSet() {
|
|||||||
emit showErrorMessage("check update trigger", "Fileupload not a json-object");
|
emit showErrorMessage("check update trigger", "Fileupload not a json-object");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj.contains("error")) {
|
|
||||||
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 << ">";
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
stopProgressLoop();
|
|
||||||
int progress = (m_mainWindow->progressValue()/10) + 10;
|
|
||||||
setProgress(progress);
|
|
||||||
emit showErrorMessage("check update trigger", "no ISMAS response");
|
emit showErrorMessage("check update trigger", "no ISMAS response");
|
||||||
QThread::sleep(6);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setProgress(100);
|
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::UPDATE_TRIGGER_NOT_SET_OR_WRONG,
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::UPDATE_TRIGGER_NOT_SET_OR_WRONG,
|
||||||
QString("UPDATE-TRIGGER-NOT-SET-OR-WRONG: VALUE=(") +
|
QString("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);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Worker::customerEnvironment() {
|
bool Worker::customerEnvironment() {
|
||||||
emit appendText("\nPrepare customer environment ...");
|
|
||||||
if (QDir(m_customerRepository).exists()) {
|
if (QDir(m_customerRepository).exists()) {
|
||||||
startProgressLoop();
|
|
||||||
if (m_gc.gitCheckoutBranch()) {
|
if (m_gc.gitCheckoutBranch()) {
|
||||||
stopProgressLoop();
|
emit appendText("\nPrepare customer environment", UPDATE_STEP_DONE);
|
||||||
int progress = (m_mainWindow->progressValue()/10) + 10;
|
|
||||||
setProgress(progress);
|
|
||||||
|
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_CHECKOUT_BRANCH,
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_CHECKOUT_BRANCH,
|
||||||
QString("CHECKED-OUT BRANCH ") + m_gc.branchName());
|
QString("CHECKED-OUT BRANCH ") + m_gc.branchName());
|
||||||
|
|
||||||
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.checkoutBranch(m_updateStatus.m_statusDescription, ""));
|
m_ismasClient.checkoutBranch(m_updateStatus.m_statusDescription, ""));
|
||||||
|
|
||||||
setProgress(100);
|
|
||||||
emit replaceLast("Prepare customer environment ...", UPDATE_STEP_DONE);
|
|
||||||
qInfo() << "PREPARE CUSTOMER ENVIRONMENT DONE";
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
stopProgressLoop();
|
|
||||||
int progress = (m_mainWindow->progressValue()/10) + 10;
|
|
||||||
setProgress(progress);
|
|
||||||
emit showErrorMessage("cust-env",
|
emit showErrorMessage("cust-env",
|
||||||
QString("Checkout ") + m_customerRepository + " failed");
|
QString("Checkout ") + m_customerRepository + " failed");
|
||||||
qCritical() << QString(80, '*');
|
|
||||||
qCritical() << "CHECKOUT OF" << m_customerRepository << "FAILED";
|
|
||||||
qCritical() << QString(80, '*');
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
emit showErrorMessage("cust-env", m_customerRepository + " does not exist");
|
emit showErrorMessage("cust-env", m_customerRepository + " does not exist");
|
||||||
qCritical() << QString(80, '*');
|
|
||||||
qCritical() << m_customerRepository << "DOES NOT EXIST";
|
|
||||||
qCritical() << QString(80, '*');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setProgress(100);
|
|
||||||
emit replaceLast("Prepare customer environment ...", UPDATE_STEP_FAIL);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Worker::filesToUpdate() {
|
bool Worker::filesToUpdate() {
|
||||||
emit appendText("\nFetch changes files ...");
|
|
||||||
startProgressLoop();
|
|
||||||
if (std::optional<QString> changes = m_gc.gitFetch()) {
|
if (std::optional<QString> changes = m_gc.gitFetch()) {
|
||||||
stopProgressLoop();
|
|
||||||
int progress = (m_mainWindow->progressValue()/10) + 10;
|
|
||||||
setProgress(progress);
|
|
||||||
|
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_FETCH_UPDATES,
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_FETCH_UPDATES,
|
||||||
QString("FETCHING OF ") + m_customerRepositoryPath +
|
QString("FETCHING OF ") + m_customerRepositoryPath +
|
||||||
QString(" INTO ") + m_customerRepository);
|
QString(" INTO ") + m_customerRepository);
|
||||||
|
|
||||||
setProgress(progress + 10);
|
|
||||||
if (std::optional<QStringList> changedFileNames = m_gc.gitDiff(changes.value())) {
|
if (std::optional<QStringList> changedFileNames = m_gc.gitDiff(changes.value())) {
|
||||||
setProgress(progress + 20);
|
|
||||||
if (m_gc.gitPull()) {
|
|
||||||
emit replaceLast(QString("Fetch changes files ..."), UPDATE_STEP_DONE);
|
|
||||||
m_filesToUpdate = changedFileNames.value();
|
m_filesToUpdate = changedFileNames.value();
|
||||||
|
|
||||||
qInfo() << QString(80, '*');
|
|
||||||
qInfo() << "FILES-TO-UPDATE" << m_filesToUpdate;
|
|
||||||
qInfo() << QString(80, '*');
|
|
||||||
|
|
||||||
int const size = m_filesToUpdate.size();
|
int const size = m_filesToUpdate.size();
|
||||||
if (size > 1) {
|
if (size > 1) {
|
||||||
emit appendText(QString("Found %1 files to update :").arg(size), UPDATE_STEP_DONE);
|
emit appendText(QString("\nFound %1 files to update ").arg(size), UPDATE_STEP_DONE);
|
||||||
for (int i = 0; i < size; ++i) {
|
|
||||||
emit appendText(QString("\n ") + m_filesToUpdate.at(i));
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
emit appendText("Found 1 file to update :", UPDATE_STEP_DONE);
|
emit appendText(QString("\nFound 1 file to update "), UPDATE_STEP_DONE);
|
||||||
emit appendText(QString("\n ") + m_filesToUpdate.at(0));
|
|
||||||
}
|
}
|
||||||
|
if (m_gc.gitPull()) {
|
||||||
|
emit appendText(QString("\nFetch changes files "), UPDATE_STEP_DONE);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
emit showErrorMessage("files to update", "pulling files failed");
|
emit showErrorMessage("files to update", "pulling files failed");
|
||||||
|
|
||||||
qCritical() << QString(80, '*');
|
|
||||||
qCritical() << "PULLING FILES FAILED";
|
|
||||||
qCritical() << QString(80, '*');
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
emit showErrorMessage("files to update", "no files to update (checked-in any files?)");
|
emit showErrorMessage("files to update", "no files to update (checked-in any files?)");
|
||||||
|
|
||||||
qCritical() << QString(80, '*');
|
|
||||||
qCritical() << "NO FILES TO UPDATE (CHECKED IN ANY FILES?)";
|
|
||||||
qCritical() << QString(80, '*');
|
|
||||||
}
|
}
|
||||||
setProgress(progress + 30);
|
|
||||||
} else {
|
} else {
|
||||||
stopProgressLoop();
|
|
||||||
int progress = (m_mainWindow->progressValue()/10) + 10;
|
|
||||||
setProgress(progress + 30);
|
|
||||||
|
|
||||||
emit showErrorMessage("files to update",
|
emit showErrorMessage("files to update",
|
||||||
QString("no changes in ") + m_customerRepository +
|
QString("no changes in ") + m_customerRepository +
|
||||||
" (checked-in any files?)");
|
" (checked-in any files?)");
|
||||||
|
|
||||||
qCritical() << QString(80, '*');
|
|
||||||
qCritical() << "NO CHANGES IN" << m_customerRepository << "(CHECKED IN ANY FILES?)";
|
|
||||||
qCritical() << QString(80, '*');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
emit replaceLast(QString("Fetch changes files ..."), UPDATE_STEP_FAIL);
|
|
||||||
setProgress(100);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Worker::updateFiles(quint8 percent) {
|
bool Worker::updateFiles(quint8 percent) {
|
||||||
QStringList filesToDownload;
|
QStringList filesToDownload;
|
||||||
m_displayIndex = 0;
|
m_displayIndex = 0;
|
||||||
|
|
||||||
startProgressLoop();
|
|
||||||
for (int i = 0; i < m_filesToUpdate.size(); ++i) {
|
for (int i = 0; i < m_filesToUpdate.size(); ++i) {
|
||||||
QString fName = m_filesToUpdate.at(i);
|
QString fName = m_filesToUpdate.at(i);
|
||||||
|
|
||||||
qInfo() << QString(80, '*');
|
|
||||||
qInfo() << "FNAME" << fName;
|
|
||||||
qInfo() << QString(80, '*');
|
|
||||||
|
|
||||||
if (fName.contains("opkg_commands", Qt::CaseInsensitive)) {
|
if (fName.contains("opkg_commands", Qt::CaseInsensitive)) {
|
||||||
emit appendText("\n( ) Update opkg pakets ...");
|
|
||||||
// execute opkg commands
|
// execute opkg commands
|
||||||
if (QDir::setCurrent(m_customerRepository)) {
|
if (QDir::setCurrent(m_customerRepository)) {
|
||||||
QFile f(fName);
|
QFile f(fName);
|
||||||
@ -690,12 +566,8 @@ 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(")")
|
emit appendText(QString("\n(") + QString("%1").arg(m_displayIndex).rightJustified(2, ' ') + QString(")")
|
||||||
+ QString(" Update opkg pakets ... "), UPDATE_STEP_DONE);
|
+ QString(" Update opkg pakets "), UPDATE_STEP_DONE);
|
||||||
} else {
|
|
||||||
m_displayIndex = 1;
|
|
||||||
emit replaceLast(QString("(") + QString("%1").arg(m_displayIndex).rightJustified(2, ' ') + QString(")")
|
|
||||||
+ QString(" Update opkg pakets ... "), UPDATE_STEP_FAIL);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -703,39 +575,22 @@ bool Worker::updateFiles(quint8 percent) {
|
|||||||
} else
|
} else
|
||||||
if (fName.contains("print", Qt::CaseInsensitive)) {
|
if (fName.contains("print", Qt::CaseInsensitive)) {
|
||||||
filesToDownload << fName; // download printer-config-files
|
filesToDownload << fName; // download printer-config-files
|
||||||
} else {
|
} else
|
||||||
static const QRegularExpression version("^.*dc2c[.][0-9][0-9][.][0-9][0-9][.]bin.*$");
|
if (fName == "dc2c.bin") {
|
||||||
if (fName.contains(version)) {
|
|
||||||
filesToDownload << fName; // download device controller
|
filesToDownload << fName; // download device controller
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
stopProgressLoop();
|
|
||||||
setProgress(100);
|
|
||||||
bool ret = true;
|
|
||||||
|
|
||||||
if (filesToDownload.size() > 0) {
|
if (filesToDownload.size() > 0) {
|
||||||
qInfo() << QString(80, '*');
|
qCritical() << "FILES_TO_WORK_ON" << filesToDownload;
|
||||||
qInfo() << "FILES_TO_WORK_ON" << filesToDownload;
|
|
||||||
qInfo() << QString(80, '*');
|
|
||||||
ret = m_update->doUpdate(m_displayIndex, filesToDownload);
|
|
||||||
} else {
|
|
||||||
qInfo() << QString(80, '*');
|
|
||||||
qInfo() << "NO FILES_TO_WORK_ON";
|
|
||||||
qInfo() << QString(80, '*');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return m_update->doUpdate(m_displayIndex, filesToDownload);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Worker::syncCustomerRepositoryAndFS() {
|
bool Worker::syncCustomerRepositoryAndFS() {
|
||||||
setProgress(0);
|
|
||||||
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)) {
|
||||||
int progress = 10;
|
|
||||||
setProgress(progress);
|
|
||||||
QString const params("-vv "
|
QString const params("-vv "
|
||||||
"--recursive "
|
"--recursive "
|
||||||
"--progress "
|
"--progress "
|
||||||
@ -752,37 +607,29 @@ bool Worker::syncCustomerRepositoryAndFS() {
|
|||||||
QString cmd;
|
QString cmd;
|
||||||
bool error = false;
|
bool error = false;
|
||||||
foreach (cmd, cmds) {
|
foreach (cmd, cmds) {
|
||||||
progress += 5;
|
|
||||||
setProgress(progress);
|
|
||||||
if (!error) {
|
if (!error) {
|
||||||
Command c("bash");
|
Command c("bash");
|
||||||
qInfo() << "EXECUTING CMD..." << cmd;
|
qInfo() << "EXECUTING CMD..." << cmd;
|
||||||
if (c.execute(m_customerRepository, QStringList() << "-c" << cmd)) {
|
if (c.execute(m_customerRepository, QStringList() << "-c" << cmd)) {
|
||||||
QStringList result = c.getCommandResult().split('\n');
|
QStringList result = c.getCommandResult().split('\n');
|
||||||
for (int i = 0; i < result.size(); ++i) {
|
for (int i = 0; i < result.size(); ++i) {
|
||||||
qInfo() << result.at(i);
|
qCritical() << result.at(i);
|
||||||
}
|
}
|
||||||
qInfo() << "SUCCESS";
|
qCritical() << "SUCCESS";
|
||||||
} else {
|
} else {
|
||||||
qCritical() << QString(80, '*');
|
|
||||||
qCritical() << "CMD" << cmd << "FAILED";
|
qCritical() << "CMD" << cmd << "FAILED";
|
||||||
qCritical() << c.getCommandResult().split('\n');
|
qCritical() << c.getCommandResult().split('\n');
|
||||||
qCritical() << QString(80, '*');
|
|
||||||
error = true;
|
error = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
progress += 5;
|
|
||||||
setProgress(progress);
|
|
||||||
if (!error) {
|
if (!error) {
|
||||||
setProgress(100);
|
emit appendText(QString("\nSync customer environment with filesystem "),
|
||||||
emit replaceLast(QString("Sync customer environment with filesystem ..."), UPDATE_STEP_DONE);
|
UPDATE_STEP_DONE);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setProgress(100);
|
|
||||||
emit replaceLast(QString("Sync customer environment with filesystem ..."), UPDATE_STEP_FAIL);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -790,7 +637,7 @@ bool Worker::sendIsmasLastVersionNotification() {
|
|||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
QString("#M=APISM#C=CMD_SENDVERSION#J=") +
|
QString("#M=APISM#C=CMD_SENDVERSION#J=") +
|
||||||
m_ismasClient.updateOfPSASendVersion(getPSAInstalled()));
|
m_ismasClient.updateOfPSASendVersion(getPSAInstalled()));
|
||||||
emit appendText(QString("Send last version info "), UPDATE_STEP_DONE);
|
emit appendText(QString("\nSend last version info "), UPDATE_STEP_DONE);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -889,11 +736,9 @@ bool Worker::executeOpkgCommand(QString opkgCommand) {
|
|||||||
.arg(c.getCommandResult()));
|
.arg(c.getCommandResult()));
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
qCritical() << QString(80, '*');
|
|
||||||
qCritical() << UpdateStatus(UPDATE_STATUS::EXEC_OPKG_COMMAND_FAILURE,
|
qCritical() << UpdateStatus(UPDATE_STATUS::EXEC_OPKG_COMMAND_FAILURE,
|
||||||
QString("EXECUTE OPKG COMMAND %1 FAILED")
|
QString("EXECUTE OPKG COMMAND %1 FAILED")
|
||||||
.arg(opkgCommand));
|
.arg(opkgCommand));
|
||||||
qCritical() << QString(80, '*');
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
5
worker.h
5
worker.h
@ -127,7 +127,6 @@ class Worker : public QObject {
|
|||||||
|
|
||||||
MainWindow *m_mainWindow;
|
MainWindow *m_mainWindow;
|
||||||
int m_progressValue;
|
int m_progressValue;
|
||||||
bool m_withoutIsmasDirectPort;
|
|
||||||
|
|
||||||
bool executeOpkgCommand(QString opkgCommand);
|
bool executeOpkgCommand(QString opkgCommand);
|
||||||
QString getOsVersion() const;
|
QString getOsVersion() const;
|
||||||
@ -160,8 +159,6 @@ public:
|
|||||||
|
|
||||||
void setMainWindow(MainWindow *mainWindow) { m_mainWindow = mainWindow; }
|
void setMainWindow(MainWindow *mainWindow) { m_mainWindow = mainWindow; }
|
||||||
void setProgress(int progress);
|
void setProgress(int progress);
|
||||||
void startProgressLoop();
|
|
||||||
void stopProgressLoop();
|
|
||||||
|
|
||||||
IsmasClient &getIsmasClient() { return m_ismasClient; }
|
IsmasClient &getIsmasClient() { return m_ismasClient; }
|
||||||
IsmasClient const &getIsmasClient() const { return m_ismasClient; }
|
IsmasClient const &getIsmasClient() const { return m_ismasClient; }
|
||||||
@ -208,6 +205,8 @@ private:
|
|||||||
PSAInstalled getPSAInstalled();
|
PSAInstalled getPSAInstalled();
|
||||||
QString sendCmdSendVersionToIsmas();
|
QString sendCmdSendVersionToIsmas();
|
||||||
void privateUpdate();
|
void privateUpdate();
|
||||||
|
void startProgressLoop();
|
||||||
|
void stopProgressLoop();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // WORKER_H_INCLUDED
|
#endif // WORKER_H_INCLUDED
|
||||||
|
Loading…
x
Reference in New Issue
Block a user