Compare commits
6 Commits
259da8200e
...
0f2ee0349f
Author | SHA1 | Date | |
---|---|---|---|
0f2ee0349f | |||
e700a40875 | |||
1eba5338e4 | |||
f20be9ddcf | |||
7631c05e22 | |||
ad93e536f0 |
@ -114,6 +114,47 @@ bool GitClient::gitCloneAndCheckoutBranch() {
|
||||
return false;
|
||||
}
|
||||
|
||||
QStringList GitClient::gitShowReason() {
|
||||
QStringList lst;
|
||||
if (QDir(m_customerRepository).exists()) {
|
||||
// %h: commit (short form)
|
||||
// %s: commit message
|
||||
// %cI: commit date, strict ISO 8601 format
|
||||
Command c("git show -s --format=\"c=%h m=%s d=%cI\"");
|
||||
if (c.execute(m_customerRepository)) {
|
||||
QString const s = c.getCommandResult().trimmed();
|
||||
int const c = s.indexOf("c=");
|
||||
int const m = s.indexOf("m=");
|
||||
int const d = s.indexOf("d=");
|
||||
QString commit{""}, msg{""}, date{""};
|
||||
if (c != -1) {
|
||||
int start = c + 2;
|
||||
if (m >= start) {
|
||||
int length = m - start;
|
||||
commit = s.mid(start, length).trimmed();
|
||||
|
||||
start = m + 2;
|
||||
if (d >= start) {
|
||||
length = d - start;
|
||||
msg = s.mid(start, length).trimmed();
|
||||
|
||||
start = d + 2;
|
||||
date = s.mid(start);
|
||||
}
|
||||
}
|
||||
|
||||
if (!commit.isEmpty() && !msg.isEmpty() && !date.isEmpty()) {
|
||||
lst << commit << msg << date;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
qCritical() << "CUSTOMER_REPOSITORY" << m_customerRepository
|
||||
<< "DOES NOT EXIST";
|
||||
}
|
||||
return lst;
|
||||
}
|
||||
|
||||
/*
|
||||
Zu beachten: wird eine datei neu hinzugefuegt (git add/commit) dann aber gleich
|
||||
wieder geloscht, so wird sie im diff nicht angezeigt.
|
||||
|
@ -50,6 +50,7 @@ class GitClient : public QObject {
|
||||
std::optional<QStringList> gitMerge();
|
||||
|
||||
QString gitLastCommit(QString fileName);
|
||||
QStringList gitShowReason();
|
||||
QString gitBlob(QString fileName);
|
||||
QString gitCommitForBlob(QString blob);
|
||||
bool gitIsFileTracked(QString file2name);
|
||||
|
@ -231,6 +231,8 @@ IsmasClient::sendRequestReceiveResponse(int port, QString const &request) {
|
||||
tv.tv_sec = 60; /* 60 secs timeout for read and write */
|
||||
tv.tv_usec = 0;
|
||||
|
||||
QString const selectStart = QDateTime::currentDateTime().toString(Qt::ISODateWithMs);
|
||||
|
||||
int const r = select(maxfdp1, &rset, NULL, NULL, &tv);
|
||||
if (r < 0) { // error
|
||||
if (errno == EINTR) {
|
||||
@ -264,7 +266,8 @@ IsmasClient::sendRequestReceiveResponse(int port, QString const &request) {
|
||||
if (n == 0) {
|
||||
// The return value will be 0 when the peer has performed an orderly shutdown.
|
||||
printErrorMessage(port, clientIP, clientPort,
|
||||
QString("PEER CLOSED CONNECTION (") + strerror(errno) + ")");
|
||||
QString("PEER CLOSED CONNECTION (") + strerror(errno) + ") START AT" +
|
||||
selectStart + " NOW " + QDateTime::currentDateTime().toString(Qt::ISODateWithMs));
|
||||
::close(sockfd);
|
||||
return std::nullopt;
|
||||
} else
|
||||
@ -415,13 +418,11 @@ QString IsmasClient::updateOfPSASendVersion(PSAInstalled const &psa) {
|
||||
static char buf[4096*2];
|
||||
memset(buf, 0, sizeof(buf));
|
||||
|
||||
QString const ts = QDateTime::currentDateTime().toString(Qt::ISODateWithMs);
|
||||
QString sendVersionHash = "N/A";
|
||||
|
||||
// local data="#M=APISM#C=CMD_SENDVERSION#J=
|
||||
snprintf(buf, sizeof(buf)-1,
|
||||
"{"
|
||||
"\"VERSION_INFO\" : {"
|
||||
"\"REASON\":\"%s\","
|
||||
"\"CREATED\":\"%s\","
|
||||
"\"HASH\":\"%s\""
|
||||
"},"
|
||||
@ -629,8 +630,9 @@ QString IsmasClient::updateOfPSASendVersion(PSAInstalled const &psa) {
|
||||
"}"
|
||||
"}"
|
||||
"}",
|
||||
ts.toStdString().c_str(),
|
||||
sendVersionHash.toStdString().c_str(),
|
||||
psa.versionInfo.reason.toStdString().c_str(),
|
||||
psa.versionInfo.created.toStdString().c_str(),
|
||||
psa.versionInfo.lastCommit.toStdString().c_str(),
|
||||
|
||||
psa.tariff.version.toStdString().c_str(),
|
||||
psa.tariff.project.toStdString().c_str(),
|
||||
|
@ -7,6 +7,12 @@
|
||||
#include <optional>
|
||||
|
||||
struct PSAInstalled {
|
||||
struct VersionInfo {
|
||||
QString created;
|
||||
QString reason;
|
||||
QString lastCommit;
|
||||
} versionInfo;
|
||||
|
||||
struct Tariff {
|
||||
QString name;
|
||||
QString version;
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
#include <QProcess>
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QRegularExpression>
|
||||
|
||||
Command::Command(QString const &command, int start_timeout, int finish_timeout)
|
||||
@ -40,46 +41,64 @@ void Command::finished(int /*exitCode*/, QProcess::ExitStatus /*exitStatus*/) {
|
||||
}
|
||||
|
||||
bool Command::execute(QString workingDirectory, QStringList args) {
|
||||
|
||||
if (!QDir::setCurrent(workingDirectory)) {
|
||||
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), SIGNAL(readyReadStandardOutput()), this, SLOT(readyReadStandardOutput()));
|
||||
connect(&(*p), SIGNAL(readyReadStandardError()), this, SLOT(readyReadStandardError()));
|
||||
|
||||
//qCritical() << "START COMMAND" << m_command << "WITH ARGS" << args
|
||||
// << "IN" << workingDirectory;
|
||||
|
||||
p->setWorkingDirectory(workingDirectory);
|
||||
if (!args.isEmpty()) {
|
||||
qDebug() << "START COMMAND" << m_command << "WITH ARGS" << args
|
||||
<< "IN" << p->workingDirectory();
|
||||
p->start(m_command, args);
|
||||
} else {
|
||||
qDebug() << "START COMMAND" << m_command
|
||||
<< "IN" << p->workingDirectory();
|
||||
p->start(m_command);
|
||||
}
|
||||
|
||||
if (p->waitForStarted(m_waitForStartTimeout)) {
|
||||
//qDebug() << "PROCESS" << m_command << "STARTED";
|
||||
qDebug() << "PROCESS" << m_command << "STARTED IN" << p->workingDirectory();
|
||||
if (p->state() == QProcess::ProcessState::Running) {
|
||||
//qDebug() << "PROCESS" << m_command << "RUNNING";
|
||||
qDebug() << "PROCESS" << m_command << "RUNNING IN" << p->workingDirectory();
|
||||
if (p->waitForFinished(m_waitForFinishTimeout)) {
|
||||
//qDebug() << "PROCESS" << m_command << "FINISHED";
|
||||
qDebug() << "PROCESS" << m_command << "FINISHED IN" << p->workingDirectory();
|
||||
if (p->exitStatus() == QProcess::NormalExit) {
|
||||
if ((m_exitCode = p->exitCode()) == 0) {
|
||||
qDebug() << "EXECUTED" << m_command
|
||||
<< "with code" << m_exitCode
|
||||
<< "IN" << p->workingDirectory();
|
||||
return true;
|
||||
} else {
|
||||
qCritical() << "EXECUTED" << m_command << "with code" << p->exitCode();
|
||||
qCritical() << "EXECUTED" << m_command
|
||||
<< "with code" << m_exitCode
|
||||
<< "IN" << p->workingDirectory();
|
||||
}
|
||||
} else {
|
||||
qCritical() << "PROCESS" << m_command << "CRASHED with code"
|
||||
<< p->exitCode();
|
||||
<< p->exitCode()
|
||||
<< "IN" << p->workingDirectory();
|
||||
}
|
||||
} else {
|
||||
qCritical() << "PROCESS" << m_command << "DID NOT FINISH";
|
||||
qCritical() << "PROCESS" << m_command
|
||||
<< "DID NOT FINISH"
|
||||
<< "IN" << p->workingDirectory();
|
||||
}
|
||||
} else {
|
||||
qCritical() << "WRONG PROCESS STATE" << p->state();
|
||||
qCritical() << "WRONG PROCESS STATE" << p->state()
|
||||
<< "IN" << p->workingDirectory();
|
||||
}
|
||||
} else {
|
||||
qCritical() << "PROCESS" << m_command << "TIMEOUT AT START";
|
||||
qCritical() << "PROCESS" << m_command << "TIMEOUT AT START"
|
||||
<< "IN" << p->workingDirectory();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
89
worker.cpp
89
worker.cpp
@ -1117,6 +1117,17 @@ PSAInstalled Worker::getPSAInstalled() {
|
||||
QString absPathName;
|
||||
QString absPathNameRepository;
|
||||
|
||||
psaInstalled.versionInfo.lastCommit = "";
|
||||
psaInstalled.versionInfo.reason = "";
|
||||
psaInstalled.versionInfo.created = "";
|
||||
|
||||
QStringList versionInfo = m_gc.gitShowReason();
|
||||
if (versionInfo.size() == 3) {
|
||||
psaInstalled.versionInfo.lastCommit = versionInfo.at(0);
|
||||
psaInstalled.versionInfo.reason = versionInfo.at(1);
|
||||
psaInstalled.versionInfo.created = versionInfo.at(2);
|
||||
}
|
||||
|
||||
if (m_zoneNr != 0) {
|
||||
QString const &n = QString("%1").arg(m_zoneNr).rightJustified(2, '0');
|
||||
psaInstalled.tariff.name = QString("tariff%1.json").arg(n);
|
||||
@ -1179,84 +1190,6 @@ PSAInstalled Worker::getPSAInstalled() {
|
||||
return psaInstalled;
|
||||
}
|
||||
|
||||
QString Worker::sendCmdSendVersionToIsmas() {
|
||||
|
||||
QStringList const dcVersion = getDCVersion();
|
||||
QString const deviceControllerVersionHW = dcVersion.first();
|
||||
QString const deviceControllerVersionSW = dcVersion.last();
|
||||
|
||||
qInfo() << "CURRENT DC-HW-VERSION: " << deviceControllerVersionHW;
|
||||
qInfo() << "CURRENT DC-SW-VERSION: " << deviceControllerVersionSW;
|
||||
|
||||
QString const deviceControllerGitBlob = "N/A";
|
||||
QString const deviceControllerGitLastCommit = "N/A";
|
||||
|
||||
PSAInstalled psaInstalled;
|
||||
QString printSysDir("/etc/psa_config");
|
||||
QString tariffSysDir("/etc/psa_tariff");
|
||||
QString absPathName;
|
||||
|
||||
if (m_zoneNr != 0) {
|
||||
QString const &n = QString("%1").arg(m_zoneNr).rightJustified(2, '0');
|
||||
psaInstalled.tariff.name = QString("tariff%1.json").arg(n);
|
||||
absPathName = QDir::cleanPath(tariffSysDir + QDir::separator() + psaInstalled.tariff.name);
|
||||
psaInstalled.tariff.blob = m_gc.gitBlob(absPathName);
|
||||
psaInstalled.tariff.size = getFileSize(absPathName);
|
||||
psaInstalled.tariff.zone = m_zoneNr;
|
||||
}
|
||||
psaInstalled.tariff.project = "Szeged";
|
||||
psaInstalled.tariff.info = "N/A";
|
||||
psaInstalled.tariff.loadTime = "N/A"; // QDateTime::currentDateTime().toString(Qt::ISODateWithMs);
|
||||
psaInstalled.tariff.version = "N/A";
|
||||
|
||||
psaInstalled.hw.linuxVersion = m_osVersion;
|
||||
psaInstalled.hw.cpuSerial = m_cpuSerial;
|
||||
|
||||
psaInstalled.dc.versionHW = deviceControllerVersionHW;
|
||||
psaInstalled.dc.versionSW = deviceControllerVersionSW;
|
||||
psaInstalled.dc.gitBlob = "N/A";
|
||||
psaInstalled.dc.gitLastCommit = "N/A";
|
||||
psaInstalled.dc.size = -1;
|
||||
|
||||
psaInstalled.sw.raucVersion = m_raucVersion;
|
||||
psaInstalled.sw.opkgVersion = m_opkgVersion;
|
||||
psaInstalled.sw.atbQTVersion = m_atbqtVersion;
|
||||
|
||||
psaInstalled.pluginVersion.deviceController = m_pluginVersionATBDeciceController;
|
||||
psaInstalled.pluginVersion.ingenicoISelfCC = m_pluginVersionIngenicoISelf;
|
||||
psaInstalled.pluginVersion.mobilisisCalculatePrice = m_pluginVersionMobilisisCalc;
|
||||
psaInstalled.pluginVersion.mobilisisCalculatePriceConfigUi = m_pluginVersionMobilisisCalcConfig;
|
||||
psaInstalled.pluginVersion.prmCalculatePrice = m_pluginVersionPrmCalc;
|
||||
psaInstalled.pluginVersion.prmCalculatePriceConfigUi = m_pluginVersionPrmCalcConfig;
|
||||
psaInstalled.pluginVersion.tcpZVT = m_pluginVersionTcpZvt;
|
||||
|
||||
psaInstalled.cash.name = "DC2C_cash.json";
|
||||
absPathName = QDir::cleanPath(printSysDir + QDir::separator() + psaInstalled.cash.name);
|
||||
psaInstalled.cash.blob = m_gc.gitBlob(absPathName);
|
||||
psaInstalled.cash.size = getFileSize(absPathName);
|
||||
|
||||
psaInstalled.conf.name = "DC2C_conf.json";
|
||||
absPathName = QDir::cleanPath(printSysDir + QDir::separator() + psaInstalled.conf.name);
|
||||
psaInstalled.conf.blob = m_gc.gitBlob(absPathName);
|
||||
psaInstalled.conf.size = getFileSize(absPathName);
|
||||
|
||||
psaInstalled.device.name = "DC2C_device.json";
|
||||
absPathName = QDir::cleanPath(printSysDir + QDir::separator() + psaInstalled.device.name);
|
||||
psaInstalled.device.blob = m_gc.gitBlob(absPathName);
|
||||
psaInstalled.device.size = getFileSize(absPathName);
|
||||
|
||||
for (int i=0; i < 32; ++i) {
|
||||
QString const &n = QString("%1").arg(i+1).rightJustified(2, '0');
|
||||
psaInstalled.print[i].name = QString("DC2C_print%1.json").arg(n);
|
||||
absPathName = QDir::cleanPath(printSysDir + QDir::separator() + psaInstalled.print[i].name);
|
||||
psaInstalled.print[i].blob = m_gc.gitBlob(absPathName);
|
||||
psaInstalled.print[i].size = getFileSize(absPathName);
|
||||
}
|
||||
|
||||
// QByteArray data = "#M=APISM#C=CMD_SENDVERSION#J=";
|
||||
return m_ismasClient.updateOfPSASendVersion(psaInstalled);
|
||||
}
|
||||
|
||||
/************************************************************************************************
|
||||
* operators
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user