Always look for {"error": "ISMAS is offline"} first.
Allow for empty update-trgger (try again) rsync: mkdir -p the necessary directories.
This commit is contained in:
parent
86064979b4
commit
66d0214720
73
worker.cpp
73
worker.cpp
@ -497,12 +497,14 @@ bool Worker::backendConnected() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define CHECK_UPDATE_TRIGGER_SET "Check update trigger ..."
|
||||||
|
|
||||||
bool Worker::updateTriggerSet() {
|
bool Worker::updateTriggerSet() {
|
||||||
if (m_withoutIsmasDirectPort) { // useful for testing
|
if (m_withoutIsmasDirectPort) { // useful for testing
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
emit appendText("\nUpdate trigger set ...");
|
emit appendText("\n" CHECK_UPDATE_TRIGGER_SET);
|
||||||
QString triggerValue("");
|
QString triggerValue("");
|
||||||
|
|
||||||
for (int repeat = 0; repeat < 50; ++repeat) {
|
for (int repeat = 0; repeat < 50; ++repeat) {
|
||||||
@ -518,7 +520,7 @@ bool Worker::updateTriggerSet() {
|
|||||||
|
|
||||||
QString msg = result.value();
|
QString msg = result.value();
|
||||||
|
|
||||||
qInfo() << "REPEAT" << repeat << "APISM RESPONSE" << msg;
|
qInfo() << "REPEAT" << repeat << "APISM RESPONSE (" << msg << ")";
|
||||||
|
|
||||||
QJsonParseError parseError;
|
QJsonParseError parseError;
|
||||||
QJsonDocument document(QJsonDocument::fromJson(msg.toUtf8(), &parseError));
|
QJsonDocument document(QJsonDocument::fromJson(msg.toUtf8(), &parseError));
|
||||||
@ -537,7 +539,7 @@ bool Worker::updateTriggerSet() {
|
|||||||
m_updateStatus.m_statusDescription));
|
m_updateStatus.m_statusDescription));
|
||||||
emit showErrorMessage("check update trigger",
|
emit showErrorMessage("check update trigger",
|
||||||
QString("invalid json ") + msg.mid(0, 20));
|
QString("invalid json ") + msg.mid(0, 20));
|
||||||
emit replaceLast("Update trigger set ...", UPDATE_STEP_FAIL);
|
emit replaceLast(CHECK_UPDATE_TRIGGER_SET, UPDATE_STEP_FAIL);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!document.isObject()) {
|
if (!document.isObject()) {
|
||||||
@ -550,13 +552,25 @@ bool Worker::updateTriggerSet() {
|
|||||||
m_ismasClient.jsonParseFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
m_ismasClient.jsonParseFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
||||||
m_updateStatus.m_statusDescription));
|
m_updateStatus.m_statusDescription));
|
||||||
emit showErrorMessage("check update trigger", QString("not a json object") + msg);
|
emit showErrorMessage("check update trigger", QString("not a json object") + msg);
|
||||||
emit replaceLast("Update trigger set ...", UPDATE_STEP_FAIL);
|
emit replaceLast(CHECK_UPDATE_TRIGGER_SET, UPDATE_STEP_FAIL);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
progress += 1;
|
progress += 1;
|
||||||
setProgress(progress);
|
setProgress(progress);
|
||||||
|
|
||||||
QJsonObject obj = document.object();
|
QJsonObject obj = document.object();
|
||||||
|
|
||||||
|
// always look for an 'error' first
|
||||||
|
if (obj.contains("error")) {
|
||||||
|
progress += 1;
|
||||||
|
setProgress(progress);
|
||||||
|
QString value = obj.value("error").toString();
|
||||||
|
emit showErrorMessage("check update trigger", QString("REPEAT %1 error=<").arg(repeat) + value + ">");
|
||||||
|
qInfo() << "REPEAT" << repeat << "In updateTriggerSet() error=<"
|
||||||
|
<< value << ">";
|
||||||
|
QThread::sleep(6);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
// sanity check: cust_nr and machine_nr of PSA correct ?
|
// sanity check: cust_nr and machine_nr of PSA correct ?
|
||||||
// note: this check has to be done here, as the cust_nr and the machine_nr
|
// note: this check has to be done here, as the cust_nr and the machine_nr
|
||||||
// of the PSA are sent by ISMAS.
|
// of the PSA are sent by ISMAS.
|
||||||
@ -579,7 +593,7 @@ bool Worker::updateTriggerSet() {
|
|||||||
m_ismasClient.sanityCheckFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
m_ismasClient.sanityCheckFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
||||||
m_updateStatus.m_statusDescription));
|
m_updateStatus.m_statusDescription));
|
||||||
emit showErrorMessage("check update trigger", m_updateStatus.m_statusDescription);
|
emit showErrorMessage("check update trigger", m_updateStatus.m_statusDescription);
|
||||||
emit replaceLast("Update trigger set ...", UPDATE_STEP_FAIL);
|
emit replaceLast(CHECK_UPDATE_TRIGGER_SET, UPDATE_STEP_FAIL);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (machineNr != m_machineNr) {
|
if (machineNr != m_machineNr) {
|
||||||
@ -592,7 +606,7 @@ bool Worker::updateTriggerSet() {
|
|||||||
m_ismasClient.sanityCheckFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
m_ismasClient.sanityCheckFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
||||||
m_updateStatus.m_statusDescription));
|
m_updateStatus.m_statusDescription));
|
||||||
emit showErrorMessage("check update trigger", m_updateStatus.m_statusDescription);
|
emit showErrorMessage("check update trigger", m_updateStatus.m_statusDescription);
|
||||||
emit replaceLast("Update trigger set ...", UPDATE_STEP_FAIL);
|
emit replaceLast(CHECK_UPDATE_TRIGGER_SET, UPDATE_STEP_FAIL);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -607,7 +621,7 @@ bool Worker::updateTriggerSet() {
|
|||||||
m_ismasClient.sanityCheckFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
m_ismasClient.sanityCheckFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
||||||
m_updateStatus.m_statusDescription));
|
m_updateStatus.m_statusDescription));
|
||||||
emit showErrorMessage("check update trigger", m_updateStatus.m_statusDescription);
|
emit showErrorMessage("check update trigger", m_updateStatus.m_statusDescription);
|
||||||
emit replaceLast("Update trigger set ...", UPDATE_STEP_FAIL);
|
emit replaceLast(CHECK_UPDATE_TRIGGER_SET, UPDATE_STEP_FAIL);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -619,7 +633,7 @@ bool Worker::updateTriggerSet() {
|
|||||||
m_ismasClient.sanityCheckFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
m_ismasClient.sanityCheckFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
||||||
m_updateStatus.m_statusDescription));
|
m_updateStatus.m_statusDescription));
|
||||||
emit showErrorMessage("check update trigger", m_updateStatus.m_statusDescription);
|
emit showErrorMessage("check update trigger", m_updateStatus.m_statusDescription);
|
||||||
emit replaceLast("Update trigger set ...", UPDATE_STEP_FAIL);
|
emit replaceLast(CHECK_UPDATE_TRIGGER_SET, UPDATE_STEP_FAIL);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -631,7 +645,7 @@ bool Worker::updateTriggerSet() {
|
|||||||
m_ismasClient.sanityCheckFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
m_ismasClient.sanityCheckFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
||||||
m_updateStatus.m_statusDescription));
|
m_updateStatus.m_statusDescription));
|
||||||
emit showErrorMessage("check update trigger", m_updateStatus.m_statusDescription);
|
emit showErrorMessage("check update trigger", m_updateStatus.m_statusDescription);
|
||||||
emit replaceLast("Update trigger set ...", UPDATE_STEP_FAIL);
|
emit replaceLast(CHECK_UPDATE_TRIGGER_SET, UPDATE_STEP_FAIL);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
progress += 1;
|
progress += 1;
|
||||||
@ -664,19 +678,28 @@ 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);
|
emit replaceLast(CHECK_UPDATE_TRIGGER_SET, UPDATE_STEP_DONE);
|
||||||
return true;
|
return true;
|
||||||
|
} else
|
||||||
|
if (QRegExp("\\s*").exactMatch(triggerValue)) { // check for whitespace
|
||||||
|
stopProgressLoop();
|
||||||
|
int progress = (m_mainWindow->progressValue()/10) + 10;
|
||||||
|
progress += 1;
|
||||||
|
setProgress(progress);
|
||||||
|
emit showErrorMessage("check update trigger", "empty update-trigger");
|
||||||
|
QThread::sleep(6);
|
||||||
|
continue;
|
||||||
} else {
|
} else {
|
||||||
// if the download-button once has the wrong value, it will never recover
|
// if the download-button once has the wrong value, it will never recover
|
||||||
setProgress(100);
|
setProgress(100);
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_FAILURE,
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_FAILURE,
|
||||||
QString("TRIGGER-VALUE ") + triggerValue + " NOT 'WAIT'");
|
QString("TRIGGER-VALUE=<") + triggerValue + "> NOT 'WAIT'");
|
||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
m_ismasClient.sanityCheckFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
m_ismasClient.sanityCheckFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
||||||
m_updateStatus.m_statusDescription));
|
m_updateStatus.m_statusDescription));
|
||||||
emit showErrorMessage("check update trigger", m_updateStatus.m_statusDescription);
|
emit showErrorMessage("check update trigger", m_updateStatus.m_statusDescription);
|
||||||
emit replaceLast("Update trigger set ...", UPDATE_STEP_FAIL);
|
emit replaceLast(CHECK_UPDATE_TRIGGER_SET, UPDATE_STEP_FAIL);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -687,7 +710,7 @@ bool Worker::updateTriggerSet() {
|
|||||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
m_ismasClient.sanityCheckFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
m_ismasClient.sanityCheckFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
||||||
m_updateStatus.m_statusDescription));
|
m_updateStatus.m_statusDescription));
|
||||||
emit replaceLast("Update trigger set ...", UPDATE_STEP_FAIL);
|
emit replaceLast(CHECK_UPDATE_TRIGGER_SET, UPDATE_STEP_FAIL);
|
||||||
emit showErrorMessage("check update trigger", m_updateStatus.m_statusDescription);
|
emit showErrorMessage("check update trigger", m_updateStatus.m_statusDescription);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -699,7 +722,7 @@ bool Worker::updateTriggerSet() {
|
|||||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
m_ismasClient.sanityCheckFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
m_ismasClient.sanityCheckFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
||||||
m_updateStatus.m_statusDescription));
|
m_updateStatus.m_statusDescription));
|
||||||
emit replaceLast("Update trigger set ...", UPDATE_STEP_FAIL);
|
emit replaceLast(CHECK_UPDATE_TRIGGER_SET, UPDATE_STEP_FAIL);
|
||||||
emit showErrorMessage("check update trigger", m_updateStatus.m_statusDescription);
|
emit showErrorMessage("check update trigger", m_updateStatus.m_statusDescription);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -711,20 +734,10 @@ bool Worker::updateTriggerSet() {
|
|||||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
m_ismasClient.sanityCheckFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
m_ismasClient.sanityCheckFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
||||||
m_updateStatus.m_statusDescription));
|
m_updateStatus.m_statusDescription));
|
||||||
emit replaceLast("Update trigger set ...", UPDATE_STEP_FAIL);
|
emit replaceLast(CHECK_UPDATE_TRIGGER_SET, UPDATE_STEP_FAIL);
|
||||||
emit showErrorMessage("check update trigger", m_updateStatus.m_statusDescription);
|
emit showErrorMessage("check update trigger", m_updateStatus.m_statusDescription);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj.contains("error")) {
|
|
||||||
progress += 1;
|
|
||||||
setProgress(progress);
|
|
||||||
QString value = obj.value("error").toString();
|
|
||||||
emit showErrorMessage("check update trigger", QString("REPEAT %1 error=<").arg(repeat) + value + ">");
|
|
||||||
qInfo() << "REPEAT" << repeat << "In updateTriggerSet() error=<"
|
|
||||||
<< value << ">";
|
|
||||||
QThread::sleep(6);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
stopProgressLoop();
|
stopProgressLoop();
|
||||||
int progress = (m_mainWindow->progressValue()/10) + 10;
|
int progress = (m_mainWindow->progressValue()/10) + 10;
|
||||||
@ -743,7 +756,7 @@ bool Worker::updateTriggerSet() {
|
|||||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
m_ismasClient.errorUpdateTrigger(m_updateStatus.m_statusDescription, ""));
|
m_ismasClient.errorUpdateTrigger(m_updateStatus.m_statusDescription, ""));
|
||||||
|
|
||||||
emit replaceLast("Update trigger set ...", UPDATE_STEP_OK);
|
emit replaceLast(CHECK_UPDATE_TRIGGER_SET, UPDATE_STEP_FAIL);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -919,10 +932,16 @@ bool Worker::updateFiles(quint8 percent) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Worker::syncCustomerRepositoryAndFS() {
|
bool Worker::syncCustomerRepositoryAndFS() {
|
||||||
|
// this step is currently needed only for updating tariff-files
|
||||||
setProgress(0);
|
setProgress(0);
|
||||||
emit appendText("\nSync customer environment with filesystem ...");
|
emit appendText("\nSync customer environment with filesystem ...");
|
||||||
if (QDir(m_customerRepository).exists()) {
|
if (QDir(m_customerRepository).exists()) {
|
||||||
if (QDir::setCurrent(m_customerRepository)) {
|
if (QDir::setCurrent(m_customerRepository)) {
|
||||||
|
Command md("bash");
|
||||||
|
if (!md.execute(m_customerRepository,
|
||||||
|
QStringList() << "-c" << "mkdir -p /etc/psa_config /etc/psa_update /etc/dc /etc/psa_tariff")) {
|
||||||
|
qCritical() << "COULD NOT EXECUTE '" << md.command() << "' exitCode=(" << md.exitCode() << ")";
|
||||||
|
}
|
||||||
int progress = 10;
|
int progress = 10;
|
||||||
setProgress(progress);
|
setProgress(progress);
|
||||||
QString const params("-vv "
|
QString const params("-vv "
|
||||||
@ -953,7 +972,7 @@ bool Worker::syncCustomerRepositoryAndFS() {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Utils::printCriticalErrorMsg(QString("CMD ") + cmd + " FAILED: "
|
Utils::printCriticalErrorMsg(QString("CMD ") + cmd + " FAILED: "
|
||||||
+ c.getCommandResult());
|
+ c.getCommandResult() + QString(" EXIT_CODE=(%1)").arg(c.exitCode()));
|
||||||
error = true;
|
error = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user