Send custom events to the progress bar according to the state of the update process.
Changed the handling of messages for the text edit.
This commit is contained in:
parent
4caa0c0d83
commit
6d43cf4c9f
244
worker.cpp
244
worker.cpp
@ -149,8 +149,14 @@ void Worker::privateUpdate() {
|
|||||||
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()) {
|
||||||
emit appendText("\nInitializing customer environment", UPDATE_STEP_DONE);
|
stopProgressLoop();
|
||||||
|
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);
|
||||||
@ -160,82 +166,90 @@ 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 {
|
||||||
qCritical() << "CHECKOUT BRANCH...";
|
qInfo() << "CHECKOUT BRANCH...";
|
||||||
// checkout branch
|
emit appendText("\nInitializing customer environment ...");
|
||||||
|
startProgressLoop();
|
||||||
if (m_gc.gitCheckoutBranch()) {
|
if (m_gc.gitCheckoutBranch()) {
|
||||||
int progress = 10;
|
stopProgressLoop();
|
||||||
m_ismasClient.setProgressInPercent(progress);
|
emit replaceLast("Initializing customer environment ...", UPDATE_STEP_DONE);
|
||||||
|
setProgress(100);
|
||||||
|
|
||||||
|
m_ismasClient.setProgressInPercent(10);
|
||||||
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_ismasClient.checkoutBranch(
|
||||||
m_updateStatus.m_statusDescription, ""));
|
m_updateStatus.m_statusDescription, ""));
|
||||||
setProgress(progress);
|
|
||||||
|
|
||||||
qCritical() << "CHECKED OUT BRANCH";
|
qCritical() << "CHECKED OUT BRANCH";
|
||||||
if (backendConnected()) { qCritical() << "BACKEND CONNECTED";
|
if (backendConnected()) { qCritical() << "BACKEND CONNECTED";
|
||||||
progress = 20;
|
m_ismasClient.setProgressInPercent(20);
|
||||||
setProgress(progress);
|
|
||||||
m_ismasClient.setProgressInPercent(progress);
|
|
||||||
if (updateTriggerSet()) { qCritical() << "UPDATE TRIGGER SET";
|
if (updateTriggerSet()) { qCritical() << "UPDATE TRIGGER SET";
|
||||||
progress = 30;
|
m_ismasClient.setProgressInPercent(30);
|
||||||
setProgress(progress);
|
|
||||||
m_ismasClient.setProgressInPercent(progress);
|
|
||||||
if (customerEnvironment()) { qCritical() << "CUSTOMER ENVIRONMENT";
|
if (customerEnvironment()) { qCritical() << "CUSTOMER ENVIRONMENT";
|
||||||
progress = 40;
|
m_ismasClient.setProgressInPercent(40);
|
||||||
setProgress(progress);
|
|
||||||
m_ismasClient.setProgressInPercent(progress);
|
|
||||||
if (filesToUpdate()) { qCritical() << "FILES TO UPDATE";
|
if (filesToUpdate()) { qCritical() << "FILES TO UPDATE";
|
||||||
progress = 50;
|
m_ismasClient.setProgressInPercent(50);
|
||||||
setProgress(progress);
|
if (updateFiles(50)) { qCritical() << "UPDATE FILES";
|
||||||
m_ismasClient.setProgressInPercent(progress);
|
m_ismasClient.setProgressInPercent(60);
|
||||||
if (updateFiles(progress)) { qCritical() << "UPDATE FILES";
|
|
||||||
progress = 60;
|
|
||||||
setProgress(progress);
|
|
||||||
m_ismasClient.setProgressInPercent(progress);
|
|
||||||
if (syncCustomerRepositoryAndFS()) { qCritical() << "SYNC REPOSITORY";
|
if (syncCustomerRepositoryAndFS()) { qCritical() << "SYNC REPOSITORY";
|
||||||
progress = 70;
|
m_ismasClient.setProgressInPercent(70);
|
||||||
setProgress(progress);
|
|
||||||
m_ismasClient.setProgressInPercent(progress);
|
|
||||||
if (sendIsmasLastVersionNotification()) { qCritical() << "SEND LAST NOTIFICATION";
|
if (sendIsmasLastVersionNotification()) { qCritical() << "SEND LAST NOTIFICATION";
|
||||||
progress = 80;
|
m_ismasClient.setProgressInPercent(80);
|
||||||
setProgress(progress);
|
|
||||||
m_ismasClient.setProgressInPercent(progress);
|
|
||||||
sentIsmasLastVersionNotification = true;
|
sentIsmasLastVersionNotification = true;
|
||||||
if (saveLogFile()) { qCritical() << "SAVE LOG FILE";
|
if (saveLogFile()) { qCritical() << "SAVE LOG FILE";
|
||||||
progress = 90;
|
m_ismasClient.setProgressInPercent(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
|
||||||
progress = 100;
|
m_ismasClient.setProgressInPercent(95);
|
||||||
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;
|
||||||
}
|
}
|
||||||
@ -254,18 +268,8 @@ 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) {
|
||||||
@ -274,9 +278,13 @@ void Worker::privateUpdate() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (m_returnCode != 0) {
|
if (m_returnCode != 0) {
|
||||||
emit appendText(QString("Update process "), UPDATE_STEP_FAIL);
|
stopProgressLoop();
|
||||||
|
emit appendText(QString("UPDATE "), UPDATE_STEP_FAIL);
|
||||||
|
} else {
|
||||||
|
emit appendText(QString("UPDATE "), UPDATE_STEP_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setProgress(100);
|
||||||
m_updateProcessRunning = false;
|
m_updateProcessRunning = false;
|
||||||
emit enableExit();
|
emit enableExit();
|
||||||
emit restartExitTimer();
|
emit restartExitTimer();
|
||||||
@ -285,26 +293,39 @@ void Worker::privateUpdate() {
|
|||||||
bool Worker::backendConnected() {
|
bool Worker::backendConnected() {
|
||||||
static int repeat = 0;
|
static int repeat = 0;
|
||||||
|
|
||||||
|
if (repeat == 0) {
|
||||||
|
emit appendText("\nConnecting backend ...");
|
||||||
|
}
|
||||||
|
|
||||||
if (repeat < 3) {
|
if (repeat < 3) {
|
||||||
qCritical() << "In backendConnected() -> #M=APISM#C=REQ_SELF#J={}";
|
qInfo() << 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();
|
||||||
qCritical() << "In backendConnected() -> APISM response" << msg;
|
qInfo() << "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 + 10);
|
||||||
|
|
||||||
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 ) {
|
||||||
@ -314,14 +335,13 @@ 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() << "In backendConnected() STATUS" << status;
|
||||||
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
|
||||||
emit appendText("\nBackend connected", UPDATE_STEP_OK);
|
setProgress(100);
|
||||||
|
emit replaceLast("Connecting backend ...", UPDATE_STEP_OK);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -330,14 +350,20 @@ bool Worker::backendConnected() {
|
|||||||
++repeat;
|
++repeat;
|
||||||
return backendConnected();
|
return backendConnected();
|
||||||
}
|
}
|
||||||
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"));
|
||||||
@ -355,11 +381,17 @@ bool Worker::updateTriggerSet() {
|
|||||||
// PORT STATE SERVICE
|
// PORT STATE SERVICE
|
||||||
// 8883/tcp open secure-mqtt
|
// 8883/tcp open secure-mqtt
|
||||||
|
|
||||||
|
emit appendText("\nUpdate trigger set ...");
|
||||||
QString triggerValue("");
|
QString triggerValue("");
|
||||||
|
|
||||||
|
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();
|
||||||
QJsonParseError parseError;
|
QJsonParseError parseError;
|
||||||
QJsonDocument document(QJsonDocument::fromJson(msg.toUtf8(), &parseError));
|
QJsonDocument document(QJsonDocument::fromJson(msg.toUtf8(), &parseError));
|
||||||
@ -368,15 +400,19 @@ 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 ?
|
||||||
if (obj.contains("Dev_ID")) {
|
if (obj.contains("Dev_ID")) {
|
||||||
@ -398,9 +434,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;
|
||||||
}
|
}
|
||||||
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));
|
||||||
@ -410,11 +448,15 @@ 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()) {
|
||||||
@ -424,8 +466,7 @@ bool Worker::updateTriggerSet() {
|
|||||||
if (v.isString()) {
|
if (v.isString()) {
|
||||||
triggerValue = v.toString();
|
triggerValue = v.toString();
|
||||||
if (triggerValue == "WAIT") {
|
if (triggerValue == "WAIT") {
|
||||||
emit appendText("\nUpdate trigger set", UPDATE_STEP_OK);
|
setProgress(100);
|
||||||
|
|
||||||
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. "));
|
||||||
|
|
||||||
@ -433,6 +474,7 @@ 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",
|
||||||
@ -448,72 +490,111 @@ bool Worker::updateTriggerSet() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} 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");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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()) {
|
||||||
emit appendText("\nPrepare customer environment", UPDATE_STEP_DONE);
|
stopProgressLoop();
|
||||||
|
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);
|
||||||
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");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
emit showErrorMessage("cust-env", m_customerRepository + " does not exist");
|
emit showErrorMessage("cust-env", m_customerRepository + " does not exist");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
int const size = m_filesToUpdate.size();
|
int const size = m_filesToUpdate.size();
|
||||||
if (size > 1) {
|
if (size > 1) {
|
||||||
emit appendText(QString("\nFound %1 files to update ").arg(size), UPDATE_STEP_DONE);
|
emit appendText(QString("Found %1 files to update ").arg(size), UPDATE_STEP_DONE);
|
||||||
} else {
|
} else {
|
||||||
emit appendText(QString("\nFound 1 file to update "), UPDATE_STEP_DONE);
|
emit appendText("Found 1 file to update ", UPDATE_STEP_DONE);
|
||||||
}
|
}
|
||||||
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");
|
||||||
} 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?)");
|
||||||
}
|
}
|
||||||
|
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?)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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) {
|
||||||
|
emit appendText("\n( ) Update opkg pakets ...");
|
||||||
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);
|
||||||
if (fName.contains("opkg_commands", Qt::CaseInsensitive)) {
|
if (fName.contains("opkg_commands", Qt::CaseInsensitive)) {
|
||||||
@ -544,8 +625,8 @@ bool Worker::updateFiles(quint8 percent) {
|
|||||||
f.close();
|
f.close();
|
||||||
if (cmdCount > 0) {
|
if (cmdCount > 0) {
|
||||||
m_displayIndex = 1;
|
m_displayIndex = 1;
|
||||||
emit appendText(QString("\n(") + QString("%1").arg(m_displayIndex).rightJustified(2, ' ') + QString(")")
|
emit replaceLast(QString("(") + QString("%1").arg(m_displayIndex).rightJustified(2, ' ') + QString(")")
|
||||||
+ QString(" Update opkg pakets "), UPDATE_STEP_DONE);
|
+ QString(" Update opkg pakets ... "), UPDATE_STEP_DONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -563,12 +644,19 @@ bool Worker::updateFiles(quint8 percent) {
|
|||||||
qCritical() << "FILES_TO_WORK_ON" << filesToDownload;
|
qCritical() << "FILES_TO_WORK_ON" << filesToDownload;
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_update->doUpdate(m_displayIndex, filesToDownload);
|
bool const ret = m_update->doUpdate(m_displayIndex, filesToDownload);
|
||||||
|
stopProgressLoop();
|
||||||
|
setProgress(100);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
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 "
|
||||||
@ -585,6 +673,8 @@ 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;
|
||||||
@ -601,13 +691,17 @@ bool Worker::syncCustomerRepositoryAndFS() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
progress += 5;
|
||||||
|
setProgress(progress);
|
||||||
if (!error) {
|
if (!error) {
|
||||||
emit appendText(QString("\nSync customer environment with filesystem "),
|
setProgress(100);
|
||||||
UPDATE_STEP_DONE);
|
emit replaceLast(QString("Sync customer environment with filesystem ..."), UPDATE_STEP_DONE);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
setProgress(100);
|
||||||
|
emit replaceLast(QString("Sync customer environment with filesystem ..."), UPDATE_STEP_FAIL);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -615,7 +709,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("\nSend last version info "), UPDATE_STEP_DONE);
|
emit appendText(QString("Send last version info "), UPDATE_STEP_DONE);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user