Use output functions ISMAS(), GUI() and CONSOLE(), which point to friend
operators<< in Worker-class.
This commit is contained in:
parent
bef0d4fe12
commit
19dfae9b56
278
worker.cpp
278
worker.cpp
@ -592,23 +592,22 @@ bool Worker::updateTriggerSet() {
|
|||||||
QString triggerValue("");
|
QString triggerValue("");
|
||||||
|
|
||||||
for (int repeat = 1; repeat <= 100; ++repeat) {
|
for (int repeat = 1; repeat <= 100; ++repeat) {
|
||||||
CONSOLE(QStringList(FUNC_NAME) << QString("-> REPEAT=%1").arg(repeat)) << UPDATE_STEP::DEBUG;
|
|
||||||
|
|
||||||
if (repeat > 1) {
|
if (repeat > 1) {
|
||||||
int const startMs = QTime::currentTime().msecsSinceStartOfDay();
|
int const startMs = QTime::currentTime().msecsSinceStartOfDay();
|
||||||
int const durationMs = QTime::currentTime().msecsSinceStartOfDay() - startMs;
|
int const durationMs = QTime::currentTime().msecsSinceStartOfDay() - startMs;
|
||||||
QString const &s = QString("elapsed: %1.%2s").arg(durationMs / 1000).arg(durationMs % 1000);
|
QString const &s = QString("elapsed: %1.%2s").arg(durationMs / 1000).arg(durationMs % 1000);
|
||||||
CONSOLE(QStringList(FUNC_NAME) << s) << UPDATE_STEP::DEBUG;
|
CONSOLE(QStringList(func) << s) << UPDATE_STEP::DEBUG;
|
||||||
} else {
|
} else {
|
||||||
CONSOLE(QStringList(FUNC_NAME)) << UPDATE_STEP::DEBUG;
|
CONSOLE(QStringList(func) << QString("-> REPEAT=%1").arg(repeat)) << UPDATE_STEP::DEBUG;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((repeat % 10) == 0) {
|
if ((repeat % 10) == 0) {
|
||||||
CONSOLE(QStringList(FUNC_NAME) << "RESTART APISM") << UPDATE_STEP::DEBUG;
|
CONSOLE(QStringList(func) << "RESTART APISM") << UPDATE_STEP::DEBUG;
|
||||||
Command c("systemctl restart apism");
|
Command c("systemctl restart apism");
|
||||||
if (c.execute("/tmp")) {
|
if (c.execute("/tmp")) {
|
||||||
QThread::sleep(20); // give APISM some time to reconnect
|
QThread::sleep(20); // give APISM some time to reconnect
|
||||||
CONSOLE(QStringList(FUNC_NAME) << "RESTART APISM DONE") << UPDATE_STEP::DEBUG;
|
CONSOLE(QStringList(func) << "RESTART APISM DONE") << UPDATE_STEP::DEBUG;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -617,21 +616,21 @@ bool Worker::updateTriggerSet() {
|
|||||||
IsmasClient::APISM::DIRECT_PORT, "#M=APISM#C=REQ_ISMASPARAMETER#J={}")) {
|
IsmasClient::APISM::DIRECT_PORT, "#M=APISM#C=REQ_ISMASPARAMETER#J={}")) {
|
||||||
|
|
||||||
QString const &msg = QString("APISM RESPONSE(%1)=(").arg(repeat) + result.value() + ")";
|
QString const &msg = QString("APISM RESPONSE(%1)=(").arg(repeat) + result.value() + ")";
|
||||||
CONSOLE(QStringList(FUNC_NAME) << msg) << UPDATE_STEP::DEBUG;
|
CONSOLE(QStringList(func) << msg) << UPDATE_STEP::DEBUG;
|
||||||
|
|
||||||
QJsonParseError parseError;
|
QJsonParseError parseError;
|
||||||
QJsonDocument document(QJsonDocument::fromJson(msg.toUtf8(), &parseError));
|
QJsonDocument document(QJsonDocument::fromJson(result.value().toUtf8(), &parseError));
|
||||||
if (parseError.error != QJsonParseError::NoError) {
|
if (parseError.error != QJsonParseError::NoError) {
|
||||||
QStringList const &lst
|
QStringList lst(QString("INVALID JSON MSG: PARSING FAILED (json=<START>%1<END> error=[%2] str=[%3] offset=[%4])")
|
||||||
= QStringList(QString("check update trigger")) << QString("invalid json ")
|
.arg(msg)
|
||||||
+ QString("INVALID JSON MSG: PARSING FAILED (msg=%1 %2 %3)")
|
.arg(parseError.error)
|
||||||
.arg(msg).arg(parseError.error).arg(parseError.errorString()).mid(0, 20);
|
.arg(parseError.errorString())
|
||||||
|
.arg(parseError.offset));
|
||||||
GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE);
|
GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!document.isObject()) {
|
if (!document.isObject()) {
|
||||||
QStringList const &lst =
|
QStringList lst(QString("not a json-object %1").arg(result.value()));
|
||||||
QStringList(QString("check update trigger")) << QString("not a json-object ") + msg;
|
|
||||||
GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE);
|
GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -640,7 +639,8 @@ bool Worker::updateTriggerSet() {
|
|||||||
|
|
||||||
// always look for an 'error' first
|
// always look for an 'error' first
|
||||||
if (obj.contains("error")) {
|
if (obj.contains("error")) {
|
||||||
CONSOLE(QStringList(obj.value("error").toString())) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE;
|
QStringList lst(obj.value("error").toString());
|
||||||
|
CONSOLE(QStringList(lst)) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE;
|
||||||
QThread::sleep(6);
|
QThread::sleep(6);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -655,33 +655,29 @@ bool Worker::updateTriggerSet() {
|
|||||||
int const customerNr = obj.value("Custom_ID").toInt(-1);
|
int const customerNr = obj.value("Custom_ID").toInt(-1);
|
||||||
int const machineNr = obj.value("Device_ID").toInt(-1);
|
int const machineNr = obj.value("Device_ID").toInt(-1);
|
||||||
if (customerNr != m_customerNr) {
|
if (customerNr != m_customerNr) {
|
||||||
QStringList const &lst =
|
QStringList lst(QString("CUSTOMER-NR (%1) != LOCAL CUSTOMER-NR (%2)")
|
||||||
QStringList(QString("check update trigger"))
|
.arg(customerNr).arg(m_customerNr));
|
||||||
<< QString("CUSTOMER-NR (%1) != LOCAL CUSTOMER-NR (%2)")
|
|
||||||
.arg(customerNr).arg(m_customerNr);
|
|
||||||
GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE);
|
GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (machineNr != m_machineNr) {
|
if (machineNr != m_machineNr) {
|
||||||
QStringList const &lst =
|
QStringList lst(QString("MACHINE-NR (%1) != LOCAL MACHINE-NR (%2)")
|
||||||
QStringList(QString("check update trigger"))
|
.arg(machineNr).arg(m_machineNr));
|
||||||
<< QString("MACHINE-NR (%1) != LOCAL MACHINE-NR (%2)")
|
|
||||||
.arg(machineNr).arg(m_machineNr);
|
|
||||||
GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE);
|
GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
QStringList const lst("Dev_ID DOES NOT CONTAIN Custom_ID AND/OR Device_ID");
|
QStringList lst("Dev_ID DOES NOT CONTAIN Custom_ID AND/OR Device_ID");
|
||||||
GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE);
|
GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
QStringList const lst("Dev_ID KEY NOT A JSON-OBJECT");
|
QStringList lst("Dev_ID KEY NOT A JSON-OBJECT");
|
||||||
GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE);
|
GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
QStringList const lst("Dev_ID KEY NOT AVAILABLE");
|
QStringList lst("Dev_ID KEY NOT AVAILABLE");
|
||||||
GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE);
|
GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -692,157 +688,124 @@ bool Worker::updateTriggerSet() {
|
|||||||
obj = v.toObject();
|
obj = v.toObject();
|
||||||
if (obj.contains("TRG")) {
|
if (obj.contains("TRG")) {
|
||||||
if ((triggerValue = obj.value("TRG").toString()) == "WAIT") {
|
if ((triggerValue = obj.value("TRG").toString()) == "WAIT") {
|
||||||
GUI() << (ISMAS() << (CONSOLE() << UPDATE_STEP::CHECK_ISMAS_TRIGGER_SUCCESS));
|
m_ismasTriggerActive = true;
|
||||||
return true;
|
return m_ismasTriggerActive;
|
||||||
} else
|
} else
|
||||||
if (QRegExp("\\s*").exactMatch(triggerValue)) { // check for whitespace
|
if (QRegExp("\\s*").exactMatch(triggerValue)) { // check for whitespace
|
||||||
QStringList const &lst =
|
QStringList lst("empty update trigger");
|
||||||
QStringList(QString("check update trigger")) << QString("empty update trigger");
|
if (m_clone) {
|
||||||
|
GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_WRONG_VALUE);
|
||||||
|
// if the customer repository has just been cloned
|
||||||
|
break; // it is OK the ISMAS trigger might not be 'WAIT'
|
||||||
|
} else {
|
||||||
GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE);
|
GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE);
|
||||||
|
}
|
||||||
QThread::sleep(6);
|
QThread::sleep(6);
|
||||||
continue;
|
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
|
||||||
QStringList const &lst =
|
if (m_clone) {
|
||||||
QStringList(QString("check update trigger"))
|
GUI() << (CONSOLE() << UPDATE_STEP::CHECK_ISMAS_TRIGGER_WRONG_VALUE);
|
||||||
<< QString("TRIGGER-VALUE=<%1> NOT 'WAIT'").arg(triggerValue);
|
} else {
|
||||||
|
QStringList lst(QString("TRIGGER-VALUE=<%1> NOT 'WAIT'").arg(triggerValue));
|
||||||
|
GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
QStringList lst("TRG key not available");
|
||||||
GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE);
|
GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
QStringList const &lst =
|
QStringList lst("Fileupload not a json-object");
|
||||||
QStringList(QString("check update trigger")) << QString("TRG key not available");
|
|
||||||
GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE);
|
GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
QStringList const &lst =
|
QStringList lst(QString("Fileupload not available"));
|
||||||
QStringList(QString("check update trigger")) << QString("Fileupload not a json-object");
|
|
||||||
GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE);
|
GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
QStringList const &lst =
|
QStringList lst = QStringList(QString("no ISMAS response"));
|
||||||
QStringList(QString("check update trigger")) << QString("Fileupload not available");
|
|
||||||
GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
QStringList const &lst =
|
|
||||||
QStringList(QString("check update trigger")) << QString("no ISMAS response");
|
|
||||||
GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE);
|
GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE);
|
||||||
QThread::sleep(6);
|
QThread::sleep(6);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_initialClone == false) {
|
||||||
if (!triggerValue.contains("WAIT", Qt::CaseInsensitive)) {
|
if (!triggerValue.contains("WAIT", Qt::CaseInsensitive)) {
|
||||||
QStringList const &lst =
|
QStringList lst(QString("ISMAS_UPDATE-TRIGGER-NOT-SET-OR-WRONG: VALUE=(") + triggerValue + ")");
|
||||||
QStringList(QString("check update trigger"))
|
|
||||||
<< QString("ISMAS_UPDATE-TRIGGER-NOT-SET-OR-WRONG: VALUE=(") + triggerValue + ")";
|
|
||||||
ISMAS(lst) << (GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE));
|
ISMAS(lst) << (GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Worker::customerEnvironment(int progress) {
|
bool Worker::customerEnvironment() {
|
||||||
emit appendText("\nPrepare customer environment ...");
|
// configure customer environment -> checkout branch in case someone has
|
||||||
|
// changed the zone_nr
|
||||||
|
|
||||||
|
ISMAS() << (GUI() << (CONSOLE() << UPDATE_STEP::CHECKOUT_BRANCH));
|
||||||
|
|
||||||
if (QDir(m_customerRepository).exists()) {
|
if (QDir(m_customerRepository).exists()) {
|
||||||
startProgressLoop();
|
|
||||||
// setProgress(m_mainWindow->progressValue()/10 + 11);
|
|
||||||
if (m_gc.gitCheckoutBranch()) {
|
if (m_gc.gitCheckoutBranch()) {
|
||||||
stopProgressLoop();
|
|
||||||
m_ismasClient.setProgressInPercent(progress);
|
|
||||||
|
|
||||||
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, ""));
|
|
||||||
|
|
||||||
emit replaceLast("Prepare customer environment ...", UPDATE_STEP_DONE);
|
|
||||||
qInfo() << "PREPARE CUSTOMER ENVIRONMENT DONE";
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
stopProgressLoop();
|
QStringList lst(QString("CHECKOUT OF " + m_customerRepository + "FAILED"));
|
||||||
m_ismasClient.setProgressInPercent(0);
|
ISMAS(lst) << (GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECKOUT_BRANCH_FAILURE));
|
||||||
|
|
||||||
emit showErrorMessage("cust-env",
|
|
||||||
QString("Checkout ") + m_customerRepository + " failed");
|
|
||||||
Utils::printCriticalErrorMsg(QString("CHECKOUT OF " + m_customerRepository + "FAILED"));
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {// cannot happen
|
||||||
emit showErrorMessage("cust-env", m_customerRepository + " does not exist");
|
QStringList lst(QString(m_customerRepository + " DOES NOT EXIST"));
|
||||||
Utils::printCriticalErrorMsg(m_customerRepository + " DOES NOT EXIST");
|
ISMAS(lst) << (GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECKOUT_BRANCH_FAILURE));
|
||||||
}
|
}
|
||||||
|
|
||||||
emit replaceLast("Prepare customer environment ...", UPDATE_STEP_FAIL);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Worker::filesToUpdate(int progress) {
|
bool Worker::filesToUpdate() {
|
||||||
m_ismasClient.setProgressInPercent(progress);
|
// determine which files has to be updated: either sent to the hardware or
|
||||||
|
// rsynced with the filesystem in case of tariff-files
|
||||||
|
|
||||||
emit appendText("\nFetch changes files ...");
|
ISMAS() << (GUI() << (CONSOLE() << UPDATE_STEP::UPDATE_REPOSITORY));
|
||||||
startProgressLoop();
|
|
||||||
|
|
||||||
// always execute contents of opkg_commands-file
|
// always execute contents of opkg_commands-file
|
||||||
m_filesToUpdate << "etc/psa_update/opkg_commands";
|
m_filesToUpdate << "etc/psa_update/opkg_commands";
|
||||||
|
|
||||||
if (std::optional<QString> changes = m_gc.gitPull()) {
|
if (std::optional<QString> changes = m_gc.gitPull()) {
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_FETCH_UPDATES,
|
if (!changes.value().contains("Already up to date")) {
|
||||||
QString("FETCHING OF ") + m_customerRepositoryPath +
|
|
||||||
QString(" INTO ") + m_customerRepository);
|
|
||||||
|
|
||||||
if (std::optional<QStringList> changedFileNames = m_gc.gitDiff(changes.value())) {
|
if (std::optional<QStringList> changedFileNames = m_gc.gitDiff(changes.value())) {
|
||||||
if (m_gc.gitPull()) {
|
|
||||||
emit replaceLast(QString("Fetch changes files ..."), UPDATE_STEP_DONE);
|
|
||||||
m_filesToUpdate << changedFileNames.value();
|
m_filesToUpdate << changedFileNames.value();
|
||||||
} else {
|
|
||||||
emit showErrorMessage("files to update", "pulling files failed");
|
|
||||||
Utils::printCriticalErrorMsg("PULLING FILES FAILED");
|
|
||||||
|
|
||||||
emit replaceLast(QString("Fetch changes files ..."), UPDATE_STEP_FAIL);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Utils::printInfoMsg("FILES-TO-UPDATE " + m_filesToUpdate.join(','));
|
|
||||||
|
|
||||||
m_filesToUpdate.removeDuplicates();
|
m_filesToUpdate.removeDuplicates();
|
||||||
int const size = m_filesToUpdate.size();
|
|
||||||
if (size > 1) {
|
|
||||||
emit appendText(QString("Found %1 files to update :").arg(size), UPDATE_STEP_DONE);
|
|
||||||
for (int i = 0; i < size; ++i) {
|
|
||||||
emit appendText(QString("\n ") + m_filesToUpdate.at(i));
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
GUI() << (CONSOLE(m_filesToUpdate) << UPDATE_STEP::FILES_TO_UPDATE);
|
||||||
} else {
|
} else {
|
||||||
emit appendText("Found 1 file to update :", UPDATE_STEP_DONE);
|
ISMAS() << (GUI() << (CONSOLE() << UPDATE_STEP::UPDATE_REPOSITORY_FAILURE));
|
||||||
emit appendText(QString("\n ") + m_filesToUpdate.at(0));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Worker::updateFiles(int percent) {
|
bool Worker::updateFiles() {
|
||||||
m_filesToDownload.clear();
|
m_filesToDownload.clear();
|
||||||
m_displayIndex = 0;
|
m_displayIndex = 0;
|
||||||
startProgressLoop();
|
|
||||||
|
GUI(m_filesToUpdate) << (CONSOLE(m_filesToUpdate) << UPDATE_STEP::APPLY_REPOSITORY_CHANGES);
|
||||||
|
|
||||||
for (int i = 0; i < m_filesToUpdate.size(); ++i) {
|
for (int i = 0; i < m_filesToUpdate.size(); ++i) {
|
||||||
QString const fName = m_filesToUpdate.at(i);
|
QString const fName = m_filesToUpdate.at(i);
|
||||||
Utils::printInfoMsg(QString("FNAME ") + fName);
|
|
||||||
|
|
||||||
if (fName.contains("opkg_commands", Qt::CaseInsensitive)) {
|
if (fName.contains("opkg_commands", Qt::CaseInsensitive)) {
|
||||||
emit appendText("\n( ) Update opkg pakets ...");
|
GUI() << (CONSOLE() << UPDATE_STEP::EXEC_OPKG_COMMANDS);
|
||||||
// execute opkg commands
|
// execute opkg commands
|
||||||
if (QDir::setCurrent(m_customerRepository)) {
|
if (QDir::setCurrent(m_customerRepository)) {
|
||||||
QFile f(fName);
|
QFile f(fName);
|
||||||
if (f.exists()) {
|
if (f.exists()) {
|
||||||
if (f.open(QIODevice::ReadOnly)) {
|
if (f.open(QIODevice::ReadOnly)) {
|
||||||
QTextStream in(&f);
|
QTextStream in(&f);
|
||||||
QStringList opkgCommands;
|
m_opkgCommands.clear();
|
||||||
bool executeOpkgCommandFailed = false;
|
bool executeOpkgCommandFailed = false;
|
||||||
while (!in.atEnd()) {
|
while (!in.atEnd()) {
|
||||||
QString line = in.readLine();
|
QString line = in.readLine();
|
||||||
@ -855,31 +818,54 @@ bool Worker::updateFiles(int percent) {
|
|||||||
} else {
|
} else {
|
||||||
QString cmd = "\n " + opkgCommand;
|
QString cmd = "\n " + opkgCommand;
|
||||||
emit appendText(cmd);
|
emit appendText(cmd);
|
||||||
opkgCommands << cmd;
|
m_opkgCommands << cmd;
|
||||||
|
|
||||||
m_ismasClient.setProgressInPercent(++percent);
|
QStringList const opkgLst(opkgCommand);
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::EXEC_OPKG_COMMAND,
|
QStringList const cmdLst(cmd);
|
||||||
QString("EXEC OPKG-COMMAND ") + opkgCommand);
|
|
||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
switch(m_opkgCommands.size()) {
|
||||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
case 1:
|
||||||
m_ismasClient.execOpkgCommand(m_updateStatus.m_statusDescription, ""));
|
ISMAS(opkgLst) << (GUI(cmdLst) << (CONSOLE() << UPDATE_STEP::EXEC_OPKG_COMMAND_1));
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
ISMAS(opkgLst) << (GUI(cmdLst) << (CONSOLE() << UPDATE_STEP::EXEC_OPKG_COMMAND_2));
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
ISMAS(opkgLst) << (GUI(cmdLst) << (CONSOLE() << UPDATE_STEP::EXEC_OPKG_COMMAND_3));
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
ISMAS(opkgLst) << (GUI(cmdLst) << (CONSOLE() << UPDATE_STEP::EXEC_OPKG_COMMAND_4));
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
ISMAS(opkgLst) << (GUI(cmdLst) << (CONSOLE() << UPDATE_STEP::EXEC_OPKG_COMMAND_5));
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
ISMAS(opkgLst) << (GUI(cmdLst) << (CONSOLE() << UPDATE_STEP::EXEC_OPKG_COMMAND_6));
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
ISMAS(opkgLst) << (GUI(cmdLst) << (CONSOLE() << UPDATE_STEP::EXEC_OPKG_COMMAND_7));
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
ISMAS(opkgLst) << (GUI(cmdLst) << (CONSOLE() << UPDATE_STEP::EXEC_OPKG_COMMAND_8));
|
||||||
|
break;
|
||||||
|
case 9:
|
||||||
|
ISMAS(opkgLst) << (GUI(cmdLst) << (CONSOLE() << UPDATE_STEP::EXEC_OPKG_COMMAND_9));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ISMAS(opkgLst) << (GUI(cmdLst) << (CONSOLE() << UPDATE_STEP::EXEC_OPKG_COMMAND_LAST));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
f.close();
|
f.close();
|
||||||
if (!executeOpkgCommandFailed) {
|
if (!executeOpkgCommandFailed) {
|
||||||
if (opkgCommands.size() > 0) {
|
if (m_opkgCommands.size() > 0) {
|
||||||
m_displayIndex = 1;
|
m_displayIndex = 1;
|
||||||
QString prepend = QString("(") + QString("%1").arg(m_displayIndex).rightJustified(3, ' ') + QString(")")
|
GUI() << UPDATE_STEP::EXEC_OPKG_COMMAND_SUCCESS;
|
||||||
+ QString(" Update opkg pakets ... ");
|
|
||||||
opkgCommands.prepend(prepend);
|
|
||||||
emit replaceLast(opkgCommands, UPDATE_STEP_DONE);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
m_displayIndex = 1;
|
m_displayIndex = 1;
|
||||||
emit replaceLast(QString("(") + QString("%1").arg(m_displayIndex).rightJustified(3, ' ') + QString(")")
|
GUI() << UPDATE_STEP::EXEC_OPKG_COMMAND_FAILURE;
|
||||||
+ QString(" Update opkg pakets ... "), UPDATE_STEP_FAIL);
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -900,25 +886,24 @@ bool Worker::updateFiles(int percent) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (m_filesToDownload.size() > 0) {
|
if (m_filesToDownload.size() > 0) {
|
||||||
Utils::printInfoMsg(QString("FILES_TO_DOWNLOAD_TO_PSA_HW ") + m_filesToDownload.join(','));
|
CONSOLE(m_filesToDownload) << UPDATE_STEP::FILES_TO_DOWNLOAD;
|
||||||
|
|
||||||
Update *update = m_mainWindow->getUpdate();
|
Update *update = m_mainWindow->getUpdate();
|
||||||
if (update) {
|
if (update) {
|
||||||
return update->doUpdate(m_displayIndex, m_filesToDownload);
|
return update->doUpdate(m_displayIndex, m_filesToDownload);
|
||||||
} else {
|
} else {
|
||||||
Utils::printCriticalErrorMsg("UPDATE NOT SET");
|
CONSOLE(QStringList("UPDATE NOT SET")) << UPDATE_STEP::ERROR;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Utils::printCriticalErrorMsg("NO FILES_TO_DOWNLOAD_TO_PSA_HW");
|
CONSOLE(QStringList("NO FILES TO DOENLOAD TO PSA-HW")) << UPDATE_STEP::ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Worker::syncCustomerRepositoryAndFS(int progress) {
|
bool Worker::syncCustomerRepositoryAndFS() {
|
||||||
m_ismasClient.setProgressInPercent(progress);
|
ISMAS() << (GUI() << (CONSOLE() << UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY));
|
||||||
// this step is currently needed only for updating tariff-files
|
|
||||||
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");
|
Command md("bash");
|
||||||
@ -956,6 +941,7 @@ bool Worker::syncCustomerRepositoryAndFS(int progress) {
|
|||||||
QStringList result = c.getCommandResult().split('\n');
|
QStringList result = c.getCommandResult().split('\n');
|
||||||
QString const &p1 = "send_files mapped ";
|
QString const &p1 = "send_files mapped ";
|
||||||
QString const &p2 = "of size";
|
QString const &p2 = "of size";
|
||||||
|
|
||||||
for (int i = 0; i < result.size(); ++i) {
|
for (int i = 0; i < result.size(); ++i) {
|
||||||
QString line = result.at(i);
|
QString line = result.at(i);
|
||||||
qInfo() << line;
|
qInfo() << line;
|
||||||
@ -966,14 +952,16 @@ bool Worker::syncCustomerRepositoryAndFS(int progress) {
|
|||||||
if (sendFilesAtPos != -1 && ofSizeAtPos != -1) {
|
if (sendFilesAtPos != -1 && ofSizeAtPos != -1) {
|
||||||
sendFilesAtPos += p1.length();
|
sendFilesAtPos += p1.length();
|
||||||
QString const &s = line.mid(sendFilesAtPos, ofSizeAtPos - sendFilesAtPos).trimmed();
|
QString const &s = line.mid(sendFilesAtPos, ofSizeAtPos - sendFilesAtPos).trimmed();
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::RSYNC_FILE_SUCCESS,
|
|
||||||
QString("RSYNC FILE ") + s.split("/").last() +
|
//m_updateStatus = UpdateStatus(UPDATE_STATUS::RSYNC_FILE_SUCCESS,
|
||||||
" LAST-COMMIT: " + m_gc.gitLastCommit(s));
|
// QString("RSYNC FILE ") + s.split("/").last() +
|
||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
// " LAST-COMMIT: " + m_gc.gitLastCommit(s));
|
||||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
//IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
m_ismasClient.rsyncFile(m_updateStatus.m_statusDescription, ""));
|
// QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
|
// m_ismasClient.rsyncFile(m_updateStatus.m_statusDescription, ""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Utils::printCriticalErrorMsg(QString("CMD ") + cmd + " FAILED: "
|
Utils::printCriticalErrorMsg(QString("CMD ") + cmd + " FAILED: "
|
||||||
+ c.getCommandResult() + QString(" EXIT_CODE=(%1)").arg(c.exitCode()));
|
+ c.getCommandResult() + QString(" EXIT_CODE=(%1)").arg(c.exitCode()));
|
||||||
@ -986,18 +974,17 @@ bool Worker::syncCustomerRepositoryAndFS(int progress) {
|
|||||||
QDir dir1(QDir::cleanPath(m_customerRepository + QDir::separator() + "etc/psa_tariff"));
|
QDir dir1(QDir::cleanPath(m_customerRepository + QDir::separator() + "etc/psa_tariff"));
|
||||||
QDir dir2("/etc/psa_tariff");
|
QDir dir2("/etc/psa_tariff");
|
||||||
if (Utils::sameFilesInDirs(dir1, dir2)) {
|
if (Utils::sameFilesInDirs(dir1, dir2)) {
|
||||||
emit replaceLast(QString("Sync customer environment with filesystem ..."), UPDATE_STEP_DONE);
|
ISMAS() << (GUI() << (CONSOLE() << UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY_SUCCESS));
|
||||||
return true;
|
return true;
|
||||||
} else {
|
|
||||||
// TODO: send message to ISMAS
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
emit replaceLast(QString("Sync customer environment with filesystem ..."), UPDATE_STEP_FAIL);
|
ISMAS() << (GUI() << (CONSOLE() << UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY_FAILURE));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
bool Worker::sendIsmasLastVersionNotification(int progress) {
|
bool Worker::sendIsmasLastVersionNotification(int progress) {
|
||||||
m_ismasClient.setProgressInPercent(progress);
|
m_ismasClient.setProgressInPercent(progress);
|
||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
@ -1006,11 +993,14 @@ bool Worker::sendIsmasLastVersionNotification(int progress) {
|
|||||||
emit appendText(QString("Send last version info "), UPDATE_STEP_DONE);
|
emit appendText(QString("Send last version info "), UPDATE_STEP_DONE);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
bool Worker::saveLogFile(int progress) {
|
bool Worker::saveLogFile() {
|
||||||
m_ismasClient.setProgressInPercent(progress);
|
// ISMAS() << (GUI() << (CONSOLE() << UPDATE_STEP::SAVE_LOGS));
|
||||||
|
// ISMAS() << (GUI() << (CONSOLE() << UPDATE_STEP::SAVE_LOGS_FAILURE));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Worker::getOsVersion() const {
|
QString Worker::getOsVersion() const {
|
||||||
QString const cmd = QString("echo -n $(cat /etc/os-release | head -n 1 | cut -d'\"' -f2 | tr -d '\"')");
|
QString const cmd = QString("echo -n $(cat /etc/os-release | head -n 1 | cut -d'\"' -f2 | tr -d '\"')");
|
||||||
Command c("bash");
|
Command c("bash");
|
||||||
@ -1218,9 +1208,7 @@ PSAInstalled Worker::getPSAInstalled() {
|
|||||||
psaInstalled.dc.gitLastCommit = "N/A";
|
psaInstalled.dc.gitLastCommit = "N/A";
|
||||||
psaInstalled.dc.size = -1;
|
psaInstalled.dc.size = -1;
|
||||||
|
|
||||||
if (std::optional<QString> v = getApismVersion()) {
|
psaInstalled.sw.apismVersion = getAPISMYoctoVersion();
|
||||||
psaInstalled.sw.apismVersion = v.value();
|
|
||||||
}
|
|
||||||
psaInstalled.sw.atbQTVersion = getATBQTVersion();
|
psaInstalled.sw.atbQTVersion = getATBQTVersion();
|
||||||
psaInstalled.sw.atbUpdateToolVersion = m_atbUpdateToolVersion;
|
psaInstalled.sw.atbUpdateToolVersion = m_atbUpdateToolVersion;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user