Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
24bf190c90
|
|||
|
b656b5eab6
|
|||
|
6681e61f59
|
|||
|
7ec6ab00b1
|
+1
-1
@@ -9,7 +9,7 @@ psa-tariff-directory="etc/psa_tariff/"
|
||||
|
||||
|
||||
[PLUGINS]
|
||||
plugin-name="libCAslave.so"
|
||||
plugin-name="libCAmaster.so"
|
||||
|
||||
[FLAGS]
|
||||
no-psa-hardware-update=false
|
||||
|
||||
+2
-1
@@ -1,3 +1,4 @@
|
||||
TEMPLATE = subdirs
|
||||
CONFIG += ordered
|
||||
SUBDIRS = DownloadDCFirmware DownloadDCJsonFiles UpdatePTUDevCtrl
|
||||
#SUBDIRS = DownloadDCFirmware DownloadDCJsonFiles UpdatePTUDevCtrl
|
||||
SUBDIRS = UpdatePTUDevCtrl
|
||||
|
||||
@@ -2,6 +2,9 @@ QT += core serialport
|
||||
|
||||
TARGET = ATBUpdateDC
|
||||
|
||||
include(../common.pri)
|
||||
|
||||
|
||||
VERSION="0.1.0"
|
||||
win32 {
|
||||
BUILD_DATE=$$system("date /t")
|
||||
@@ -98,6 +101,9 @@ OTHER_FILES += \
|
||||
../ATBUpdateTool.ini
|
||||
|
||||
|
||||
FORMS += \
|
||||
mainwindow.ui
|
||||
|
||||
##########################################################################################
|
||||
# for running program on target through QtCreator
|
||||
contains( CONFIG, PTU5 ) {
|
||||
|
||||
+39
-28
@@ -4,6 +4,7 @@
|
||||
#include <QByteArray>
|
||||
|
||||
#include <QProcess>
|
||||
#include <QCommandLineParser>
|
||||
#include <QStandardPaths>
|
||||
#include <QSettings>
|
||||
#include <QDir>
|
||||
@@ -64,7 +65,9 @@ int main(int argc, char **argv) {
|
||||
setDebugLevel(LOG_NOTICE);
|
||||
}
|
||||
|
||||
/*
|
||||
//return 0;
|
||||
|
||||
/*
|
||||
CommandLineParser parser;
|
||||
parser.process(a);
|
||||
parser.readSettings();
|
||||
@@ -126,13 +129,21 @@ int main(int argc, char **argv) {
|
||||
printf(APP_EXTENDED_VERSION"\n");
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
|
||||
QString const &customerRepo
|
||||
= QDir::cleanPath(workingDir + QDir::separator() + QString("customer_%1").arg(customerNr));
|
||||
*/
|
||||
|
||||
QString const &psaDcDir = internal::customerRepoDcDir();
|
||||
QString const &psaRepoRootDir = internal::customerRepoRoot();
|
||||
QString const &psaRepoDir = internal::customerRepoDir();
|
||||
QString const &branchName = internal::branchName();
|
||||
|
||||
bool debug = false;
|
||||
bool noaction = true;
|
||||
QString workingDir;
|
||||
QString libDir;
|
||||
QString libca;
|
||||
QString workingDir;
|
||||
|
||||
std::unique_ptr<QSettings> settings = internal::readSettings();
|
||||
|
||||
@@ -151,37 +162,37 @@ int main(int argc, char **argv) {
|
||||
settings->endGroup();
|
||||
}
|
||||
|
||||
// etc/dc: located under mount-path
|
||||
std::optional<QString> mountPath = System::checkForUSBStick(psaDcDir);
|
||||
QFileInfo fi;
|
||||
if (mountPath.has_value()) {
|
||||
fi.setFile(mountPath.value(), System::getDCFileOnUsbStick(mountPath.value()));
|
||||
} else
|
||||
if ((mountPath = System::checkForSDCard(psaDcDir)).has_value()) {
|
||||
fi.setFile(mountPath.value(), System::getDCFileOnSDCard(mountPath.value()));
|
||||
} else {
|
||||
|
||||
// ------------------- single command line argument is DC-firmware binary file -----------------
|
||||
QStringList args = a.arguments();
|
||||
if (args.size() != 2) {
|
||||
qCritical() << "ERROR: missing parameter <dc-firmware>";
|
||||
exit(1);
|
||||
if (debug) {
|
||||
qInfo() << "using customer repository" << psaRepoDir;
|
||||
}
|
||||
|
||||
std::unique_ptr<QString> c = internal::dcCandidateToInstall("/etc/dc/");
|
||||
if (c) {
|
||||
fi.setFile(*c);
|
||||
if (fi.exists() == false) {
|
||||
qCritical() << "dc2c.bin candidate" << *c << "does not exist. STOP.";
|
||||
return -1;
|
||||
}
|
||||
qInfo() << "dc2c.bin canditate" << fi.absoluteFilePath();
|
||||
}
|
||||
}
|
||||
|
||||
qCritical() << "------------------------------------------------------";
|
||||
qCritical() << "main: argument dc-firmware: " << args.at(1);
|
||||
qCritical() << "------------------------------------------------------";
|
||||
|
||||
fi.setFile(args.at(1));
|
||||
|
||||
if (!fi.isFile()) {
|
||||
qCritical() << "ERROR: parameter " << fi.absoluteFilePath() << " is not a file";
|
||||
exit(1);
|
||||
if (debug) {
|
||||
qInfo() << "downloading dc-firmware" << fi.absoluteFilePath();
|
||||
qInfo() << "dc-firmware size (bytes)" << fi.size();
|
||||
qInfo() << "dc-version" << Update::dcVersion(fi.absoluteFilePath());
|
||||
}
|
||||
|
||||
if (!fi.isReadable()) {
|
||||
qCritical() << "ERROR: parameter " << fi.absoluteFilePath() << " is not readable";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
qCritical() << "------------------------------------------------------";
|
||||
qCritical() << "uploading dc-firmware" << fi.absoluteFilePath();
|
||||
qCritical() << "dc-firmware size (bytes)" << fi.size();
|
||||
qCritical() << "dc-version" << Update::dcVersion(fi.absoluteFilePath());
|
||||
qCritical() << "------------------------------------------------------";
|
||||
|
||||
Update u(fi.absoluteFilePath(), libca, debug, noaction);
|
||||
u.run();
|
||||
|
||||
|
||||
@@ -397,7 +397,9 @@ int Update::run() {
|
||||
qInfo() << "<DC-VERSION>" << Update::dcVersion(m_dcFileName);
|
||||
}
|
||||
|
||||
m_hw->dc_autoRequest(false);
|
||||
if (!m_debug) {
|
||||
m_hw->dc_autoRequest(false);
|
||||
}
|
||||
|
||||
qInfo() << "DC auto request OFF";
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
QT += core
|
||||
QT += serialport network
|
||||
|
||||
include(../common.pri)
|
||||
|
||||
TARGET = ATBDownloadDCJsonFiles
|
||||
|
||||
VERSION="0.1.0"
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
QT += core gui
|
||||
QT += widgets serialport network
|
||||
|
||||
include(../common.pri)
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
|
||||
TARGET = ATBUpdateTool
|
||||
@@ -150,8 +152,7 @@ DEFINES += QT_DEPRECATED_WARNINGS
|
||||
# 1.5.7 : Add support for dynamic portrait / landscape.
|
||||
# 1.5.8 : Use EVENT_ID=<pid of update-tool> for CMD_EVENT.
|
||||
# 1.5.9 : Removed restart of Apism if ISMAS unreachable.
|
||||
# 1,6,9 : Add separate tool ATBUpdateDC for manual updating DC-FW
|
||||
VERSION="1.6.0"
|
||||
VERSION="1.5.9"
|
||||
# PLANNED TODOS:
|
||||
# 1: Das Repository wird repariert bwz. neu geklont. Unabhaengig vom WAIT.
|
||||
# 2: Wenn der WAIT-Button aktiv ist, dann wird ein Repository repariert (neu
|
||||
|
||||
@@ -6,9 +6,7 @@
|
||||
#include <QFile>
|
||||
|
||||
CommandLineParser::CommandLineParser()
|
||||
: m_repositoryUrl("gitea@ptu-config.atb-comm.de:ATB/")
|
||||
, m_sshKeyFile("/opt/app/tools/atbupdate/.keys/id_ed25519_ptuConfig")
|
||||
, m_sshOptionStrictHostKeyChecking("false")
|
||||
: m_repositoryUrl("https://git.mimbach49.de/GerhardHoffmann")
|
||||
, m_plugInDir("/usr/lib/")
|
||||
, m_plugInName("libCAslave.so")
|
||||
, m_workingDir("/opt/app/tools/atbupdate/")
|
||||
@@ -22,36 +20,27 @@ CommandLineParser::CommandLineParser()
|
||||
, m_alwaysDownloadDC("false")
|
||||
, m_repositoryUrlOption(
|
||||
QCommandLineOption(
|
||||
QStringList() << "repository-url",
|
||||
QStringList() << "repository-url" << "repository-url",
|
||||
QCoreApplication::translate("main", "Where to find a customer repository."),
|
||||
QCoreApplication::translate("main", "directory")))
|
||||
, m_sshKeyFileOption(
|
||||
QCommandLineOption(
|
||||
QStringList() << "sshKeyFile",
|
||||
QCoreApplication::translate("main", "Used ssh key."),
|
||||
QCoreApplication::translate("main", "file")))
|
||||
, m_sshOptionStrictHostKeyCheckingOption(
|
||||
QCommandLineOption(
|
||||
QStringList() << "sshStrictHostKeyChecking",
|
||||
QCoreApplication::translate("main", "Enable ssh strict host key checking")))
|
||||
, m_iniFileDirectoryOption(
|
||||
QCommandLineOption(
|
||||
QStringList() << "ini-directory",
|
||||
QStringList() << "ini-directory" << "ini-directory",
|
||||
QCoreApplication::translate("main", "Where to find an ini-file."),
|
||||
QCoreApplication::translate("main", "directory")))
|
||||
, m_iniFileNameOption(
|
||||
QCommandLineOption(
|
||||
QStringList() << "ini-filename",
|
||||
QStringList() << "ini-filename" << "ini-filename",
|
||||
QCoreApplication::translate("main", "Name of ini-file."),
|
||||
QCoreApplication::translate("main", "file")))
|
||||
, m_pluginDirectoryOption(
|
||||
QCommandLineOption(
|
||||
QStringList() << "plugin-directory",
|
||||
QStringList() << "plugin-directory" << "plugin-directory",
|
||||
QCoreApplication::translate("main", "Where to find dc-plugin."),
|
||||
QCoreApplication::translate("main", "directory")))
|
||||
, m_pluginNameOption(
|
||||
QCommandLineOption(
|
||||
QStringList() << "plugin-name",
|
||||
QStringList() << "plugin-name" << "plugin-name",
|
||||
QCoreApplication::translate("main", "Name of dc-plugin."),
|
||||
QCoreApplication::translate("main", "directory")))
|
||||
, m_noDownloadOption(
|
||||
@@ -68,17 +57,17 @@ CommandLineParser::CommandLineParser()
|
||||
QCoreApplication::translate("main", "Always download the dc-bin-file to DC).")))
|
||||
, m_workingDirectoryOption(
|
||||
QCommandLineOption(
|
||||
QStringList() << "working-directory",
|
||||
QStringList() << "working-directory" << "working-directory",
|
||||
QCoreApplication::translate("main", "working directory of update-script."),
|
||||
QCoreApplication::translate("main", "directory")))
|
||||
, m_psaConfigDirectoryOption(
|
||||
QCommandLineOption(
|
||||
QStringList() << "psa-config-directory",
|
||||
QStringList() << "psa-config-directory" << "psa-config-directory",
|
||||
QCoreApplication::translate("main", "config directory of json-files sent to dc."),
|
||||
QCoreApplication::translate("main", "directory")))
|
||||
, m_psaTariffDirectoryOption(
|
||||
QCommandLineOption(
|
||||
QStringList() << "psa-tariff-directory",
|
||||
QStringList() << "psa-tariff-directory" << "psa-tariff-directory",
|
||||
QCoreApplication::translate("main", "tariff directory of tariff-json-files."),
|
||||
QCoreApplication::translate("main", "directory")))
|
||||
, m_dryRunOption(
|
||||
@@ -105,8 +94,8 @@ CommandLineParser::CommandLineParser()
|
||||
, m_readDCVersionOption(
|
||||
QCommandLineOption(
|
||||
QStringList() << "D" << "read-dc-version",
|
||||
QCoreApplication::translate("main", "Show version of device controller.")))
|
||||
{
|
||||
QCoreApplication::translate("main", "Show version of device controller."),
|
||||
QCoreApplication::translate("main", "Show version of device controller."))) {
|
||||
configure();
|
||||
}
|
||||
|
||||
@@ -115,15 +104,9 @@ void CommandLineParser::configure() {
|
||||
m_parser.addHelpOption();
|
||||
m_parser.addVersionOption();
|
||||
|
||||
m_repositoryUrlOption.setDefaultValue("gitea@ptu-config.atb-comm.de:ATB/");
|
||||
m_repositoryUrlOption.setDefaultValue("https://git.mimbach49.de/GerhardHoffmann");
|
||||
m_parser.addOption(m_repositoryUrlOption);
|
||||
|
||||
m_sshKeyFileOption.setDefaultValue("/opt/app/tools/atbupdate/.keys/id_ed25519_ptuConfig");
|
||||
m_parser.addOption(m_sshKeyFileOption);
|
||||
|
||||
m_sshOptionStrictHostKeyCheckingOption.setDefaultValue("");
|
||||
m_parser.addOption(m_sshOptionStrictHostKeyCheckingOption);
|
||||
|
||||
m_iniFileDirectoryOption.setDefaultValue(QCoreApplication::applicationDirPath());
|
||||
m_parser.addOption(m_iniFileDirectoryOption);
|
||||
|
||||
@@ -194,12 +177,6 @@ void CommandLineParser::readSettings() {
|
||||
if (key.contains("repository-url")) {
|
||||
m_repositoryUrl = v.toString();
|
||||
} else
|
||||
if (key.contains("sshKeyFile")) {
|
||||
m_sshKeyFile = v.toString();
|
||||
} else
|
||||
if (key.contains("sshOptionStrictHostKeyChecking")) {
|
||||
m_sshOptionStrictHostKeyChecking = (v.toBool() ? "true" : "false");
|
||||
} else
|
||||
if (key.contains("plugin-directory")) {
|
||||
m_plugInDir = v.toString();
|
||||
} else
|
||||
@@ -260,21 +237,6 @@ QString CommandLineParser::repositoryUrl() {
|
||||
return m_repositoryUrl;
|
||||
}
|
||||
|
||||
QString CommandLineParser::sshKeyFile() {
|
||||
if (m_parser.isSet(m_sshKeyFileOption)) {
|
||||
m_sshKeyFile = m_parser.value(m_sshKeyFileOption);
|
||||
}
|
||||
return m_sshKeyFile;
|
||||
}
|
||||
|
||||
bool CommandLineParser::sshOptionStrictHostKeyChecking()
|
||||
{
|
||||
if (m_parser.isSet(m_sshOptionStrictHostKeyCheckingOption)) {
|
||||
m_sshOptionStrictHostKeyChecking = m_parser.value(m_sshOptionStrictHostKeyCheckingOption);
|
||||
}
|
||||
return m_sshOptionStrictHostKeyChecking == "false" ? false : true;
|
||||
}
|
||||
|
||||
QString CommandLineParser::plugInDir() {
|
||||
if (m_parser.isSet(m_pluginDirectoryOption)) {
|
||||
m_plugInDir = m_parser.value(m_pluginDirectoryOption);
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
|
||||
class CommandLineParser : public QCommandLineParser {
|
||||
QString m_repositoryUrl;
|
||||
QString m_sshKeyFile;
|
||||
QString m_sshOptionStrictHostKeyChecking;
|
||||
QString m_plugInDir;
|
||||
QString m_plugInName;
|
||||
QString m_workingDir;
|
||||
@@ -27,8 +25,6 @@ class CommandLineParser : public QCommandLineParser {
|
||||
QString m_dcDir{"etc/dc/"};
|
||||
|
||||
QCommandLineOption m_repositoryUrlOption;
|
||||
QCommandLineOption m_sshKeyFileOption;
|
||||
QCommandLineOption m_sshOptionStrictHostKeyCheckingOption;
|
||||
QCommandLineOption m_iniFileDirectoryOption;
|
||||
QCommandLineOption m_iniFileNameOption;
|
||||
QCommandLineOption m_pluginDirectoryOption;
|
||||
@@ -61,8 +57,6 @@ public:
|
||||
QString const &iniFileName() const { return m_iniFileName; }
|
||||
void readSettings();
|
||||
QString repositoryUrl();
|
||||
QString sshKeyFile();
|
||||
bool sshOptionStrictHostKeyChecking();
|
||||
QString plugInDir();
|
||||
QString plugInName();
|
||||
QString workingDir();
|
||||
|
||||
@@ -400,12 +400,6 @@ std::optional<QString> GitClient::gitPull() {
|
||||
If remote host keys are changed, then
|
||||
|
||||
export GIT_SSH_COMMAND="ssh -i /opt/app/tools/atbupdate/.keys/id_ed25519_ptuConfig"
|
||||
|
||||
... or ignore host key checking:
|
||||
export GIT_SSH_COMMAND="ssh -i /opt/app/tools/atbupdate/.keys/id_ed25519_ptuConfig -o StrictHostKeyChecking=no"
|
||||
|
||||
... or use separate known_hosts file:
|
||||
export GIT_SSH_COMMAND="ssh -i /mypath/.keys/id_ed25519 -o StrictHostKeyChecking=yes -o UserKnownHostsFile=/opt/app/tools/atbupdate/.keys/known_hosts"
|
||||
git pull
|
||||
|
||||
leads to the following warning/error message:
|
||||
|
||||
+21
-24
@@ -72,43 +72,39 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
CommandLineParser parser;
|
||||
parser.process(a);
|
||||
|
||||
if (parser.isSet(parser.addHelpOption())) {
|
||||
parser.showHelp(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
parser.readSettings();
|
||||
|
||||
QString repositoryUrl = parser.repositoryUrl();
|
||||
QString sshKeyFile = parser.sshKeyFile();
|
||||
bool strictHostKeyChecking = parser.sshOptionStrictHostKeyChecking();
|
||||
|
||||
if (repositoryUrl.endsWith('/')) {
|
||||
repositoryUrl.chop(1);
|
||||
}
|
||||
|
||||
// default for gitSSHCommand
|
||||
QString gitSSHCommand = "ssh -i " + sshKeyFile;
|
||||
QString gitSSHCommand("");
|
||||
|
||||
strictHostKeyChecking ? gitSSHCommand.append(" -o StrictHostKeyChecking=yes")
|
||||
: gitSSHCommand.append(" -o StrictHostKeyChecking=no");
|
||||
|
||||
QByteArray const v = qgetenv("GIT_SSH_COMMAND");
|
||||
if (v.isEmpty()) {
|
||||
if (QFileInfo(sshKeyFile).exists()) {
|
||||
if (!qputenv("GIT_SSH_COMMAND", QByteArray(gitSSHCommand.toStdString().c_str()))) {
|
||||
qCritical() << "ERROR: GIT_SSH_COMMAND not put into env. Exiting...";
|
||||
if (repositoryUrl.contains("ptu-config.atb-comm.de")) {
|
||||
QByteArray const v = qgetenv("GIT_SSH_COMMAND");
|
||||
if (v.isEmpty()) {
|
||||
QString sshKeyFile("/opt/app/tools/atbupdate/.keys/id_ed25519_ptuConfig");
|
||||
if (QFileInfo(sshKeyFile).exists()) {
|
||||
gitSSHCommand = "ssh -i /opt/app/tools/atbupdate/.keys/id_ed25519_ptuConfig";
|
||||
if (!qputenv("GIT_SSH_COMMAND", QByteArray(gitSSHCommand.toStdString().c_str()))) {
|
||||
qCritical() << "ERROR: GIT_SSH_COMMAND not put into env. Exiting...";
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
qCritical() << "ERROR ssh-key-file" << sshKeyFile << "does not exists. Exiting...";
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
qCritical() << "ERROR ssh-key-file" << sshKeyFile << "does not exists. Exiting...";
|
||||
return -1;
|
||||
gitSSHCommand = QString(v.toStdString().c_str());
|
||||
qCritical() << "WARNING GIT_SSH_COMMAND already set in enviroment:"
|
||||
<< gitSSHCommand;
|
||||
if (gitSSHCommand != "ssh -i /opt/app/tools/atbupdate/.keys/id_ed25519_ptuConfig") {
|
||||
qCritical() << "ERROR" << gitSSHCommand << "wrong. Exiting...";
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
gitSSHCommand = QString(v.toStdString().c_str());
|
||||
qCritical() << "WARNING GIT_SSH_COMMAND already set in enviroment:"
|
||||
<< gitSSHCommand;
|
||||
}
|
||||
|
||||
QString plugInDir = parser.plugInDir();
|
||||
@@ -165,6 +161,7 @@ int main(int argc, char *argv[]) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
QThread::currentThread()->setObjectName("main thread");
|
||||
qInfo() << "Main thread" << QThread::currentThreadId();
|
||||
|
||||
|
||||
@@ -120,156 +120,84 @@ bool Command::start(QString workingDirectory, QStringList args) {
|
||||
return m_p->waitForStarted(m_waitForStartTimeout);
|
||||
}
|
||||
|
||||
bool Command::execute(QString workingDirectory, QStringList args)
|
||||
{
|
||||
bool Command::execute(QString workingDirectory, QStringList args) {
|
||||
|
||||
if (!QDir::setCurrent(workingDirectory)) {
|
||||
qCritical() << "SET WORKING_DIRECTORY"
|
||||
<< workingDirectory
|
||||
<< "FAILED FOR"
|
||||
<< m_command;
|
||||
qCritical() << "SET WORKING_DIRECTORY" << workingDirectory
|
||||
<< "FAILED FOR" << m_command;
|
||||
return false;
|
||||
}
|
||||
|
||||
QScopedPointer<QProcess> p(new QProcess(this));
|
||||
|
||||
p->setWorkingDirectory(workingDirectory);
|
||||
p->setProcessChannelMode(QProcess::MergedChannels);
|
||||
|
||||
connect(p.data(),
|
||||
SIGNAL(readyReadStandardOutput()),
|
||||
this,
|
||||
SLOT(readyReadStandardOutput()));
|
||||
|
||||
connect(p.data(),
|
||||
SIGNAL(readyReadStandardError()),
|
||||
this,
|
||||
SLOT(readyReadStandardError()));
|
||||
connect(&(*p), SIGNAL(readyReadStandardOutput()), this, SLOT(readyReadStandardOutput()));
|
||||
connect(&(*p), SIGNAL(readyReadStandardError()), this, SLOT(readyReadStandardError()));
|
||||
|
||||
if (!args.isEmpty()) {
|
||||
//qDebug() << "START COMMAND" << m_command << "WITH ARGS" << args
|
||||
// << "IN" << p->workingDirectory();
|
||||
p->start(m_command, args);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
//qDebug() << "START COMMAND" << m_command
|
||||
// << "IN" << p->workingDirectory();
|
||||
p->start(m_command);
|
||||
}
|
||||
|
||||
const qint64 start =
|
||||
QDateTime::currentDateTime().toMSecsSinceEpoch();
|
||||
qint64 const start = QDateTime::currentDateTime().toMSecsSinceEpoch();
|
||||
|
||||
if (!p->waitForStarted(m_waitForStartTimeout)) {
|
||||
|
||||
const qint64 end =
|
||||
QDateTime::currentDateTime().toMSecsSinceEpoch();
|
||||
|
||||
qCritical() << "PROCESS"
|
||||
<< m_command
|
||||
<< "TIMEOUT AT START"
|
||||
<< QString("(runtime %1ms)").arg(end - start)
|
||||
<< "IN"
|
||||
<< p->workingDirectory();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (p->state() != QProcess::Running) {
|
||||
|
||||
qCritical() << "WRONG PROCESS STATE"
|
||||
<< p->state()
|
||||
<< "IN"
|
||||
<< p->workingDirectory();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int wait = m_waitForFinishTimeout;
|
||||
|
||||
if (m_command.trimmed().startsWith("git", Qt::CaseInsensitive) ||
|
||||
m_command.trimmed().startsWith("opkg", Qt::CaseInsensitive)) {
|
||||
|
||||
wait = 30 * 60 * 1000;
|
||||
}
|
||||
|
||||
// IMPORTANT: waitForFinished() is called exactly once.
|
||||
const bool finished = p->waitForFinished(wait);
|
||||
|
||||
if (!finished) {
|
||||
|
||||
const qint64 end =
|
||||
QDateTime::currentDateTime().toMSecsSinceEpoch();
|
||||
|
||||
qCritical() << "PROCESS WAIT FAILED:"
|
||||
<< m_command
|
||||
<< "timeout =" << wait
|
||||
<< "runtime =" << (end - start)
|
||||
<< "error =" << p->error()
|
||||
<< "errorString =" << p->errorString()
|
||||
<< "state =" << p->state();
|
||||
|
||||
if (p->state() != QProcess::NotRunning) {
|
||||
|
||||
p->terminate();
|
||||
|
||||
if (!p->waitForFinished(5000)) {
|
||||
|
||||
qCritical()
|
||||
<< "Process did not terminate, killing:"
|
||||
<< m_command;
|
||||
|
||||
p->kill();
|
||||
|
||||
if (!p->waitForFinished(5000)) {
|
||||
qCritical()
|
||||
<< "ERROR: Process still did not finish after kill:"
|
||||
<< m_command;
|
||||
}
|
||||
if (p->waitForStarted(m_waitForStartTimeout)) {
|
||||
// qDebug() << "PROCESS" << m_command << "STARTED IN" << p->workingDirectory();
|
||||
if (p->state() == QProcess::ProcessState::Running) {
|
||||
// qDebug() << "PROCESS" << m_command << "RUNNING IN" << p->workingDirectory();
|
||||
// wait forever for git/opkg-commands to finish
|
||||
int wait = m_waitForFinishTimeout;
|
||||
if (m_command.trimmed().startsWith("git", Qt::CaseInsensitive) ||
|
||||
m_command.trimmed().startsWith("opkg", Qt::CaseInsensitive)) {
|
||||
wait = -1;
|
||||
}
|
||||
bool const no_timeout = p->waitForFinished(wait);
|
||||
if (no_timeout) {
|
||||
// qDebug() << "PROCESS" << m_command << "FINISHED IN" << p->workingDirectory();
|
||||
if (p->exitStatus() == QProcess::NormalExit) {
|
||||
if ((m_exitCode = p->exitCode()) == 0) {
|
||||
qint64 const end = QDateTime::currentDateTime().toMSecsSinceEpoch();
|
||||
qDebug() << "EXECUTED" << m_command
|
||||
<< QString("(runtime %1ms)").arg(end-start)
|
||||
<< "with code" << m_exitCode
|
||||
<< "IN" << p->workingDirectory();
|
||||
return true;
|
||||
} else {
|
||||
qint64 const end = QDateTime::currentDateTime().toMSecsSinceEpoch();
|
||||
qCritical() << "EXECUTED" << m_command
|
||||
<< QString("(runtime %1ms)").arg(end-start)
|
||||
<< "with code" << m_exitCode
|
||||
<< "IN" << p->workingDirectory();
|
||||
}
|
||||
} else {
|
||||
qint64 const end = QDateTime::currentDateTime().toMSecsSinceEpoch();
|
||||
qCritical() << "PROCESS" << m_command << "CRASHED with code"
|
||||
<< p->exitCode()
|
||||
<< QString("(after %1ms)").arg(end-start)
|
||||
<< "IN" << p->workingDirectory();
|
||||
}
|
||||
} else {
|
||||
qint64 const end = QDateTime::currentDateTime().toMSecsSinceEpoch();
|
||||
qCritical() << "PROCESS" << m_command
|
||||
<< "DID NOT FINISH WITH" << wait
|
||||
<< "MS IN" << p->workingDirectory()
|
||||
<< QString("(runtime %1ms)").arg(end-start);
|
||||
}
|
||||
} else {
|
||||
qCritical() << "WRONG PROCESS STATE" << p->state()
|
||||
<< "IN" << p->workingDirectory();
|
||||
}
|
||||
|
||||
m_exitCode = -1;
|
||||
return false;
|
||||
} else {
|
||||
qint64 const end = QDateTime::currentDateTime().toMSecsSinceEpoch();
|
||||
qCritical() << "PROCESS" << m_command << "TIMEOUT AT START"
|
||||
<< QString("(runtime %1ms)").arg(end-start)
|
||||
<< "IN" << p->workingDirectory();
|
||||
}
|
||||
|
||||
// From here onward the process has definitely finished.
|
||||
|
||||
const qint64 end =
|
||||
QDateTime::currentDateTime().toMSecsSinceEpoch();
|
||||
|
||||
if (p->exitStatus() != QProcess::NormalExit) {
|
||||
|
||||
m_exitCode = p->exitCode();
|
||||
|
||||
qCritical() << "PROCESS"
|
||||
<< m_command
|
||||
<< "CRASHED with code"
|
||||
<< m_exitCode
|
||||
<< QString("(after %1ms)").arg(end - start)
|
||||
<< "IN"
|
||||
<< p->workingDirectory();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
m_exitCode = p->exitCode();
|
||||
|
||||
if (m_exitCode != 0) {
|
||||
|
||||
qCritical() << "EXECUTED"
|
||||
<< m_command
|
||||
<< QString("(runtime %1ms)").arg(end - start)
|
||||
<< "with code"
|
||||
<< m_exitCode
|
||||
<< "IN"
|
||||
<< p->workingDirectory();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
qDebug() << "EXECUTED"
|
||||
<< m_command
|
||||
<< QString("(runtime %1ms)").arg(end - start)
|
||||
<< "with code"
|
||||
<< m_exitCode
|
||||
<< "IN"
|
||||
<< p->workingDirectory();
|
||||
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -22,11 +22,9 @@ class Command : public QObject {
|
||||
QProcess *m_p;
|
||||
Worker *m_worker;
|
||||
public:
|
||||
static constexpr int COMMAND_START_TIMEOUT_MS = 30 * 1000;
|
||||
static constexpr int COMMAND_FINISH_TIMEOUT_MS = 30 * 60 * 1000;
|
||||
explicit Command(QString const &command,
|
||||
int start_timeout = COMMAND_START_TIMEOUT_MS,
|
||||
int finish_timeout = COMMAND_FINISH_TIMEOUT_MS);
|
||||
int start_timeout = 100000,
|
||||
int finish_timeout = 100000);
|
||||
|
||||
QString getCommandResult(bool reset = false) const;
|
||||
QString command() const { return m_command; }
|
||||
|
||||
@@ -40,6 +40,7 @@ QPluginLoader Update::pluginLoader;
|
||||
|
||||
hwinf *Update::loadDCPlugin(QDir const &plugInDir, QString const &fname) {
|
||||
hwinf *hw = nullptr;
|
||||
#if 0
|
||||
if (plugInDir.exists()) {
|
||||
QString pluginLibName(fname);
|
||||
pluginLibName = plugInDir.absoluteFilePath(pluginLibName);
|
||||
@@ -74,6 +75,7 @@ hwinf *Update::loadDCPlugin(QDir const &plugInDir, QString const &fname) {
|
||||
qCritical() << "plugins directory" << plugInDir.absolutePath()
|
||||
<< "does not exist";
|
||||
}
|
||||
#endif
|
||||
return hw;
|
||||
}
|
||||
|
||||
@@ -117,6 +119,7 @@ Update::Update(Worker *worker,
|
||||
, m_dryRun(dryRun)
|
||||
, m_sys_areDCdataValid(false) {
|
||||
|
||||
#if 0
|
||||
if (!m_hw) {
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") m_hw == nullptr -> ca-slave plugin not loaded";
|
||||
} else {
|
||||
@@ -134,6 +137,7 @@ Update::Update(Worker *worker,
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") m_sys_areDCDataValid ..."
|
||||
<< m_sys_areDCdataValid;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
Update::~Update() {
|
||||
@@ -606,6 +610,8 @@ QString Update::getFileVersion(QString const& jsonFileName) {
|
||||
}
|
||||
|
||||
bool Update::checkDownloadedJsonVersions(QStringList const& jsonFileNames) {
|
||||
// note: 2026-02-09: this method is not used!
|
||||
#if 0
|
||||
|
||||
for (QStringList::size_type i=0; i < jsonFileNames.size(); ++i) {
|
||||
|
||||
@@ -679,14 +685,14 @@ bool Update::checkDownloadedJsonVersions(QStringList const& jsonFileNames) {
|
||||
qCritical() << "CANNOT FIND JSON-NR FOR" << fName;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
QMap<QString, QString>
|
||||
Update::getInstalledJsonVersions(QStringList const& jsonFileNames) {
|
||||
QMap<QString, QString> map;
|
||||
|
||||
#if 0
|
||||
if (!m_hw) {
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << "):"
|
||||
<< "ERROR!!! m_hw == nullptr";
|
||||
@@ -786,6 +792,7 @@ Update::getInstalledJsonVersions(QStringList const& jsonFileNames) {
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
@@ -178,9 +178,6 @@ QString Utils::zoneName(quint8 i) {
|
||||
//if (i < (sizeof(zName)/sizeof(char const *))) {
|
||||
// return zName[i];
|
||||
//}
|
||||
|
||||
Q_UNUSED(i)
|
||||
|
||||
return "---";
|
||||
}
|
||||
|
||||
|
||||
+14
-72
@@ -284,43 +284,14 @@ bool Worker::repairCorruptedRepository() {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Worker::updateTimedOut() const
|
||||
{
|
||||
if (!m_updateRuntime.isValid())
|
||||
return false;
|
||||
|
||||
if (m_updateRuntime.elapsed() < UPDATE_MAX_RUNTIME_MS)
|
||||
return false;
|
||||
|
||||
qCritical() << "UPDATE TOOL GLOBAL TIMEOUT:"
|
||||
<< m_updateRuntime.elapsed()
|
||||
<< "ms";
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Worker::privateUpdate() {
|
||||
m_updateRuntime.start();
|
||||
|
||||
auto abortIfTimedOut = [this]() -> bool {
|
||||
if (!updateTimedOut())
|
||||
return false;
|
||||
|
||||
qCritical() << "UPDATE TOOL GLOBAL TIMEOUT - aborting update";
|
||||
|
||||
// Ideally use a dedicated timeout step later.
|
||||
m_lastFailedUpdateStep = UPDATE_STEP::UPDATE_FINALIZE;
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
if (!m_mainWindow) {
|
||||
Utils::printCriticalErrorMsg("m_mainWindow NOT SET");
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
QString func(__PRETTY_FUNCTION__);
|
||||
|
||||
GUI() << (ISMAS() << (CONSOLE() << UPDATE_STEP::STARTED));
|
||||
@@ -382,9 +353,6 @@ void Worker::privateUpdate() {
|
||||
// update procedure, even if ISMAS-trigger is not correctly set ("WAIT")
|
||||
}
|
||||
|
||||
if (abortIfTimedOut())
|
||||
return;
|
||||
|
||||
emit this->disableExit();
|
||||
|
||||
QDir customerRepository(m_customerRepository);
|
||||
@@ -468,9 +436,6 @@ void Worker::privateUpdate() {
|
||||
CONSOLE() << UPDATE_STEP::CHECK_REPOSITORY_SUCCESS;
|
||||
setProgress(_CHECKOUT_REPOSITORY_SUCCESS);
|
||||
|
||||
if (abortIfTimedOut())
|
||||
return;
|
||||
|
||||
if (m_clone == false) {
|
||||
if (m_ismasTriggerActive == false) {
|
||||
return;
|
||||
@@ -499,9 +464,6 @@ void Worker::privateUpdate() {
|
||||
// CHECK-OUT BRANCH
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
if (abortIfTimedOut())
|
||||
return;
|
||||
|
||||
if ((continueUpdate = customerEnvironment()) == false) {
|
||||
// even if something goes wrong creating the environment, try to execute
|
||||
// opkg_commands
|
||||
@@ -524,8 +486,6 @@ void Worker::privateUpdate() {
|
||||
// COMPUTE CHANGED FILES OF CUSTOMER REPOSITORY
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
if (abortIfTimedOut())
|
||||
return;
|
||||
if ((continueUpdate = filesToUpdate()) == false) {
|
||||
// even if something goes wrong in filesToUpdate, try to execute
|
||||
// opkg_commands
|
||||
@@ -547,9 +507,6 @@ void Worker::privateUpdate() {
|
||||
// (R)SYNC THE REPOSITORY WITH THE LOCAL FILEYSTEM
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
if (abortIfTimedOut())
|
||||
return;
|
||||
|
||||
if ((continueUpdate = syncCustomerRepositoryAndFS()) == false) {
|
||||
// even if something goes wrong with rsync, try to execute
|
||||
// opkg_commands
|
||||
@@ -571,9 +528,6 @@ void Worker::privateUpdate() {
|
||||
// EXECUTE OPKG COMMANDS
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
if (abortIfTimedOut())
|
||||
return;
|
||||
|
||||
if ((continueUpdate = execOpkgCommands()) == false) {
|
||||
return;
|
||||
}
|
||||
@@ -581,18 +535,16 @@ void Worker::privateUpdate() {
|
||||
GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::EXEC_OPKG_COMMANDS);
|
||||
setProgress(_EXEC_OPKG_COMMAND_SUCCESS);
|
||||
|
||||
if (abortIfTimedOut())
|
||||
return;
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// UPDATE THE PSA USING THE CHANGED FILES
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
if ((continueUpdate = downloadFilesToPSAHardware()) == false) {
|
||||
return;
|
||||
}
|
||||
// for 281/Szeged: skip uploading files to DeviceController
|
||||
//if ((continueUpdate = downloadFilesToPSAHardware()) == false) {
|
||||
// return;
|
||||
//}
|
||||
lst = QStringList(QString("DONE"));
|
||||
ISMAS(lst) << (GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE_SUCCESS));
|
||||
|
||||
@@ -1346,28 +1298,18 @@ qint64 Worker::getFileSize(QString const &fileName) const {
|
||||
return fInfo.exists() ? fInfo.size() : -1;
|
||||
}
|
||||
|
||||
static constexpr int OPKG_START_TIMEOUT_MS = 30 * 1000;
|
||||
static constexpr int OPKG_FINISH_TIMEOUT_MS = 30 * 60 * 1000;
|
||||
|
||||
bool Worker::executeOpkgCommand(QString opkgCommand) {
|
||||
Command c(opkgCommand,
|
||||
OPKG_START_TIMEOUT_MS,
|
||||
OPKG_FINISH_TIMEOUT_MS);
|
||||
|
||||
Command c(opkgCommand);
|
||||
if (c.execute(m_workingDirectory)) {
|
||||
Utils::printInfoMsg(
|
||||
QString("EXECUTE OPKG COMMAND %1 OK: %2")
|
||||
.arg(opkgCommand)
|
||||
.arg(c.getCommandResult()));
|
||||
|
||||
QString const r = c.getCommandResult();
|
||||
Utils::printInfoMsg(QString("EXECUTE OPKG COMMAND %1 OK: %2")
|
||||
.arg(opkgCommand)
|
||||
.arg(c.getCommandResult()));
|
||||
return true;
|
||||
} else {
|
||||
Utils::printCriticalErrorMsg(QString("EXECUTE OPKG COMMAND %1 FAILED")
|
||||
.arg(opkgCommand));
|
||||
}
|
||||
|
||||
Utils::printCriticalErrorMsg(
|
||||
QString("EXECUTE OPKG COMMAND %1 FAILED/TIMED OUT: %2")
|
||||
.arg(opkgCommand)
|
||||
.arg(c.getCommandResult()));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
#include <QMap>
|
||||
#include <QDebug>
|
||||
#include <QThread>
|
||||
#include <QElapsedTimer>
|
||||
|
||||
#include <optional>
|
||||
#include <initializer_list>
|
||||
@@ -20,7 +19,6 @@
|
||||
#include "ismas/ismas_client.h"
|
||||
#include "utils.h"
|
||||
|
||||
|
||||
#ifdef PTU5
|
||||
#define SERIAL_PORT "ttymxc2"
|
||||
#else
|
||||
@@ -143,14 +141,6 @@ class hwinf;
|
||||
class Worker : public QThread{
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
static constexpr qint64 UPDATE_MAX_RUNTIME_MS =
|
||||
60LL * 60LL * 1000LL; // 60 minutes
|
||||
|
||||
QElapsedTimer m_updateRuntime;
|
||||
|
||||
public:
|
||||
bool updateTimedOut() const;
|
||||
int const m_customerNr;
|
||||
QString const m_customerNrStr;
|
||||
int const m_machineNr;
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
INCLUDEPATH += $$PWD/common/include
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user