diff --git a/worker.cpp b/worker.cpp index aa73545..64faaad 100644 --- a/worker.cpp +++ b/worker.cpp @@ -214,30 +214,30 @@ void Worker::privateUpdate() { setProgress(100); m_ismasClient.setProgressInPercent(10); - 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, "")); + //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, "")); - qCritical() << "CHECKED OUT BRANCH"; - if (backendConnected()) { qCritical() << "BACKEND CONNECTED"; + qInfo() << "CHECKED OUT BRANCH"; + if (backendConnected()) { m_ismasClient.setProgressInPercent(20); - if (updateTriggerSet()) { qCritical() << "UPDATE TRIGGER SET"; + if (updateTriggerSet()) { m_ismasClient.setProgressInPercent(30); - if (customerEnvironment()) { qCritical() << "CUSTOMER ENVIRONMENT"; + if (customerEnvironment()) { m_ismasClient.setProgressInPercent(40); - if (filesToUpdate()) { qCritical() << "FILES TO UPDATE"; + if (filesToUpdate()) { m_ismasClient.setProgressInPercent(50); - if (updateFiles(50)) { qCritical() << "UPDATE FILES"; + if (updateFiles(50)) { m_ismasClient.setProgressInPercent(60); - if (syncCustomerRepositoryAndFS()) { qCritical() << "SYNC REPOSITORY"; + if (syncCustomerRepositoryAndFS()) { m_ismasClient.setProgressInPercent(70); - if (sendIsmasLastVersionNotification()) { qCritical() << "SEND LAST NOTIFICATION"; + if (sendIsmasLastVersionNotification()) { m_ismasClient.setProgressInPercent(80); sentIsmasLastVersionNotification = true; - if (saveLogFile()) { qCritical() << "SAVE LOG FILE"; + if (saveLogFile()) { m_ismasClient.setProgressInPercent(90); IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT, @@ -345,7 +345,8 @@ bool Worker::backendConnected() { obj = v.toObject(); bool ismas = obj.value("ISMAS").toBool(); QString status = obj.value("Broker").toString(); - qInfo() << "In backendConnected() STATUS" << status; + qInfo() << "REPEAT" << repeat << "In backendConnected() Broker=<" + << status << ">, ISMAS=<" << (ismas ? "true>" : "false>"); if (ismas) { if (status == "Connected") { // do not send, as this would result in a corrupted wait button @@ -536,6 +537,7 @@ bool Worker::customerEnvironment() { setProgress(100); emit replaceLast("Prepare customer environment ...", UPDATE_STEP_DONE); + qInfo() << "PREPARE CUSTOMER ENVIRONMENT DONE"; return true; } else { stopProgressLoop(); @@ -543,9 +545,15 @@ bool Worker::customerEnvironment() { setProgress(progress); emit showErrorMessage("cust-env", QString("Checkout ") + m_customerRepository + " failed"); + qCritical() << QString(80, '*'); + qCritical() << "CHECKOUT OF" << m_customerRepository << "FAILED"; + qCritical() << QString(80, '*'); } } else { emit showErrorMessage("cust-env", m_customerRepository + " does not exist"); + qCritical() << QString(80, '*'); + qCritical() << m_customerRepository << "DOES NOT EXIST"; + qCritical() << QString(80, '*'); } setProgress(100); @@ -571,17 +579,35 @@ bool Worker::filesToUpdate() { if (m_gc.gitPull()) { emit replaceLast(QString("Fetch changes files ..."), UPDATE_STEP_DONE); m_filesToUpdate = changedFileNames.value(); + + qInfo() << QString(80, '*'); + qInfo() << "FILES-TO-UPDATE" << m_filesToUpdate; + qInfo() << QString(80, '*'); + int const size = m_filesToUpdate.size(); if (size > 1) { - emit appendText(QString("Found %1 files to update ").arg(size), UPDATE_STEP_DONE); + 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)); + } } else { - emit appendText("Found 1 file to update ", UPDATE_STEP_DONE); + emit appendText("Found 1 file to update :", UPDATE_STEP_DONE); + emit appendText(QString("\n ") + m_filesToUpdate.at(0)); } return true; } emit showErrorMessage("files to update", "pulling files failed"); + + qCritical() << QString(80, '*'); + qCritical() << "PULLING FILES FAILED"; + qCritical() << QString(80, '*'); + } else { emit showErrorMessage("files to update", "no files to update (checked-in any files?)"); + + qCritical() << QString(80, '*'); + qCritical() << "NO FILES TO UPDATE (CHECKED IN ANY FILES?)"; + qCritical() << QString(80, '*'); } setProgress(progress + 30); } else { @@ -592,6 +618,10 @@ bool Worker::filesToUpdate() { emit showErrorMessage("files to update", QString("no changes in ") + m_customerRepository + " (checked-in any files?)"); + + qCritical() << QString(80, '*'); + qCritical() << "NO CHANGES IN" << m_customerRepository << "(CHECKED IN ANY FILES?)"; + qCritical() << QString(80, '*'); } emit replaceLast(QString("Fetch changes files ..."), UPDATE_STEP_FAIL); @@ -600,14 +630,19 @@ bool Worker::filesToUpdate() { } bool Worker::updateFiles(quint8 percent) { - emit appendText("\n( ) Update opkg pakets ..."); QStringList filesToDownload; m_displayIndex = 0; startProgressLoop(); for (int i = 0; i < m_filesToUpdate.size(); ++i) { QString fName = m_filesToUpdate.at(i); + + qInfo() << QString(80, '*'); + qInfo() << "FNAME" << fName; + qInfo() << QString(80, '*'); + if (fName.contains("opkg_commands", Qt::CaseInsensitive)) { + emit appendText("\n( ) Update opkg pakets ..."); // execute opkg commands if (QDir::setCurrent(m_customerRepository)) { QFile f(fName); @@ -644,19 +679,29 @@ bool Worker::updateFiles(quint8 percent) { } else if (fName.contains("print", Qt::CaseInsensitive)) { filesToDownload << fName; // download printer-config-files - } else - if (fName == "dc2c.bin") { - filesToDownload << fName; // download device controller + } else { + static const QRegularExpression version("^.*dc2c[.][0-9][0-9][.][0-9][0-9][.]bin.*$"); + if (fName.contains(version)) { + filesToDownload << fName; // download device controller + } } } - if (filesToDownload.size() > 0) { - qCritical() << "FILES_TO_WORK_ON" << filesToDownload; - } - - bool const ret = m_update->doUpdate(m_displayIndex, filesToDownload); stopProgressLoop(); setProgress(100); + bool ret = true; + + if (filesToDownload.size() > 0) { + qInfo() << QString(80, '*'); + qInfo() << "FILES_TO_WORK_ON" << filesToDownload; + qInfo() << QString(80, '*'); + ret = m_update->doUpdate(m_displayIndex, filesToDownload); + } else { + qInfo() << QString(80, '*'); + qInfo() << "NO FILES_TO_WORK_ON"; + qInfo() << QString(80, '*'); + } + return ret; } @@ -691,12 +736,14 @@ bool Worker::syncCustomerRepositoryAndFS() { if (c.execute(m_customerRepository, QStringList() << "-c" << cmd)) { QStringList result = c.getCommandResult().split('\n'); for (int i = 0; i < result.size(); ++i) { - qCritical() << result.at(i); + qInfo() << result.at(i); } - qCritical() << "SUCCESS"; + qInfo() << "SUCCESS"; } else { + qCritical() << QString(80, '*'); qCritical() << "CMD" << cmd << "FAILED"; qCritical() << c.getCommandResult().split('\n'); + qCritical() << QString(80, '*'); error = true; } } @@ -818,9 +865,11 @@ bool Worker::executeOpkgCommand(QString opkgCommand) { .arg(c.getCommandResult())); return true; } else { + qCritical() << QString(80, '*'); qCritical() << UpdateStatus(UPDATE_STATUS::EXEC_OPKG_COMMAND_FAILURE, QString("EXECUTE OPKG COMMAND %1 FAILED") .arg(opkgCommand)); + qCritical() << QString(80, '*'); } return false; }