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("");
|
||||
|
||||
for (int repeat = 1; repeat <= 100; ++repeat) {
|
||||
CONSOLE(QStringList(FUNC_NAME) << QString("-> REPEAT=%1").arg(repeat)) << UPDATE_STEP::DEBUG;
|
||||
|
||||
if (repeat > 1) {
|
||||
int const startMs = QTime::currentTime().msecsSinceStartOfDay();
|
||||
int const durationMs = QTime::currentTime().msecsSinceStartOfDay() - startMs;
|
||||
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 {
|
||||
CONSOLE(QStringList(FUNC_NAME)) << UPDATE_STEP::DEBUG;
|
||||
CONSOLE(QStringList(func) << QString("-> REPEAT=%1").arg(repeat)) << UPDATE_STEP::DEBUG;
|
||||
}
|
||||
|
||||
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");
|
||||
if (c.execute("/tmp")) {
|
||||
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={}")) {
|
||||
|
||||
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;
|
||||
QJsonDocument document(QJsonDocument::fromJson(msg.toUtf8(), &parseError));
|
||||
QJsonDocument document(QJsonDocument::fromJson(result.value().toUtf8(), &parseError));
|
||||
if (parseError.error != QJsonParseError::NoError) {
|
||||
QStringList const &lst
|
||||
= QStringList(QString("check update trigger")) << QString("invalid json ")
|
||||
+ QString("INVALID JSON MSG: PARSING FAILED (msg=%1 %2 %3)")
|
||||
.arg(msg).arg(parseError.error).arg(parseError.errorString()).mid(0, 20);
|
||||
QStringList lst(QString("INVALID JSON MSG: PARSING FAILED (json=<START>%1<END> error=[%2] str=[%3] offset=[%4])")
|
||||
.arg(msg)
|
||||
.arg(parseError.error)
|
||||
.arg(parseError.errorString())
|
||||
.arg(parseError.offset));
|
||||
GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE);
|
||||
break;
|
||||
}
|
||||
if (!document.isObject()) {
|
||||
QStringList const &lst =
|
||||
QStringList(QString("check update trigger")) << QString("not a json-object ") + msg;
|
||||
QStringList lst(QString("not a json-object %1").arg(result.value()));
|
||||
GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE);
|
||||
break;
|
||||
}
|
||||
@ -640,7 +639,8 @@ bool Worker::updateTriggerSet() {
|
||||
|
||||
// always look for an 'error' first
|
||||
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);
|
||||
continue;
|
||||
}
|
||||
@ -655,33 +655,29 @@ bool Worker::updateTriggerSet() {
|
||||
int const customerNr = obj.value("Custom_ID").toInt(-1);
|
||||
int const machineNr = obj.value("Device_ID").toInt(-1);
|
||||
if (customerNr != m_customerNr) {
|
||||
QStringList const &lst =
|
||||
QStringList(QString("check update trigger"))
|
||||
<< QString("CUSTOMER-NR (%1) != LOCAL CUSTOMER-NR (%2)")
|
||||
.arg(customerNr).arg(m_customerNr);
|
||||
QStringList lst(QString("CUSTOMER-NR (%1) != LOCAL CUSTOMER-NR (%2)")
|
||||
.arg(customerNr).arg(m_customerNr));
|
||||
GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE);
|
||||
break;
|
||||
}
|
||||
if (machineNr != m_machineNr) {
|
||||
QStringList const &lst =
|
||||
QStringList(QString("check update trigger"))
|
||||
<< QString("MACHINE-NR (%1) != LOCAL MACHINE-NR (%2)")
|
||||
.arg(machineNr).arg(m_machineNr);
|
||||
QStringList lst(QString("MACHINE-NR (%1) != LOCAL MACHINE-NR (%2)")
|
||||
.arg(machineNr).arg(m_machineNr));
|
||||
GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE);
|
||||
break;
|
||||
}
|
||||
} 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);
|
||||
break;
|
||||
}
|
||||
} 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);
|
||||
break;
|
||||
}
|
||||
} 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);
|
||||
break;
|
||||
}
|
||||
@ -692,157 +688,124 @@ bool Worker::updateTriggerSet() {
|
||||
obj = v.toObject();
|
||||
if (obj.contains("TRG")) {
|
||||
if ((triggerValue = obj.value("TRG").toString()) == "WAIT") {
|
||||
GUI() << (ISMAS() << (CONSOLE() << UPDATE_STEP::CHECK_ISMAS_TRIGGER_SUCCESS));
|
||||
return true;
|
||||
m_ismasTriggerActive = true;
|
||||
return m_ismasTriggerActive;
|
||||
} else
|
||||
if (QRegExp("\\s*").exactMatch(triggerValue)) { // check for whitespace
|
||||
QStringList const &lst =
|
||||
QStringList(QString("check update trigger")) << QString("empty update trigger");
|
||||
QStringList lst("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);
|
||||
}
|
||||
QThread::sleep(6);
|
||||
continue;
|
||||
} else {
|
||||
// if the download-button once has the wrong value, it will never recover
|
||||
QStringList const &lst =
|
||||
QStringList(QString("check update trigger"))
|
||||
<< QString("TRIGGER-VALUE=<%1> NOT 'WAIT'").arg(triggerValue);
|
||||
if (m_clone) {
|
||||
GUI() << (CONSOLE() << UPDATE_STEP::CHECK_ISMAS_TRIGGER_WRONG_VALUE);
|
||||
} 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);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
QStringList const &lst =
|
||||
QStringList(QString("check update trigger")) << QString("TRG key not available");
|
||||
QStringList lst("Fileupload not a json-object");
|
||||
GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
QStringList const &lst =
|
||||
QStringList(QString("check update trigger")) << QString("Fileupload not a json-object");
|
||||
QStringList lst(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("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");
|
||||
QStringList lst = QStringList(QString("no ISMAS response"));
|
||||
GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE);
|
||||
QThread::sleep(6);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_initialClone == false) {
|
||||
if (!triggerValue.contains("WAIT", Qt::CaseInsensitive)) {
|
||||
QStringList const &lst =
|
||||
QStringList(QString("check update trigger"))
|
||||
<< QString("ISMAS_UPDATE-TRIGGER-NOT-SET-OR-WRONG: VALUE=(") + triggerValue + ")";
|
||||
QStringList lst(QString("ISMAS_UPDATE-TRIGGER-NOT-SET-OR-WRONG: VALUE=(") + triggerValue + ")");
|
||||
ISMAS(lst) << (GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE));
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Worker::customerEnvironment(int progress) {
|
||||
emit appendText("\nPrepare customer environment ...");
|
||||
bool Worker::customerEnvironment() {
|
||||
// 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()) {
|
||||
startProgressLoop();
|
||||
// setProgress(m_mainWindow->progressValue()/10 + 11);
|
||||
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;
|
||||
} else {
|
||||
stopProgressLoop();
|
||||
m_ismasClient.setProgressInPercent(0);
|
||||
|
||||
emit showErrorMessage("cust-env",
|
||||
QString("Checkout ") + m_customerRepository + " failed");
|
||||
Utils::printCriticalErrorMsg(QString("CHECKOUT OF " + m_customerRepository + "FAILED"));
|
||||
QStringList lst(QString("CHECKOUT OF " + m_customerRepository + "FAILED"));
|
||||
ISMAS(lst) << (GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECKOUT_BRANCH_FAILURE));
|
||||
}
|
||||
} else {
|
||||
emit showErrorMessage("cust-env", m_customerRepository + " does not exist");
|
||||
Utils::printCriticalErrorMsg(m_customerRepository + " DOES NOT EXIST");
|
||||
} else {// cannot happen
|
||||
QStringList lst(QString(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;
|
||||
}
|
||||
|
||||
bool Worker::filesToUpdate(int progress) {
|
||||
m_ismasClient.setProgressInPercent(progress);
|
||||
bool Worker::filesToUpdate() {
|
||||
// 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 ...");
|
||||
startProgressLoop();
|
||||
ISMAS() << (GUI() << (CONSOLE() << UPDATE_STEP::UPDATE_REPOSITORY));
|
||||
|
||||
// always execute contents of opkg_commands-file
|
||||
m_filesToUpdate << "etc/psa_update/opkg_commands";
|
||||
|
||||
if (std::optional<QString> changes = m_gc.gitPull()) {
|
||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_FETCH_UPDATES,
|
||||
QString("FETCHING OF ") + m_customerRepositoryPath +
|
||||
QString(" INTO ") + m_customerRepository);
|
||||
|
||||
if (!changes.value().contains("Already up to date")) {
|
||||
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();
|
||||
} 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();
|
||||
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 {
|
||||
emit appendText("Found 1 file to update :", UPDATE_STEP_DONE);
|
||||
emit appendText(QString("\n ") + m_filesToUpdate.at(0));
|
||||
}
|
||||
ISMAS() << (GUI() << (CONSOLE() << UPDATE_STEP::UPDATE_REPOSITORY_FAILURE));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Worker::updateFiles(int percent) {
|
||||
bool Worker::updateFiles() {
|
||||
m_filesToDownload.clear();
|
||||
m_displayIndex = 0;
|
||||
startProgressLoop();
|
||||
|
||||
GUI(m_filesToUpdate) << (CONSOLE(m_filesToUpdate) << UPDATE_STEP::APPLY_REPOSITORY_CHANGES);
|
||||
|
||||
for (int i = 0; i < m_filesToUpdate.size(); ++i) {
|
||||
QString const fName = m_filesToUpdate.at(i);
|
||||
Utils::printInfoMsg(QString("FNAME ") + fName);
|
||||
|
||||
if (fName.contains("opkg_commands", Qt::CaseInsensitive)) {
|
||||
emit appendText("\n( ) Update opkg pakets ...");
|
||||
GUI() << (CONSOLE() << UPDATE_STEP::EXEC_OPKG_COMMANDS);
|
||||
// execute opkg commands
|
||||
if (QDir::setCurrent(m_customerRepository)) {
|
||||
QFile f(fName);
|
||||
if (f.exists()) {
|
||||
if (f.open(QIODevice::ReadOnly)) {
|
||||
QTextStream in(&f);
|
||||
QStringList opkgCommands;
|
||||
m_opkgCommands.clear();
|
||||
bool executeOpkgCommandFailed = false;
|
||||
while (!in.atEnd()) {
|
||||
QString line = in.readLine();
|
||||
@ -855,31 +818,54 @@ bool Worker::updateFiles(int percent) {
|
||||
} else {
|
||||
QString cmd = "\n " + opkgCommand;
|
||||
emit appendText(cmd);
|
||||
opkgCommands << cmd;
|
||||
m_opkgCommands << cmd;
|
||||
|
||||
m_ismasClient.setProgressInPercent(++percent);
|
||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::EXEC_OPKG_COMMAND,
|
||||
QString("EXEC OPKG-COMMAND ") + opkgCommand);
|
||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||
m_ismasClient.execOpkgCommand(m_updateStatus.m_statusDescription, ""));
|
||||
QStringList const opkgLst(opkgCommand);
|
||||
QStringList const cmdLst(cmd);
|
||||
|
||||
switch(m_opkgCommands.size()) {
|
||||
case 1:
|
||||
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();
|
||||
if (!executeOpkgCommandFailed) {
|
||||
if (opkgCommands.size() > 0) {
|
||||
if (m_opkgCommands.size() > 0) {
|
||||
m_displayIndex = 1;
|
||||
QString prepend = QString("(") + QString("%1").arg(m_displayIndex).rightJustified(3, ' ') + QString(")")
|
||||
+ QString(" Update opkg pakets ... ");
|
||||
opkgCommands.prepend(prepend);
|
||||
emit replaceLast(opkgCommands, UPDATE_STEP_DONE);
|
||||
GUI() << UPDATE_STEP::EXEC_OPKG_COMMAND_SUCCESS;
|
||||
}
|
||||
} else {
|
||||
m_displayIndex = 1;
|
||||
emit replaceLast(QString("(") + QString("%1").arg(m_displayIndex).rightJustified(3, ' ') + QString(")")
|
||||
+ QString(" Update opkg pakets ... "), UPDATE_STEP_FAIL);
|
||||
|
||||
GUI() << UPDATE_STEP::EXEC_OPKG_COMMAND_FAILURE;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -900,25 +886,24 @@ bool Worker::updateFiles(int percent) {
|
||||
}
|
||||
|
||||
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();
|
||||
if (update) {
|
||||
return update->doUpdate(m_displayIndex, m_filesToDownload);
|
||||
} else {
|
||||
Utils::printCriticalErrorMsg("UPDATE NOT SET");
|
||||
CONSOLE(QStringList("UPDATE NOT SET")) << UPDATE_STEP::ERROR;
|
||||
}
|
||||
} else {
|
||||
Utils::printCriticalErrorMsg("NO FILES_TO_DOWNLOAD_TO_PSA_HW");
|
||||
CONSOLE(QStringList("NO FILES TO DOENLOAD TO PSA-HW")) << UPDATE_STEP::ERROR;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Worker::syncCustomerRepositoryAndFS(int progress) {
|
||||
m_ismasClient.setProgressInPercent(progress);
|
||||
// this step is currently needed only for updating tariff-files
|
||||
emit appendText("\nSync customer environment with filesystem ...");
|
||||
bool Worker::syncCustomerRepositoryAndFS() {
|
||||
ISMAS() << (GUI() << (CONSOLE() << UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY));
|
||||
|
||||
if (QDir(m_customerRepository).exists()) {
|
||||
if (QDir::setCurrent(m_customerRepository)) {
|
||||
Command md("bash");
|
||||
@ -956,6 +941,7 @@ bool Worker::syncCustomerRepositoryAndFS(int progress) {
|
||||
QStringList result = c.getCommandResult().split('\n');
|
||||
QString const &p1 = "send_files mapped ";
|
||||
QString const &p2 = "of size";
|
||||
|
||||
for (int i = 0; i < result.size(); ++i) {
|
||||
QString line = result.at(i);
|
||||
qInfo() << line;
|
||||
@ -966,14 +952,16 @@ bool Worker::syncCustomerRepositoryAndFS(int progress) {
|
||||
if (sendFilesAtPos != -1 && ofSizeAtPos != -1) {
|
||||
sendFilesAtPos += p1.length();
|
||||
QString const &s = line.mid(sendFilesAtPos, ofSizeAtPos - sendFilesAtPos).trimmed();
|
||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::RSYNC_FILE_SUCCESS,
|
||||
QString("RSYNC FILE ") + s.split("/").last() +
|
||||
" LAST-COMMIT: " + m_gc.gitLastCommit(s));
|
||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||
m_ismasClient.rsyncFile(m_updateStatus.m_statusDescription, ""));
|
||||
|
||||
//m_updateStatus = UpdateStatus(UPDATE_STATUS::RSYNC_FILE_SUCCESS,
|
||||
// QString("RSYNC FILE ") + s.split("/").last() +
|
||||
// " LAST-COMMIT: " + m_gc.gitLastCommit(s));
|
||||
//IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||
// QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||
// m_ismasClient.rsyncFile(m_updateStatus.m_statusDescription, ""));
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
Utils::printCriticalErrorMsg(QString("CMD ") + cmd + " FAILED: "
|
||||
+ 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 dir2("/etc/psa_tariff");
|
||||
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;
|
||||
} 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;
|
||||
}
|
||||
|
||||
#if 0
|
||||
bool Worker::sendIsmasLastVersionNotification(int progress) {
|
||||
m_ismasClient.setProgressInPercent(progress);
|
||||
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);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool Worker::saveLogFile(int progress) {
|
||||
m_ismasClient.setProgressInPercent(progress);
|
||||
bool Worker::saveLogFile() {
|
||||
// ISMAS() << (GUI() << (CONSOLE() << UPDATE_STEP::SAVE_LOGS));
|
||||
// ISMAS() << (GUI() << (CONSOLE() << UPDATE_STEP::SAVE_LOGS_FAILURE));
|
||||
return true;
|
||||
}
|
||||
|
||||
QString Worker::getOsVersion() const {
|
||||
QString const cmd = QString("echo -n $(cat /etc/os-release | head -n 1 | cut -d'\"' -f2 | tr -d '\"')");
|
||||
Command c("bash");
|
||||
@ -1218,9 +1208,7 @@ PSAInstalled Worker::getPSAInstalled() {
|
||||
psaInstalled.dc.gitLastCommit = "N/A";
|
||||
psaInstalled.dc.size = -1;
|
||||
|
||||
if (std::optional<QString> v = getApismVersion()) {
|
||||
psaInstalled.sw.apismVersion = v.value();
|
||||
}
|
||||
psaInstalled.sw.apismVersion = getAPISMYoctoVersion();
|
||||
psaInstalled.sw.atbQTVersion = getATBQTVersion();
|
||||
psaInstalled.sw.atbUpdateToolVersion = m_atbUpdateToolVersion;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user