save for weekend

This commit is contained in:
Gerhard Hoffmann 2025-01-10 14:19:43 +01:00
parent 8f822c5383
commit f1aad81a0c
4 changed files with 53 additions and 10 deletions

View File

@ -1,12 +1,14 @@
#include "utils.h" #include "utils.h"
#include "message_handler.h" #include "message_handler.h"
#include "git/git_client.h" #include "git/git_client.h"
#include "worker.h"
#if defined (Q_OS_UNIX) || defined (Q_OS_LINUX) #if defined (Q_OS_UNIX) || defined (Q_OS_LINUX)
#include "unistd.h" #include "unistd.h"
#endif #endif
#include <QObject>
#include <QFile> #include <QFile>
#include <QTextStream> #include <QTextStream>
#include <QDebug> #include <QDebug>
@ -23,7 +25,7 @@
#include <fstream> #include <fstream>
QVector<QPair<QString, QString>> Utils::installedJsonFiles(QDir const &customerDir) { QVector<QPair<QString, QString>> Utils::installedJsonFiles(Worker const *worker, QDir const &customerDir) {
QVector<QPair<QString, QString>> vec; QVector<QPair<QString, QString>> vec;
QStringList fileList; QStringList fileList;
@ -47,12 +49,26 @@ QVector<QPair<QString, QString>> Utils::installedJsonFiles(QDir const &customerD
for (int i = 0; i < fileList.size(); ++i) { for (int i = 0; i < fileList.size(); ++i) {
QProcess p; QProcess p;
// connect(&p, SIGNAL(finished(int,QProcess::ExitStatus)), , SLOT(finished(int,QProcess::ExitStatus)));
QStringList params; QStringList params;
params << "-c" << "git log -n 1 --pretty=format:%H -- " << fileList[i]; params << "-c" << "git log -n 1 --pretty=format:%H -- " << fileList[i];
//QObject::connect(&p, SIGNAL(readyReadStandardOutput()),
// worker, SLOT(Worker::readyReadStandardOutput()), Qt::DirectConnection);
p.start("bash", params); p.start("bash", params);
p.waitForReadyRead();
p.write("exit");
p.waitForFinished(); p.waitForFinished();
QString r = p.readAllStandardOutput().left(8);
QString r = p.readAll().left(8);
//QObject::disconnect(&p, SIGNAL(readyReadStandardOutput()), worker, SLOT(Worker::readyReadStandardError()));
qCritical() << QDir::current().absolutePath()
<< "JS git log -n 1 --pretty=format:%H -- " << fileList[i] << r;
vec.push_back(QPair<QString, QString>(QFileInfo(fileList[i]).fileName(), r)); vec.push_back(QPair<QString, QString>(QFileInfo(fileList[i]).fileName(), r));
} }
@ -66,7 +82,7 @@ QVector<QPair<QString, QString>> Utils::installedJsonFiles(QDir const &customerD
return vec; return vec;
} }
QVector<QPair<QString, QString>> Utils::installedTariffFiles(QDir const &customerDir) { QVector<QPair<QString, QString>> Utils::installedTariffFiles(Worker const *worker, QDir const &customerDir) {
QVector<QPair<QString, QString>> vec; QVector<QPair<QString, QString>> vec;
QStringList fileList; QStringList fileList;
@ -93,11 +109,19 @@ QVector<QPair<QString, QString>> Utils::installedTariffFiles(QDir const &custome
QStringList params; QStringList params;
params << "-c" << "git log -n 1 --pretty=format:%H -- " << fileList[i]; params << "-c" << "git log -n 1 --pretty=format:%H -- " << fileList[i];
qCritical() << current << "git log -n 1 --pretty=format:%H -- " << fileList[i]; //QObject::connect(&p, SIGNAL(readyReadStandardOutput()),
// worker, SLOT(Worker::readyReadStandardOutput()), Qt::DirectConnection);
p.start("bash", params); p.start("bash", params);
p.waitForReadyRead();
p.write("exit");
p.waitForFinished(); p.waitForFinished();
QString r = p.readAllStandardOutput().left(8);
QString r = p.readAll().left(8);
// QObject::disconnect(&p, SIGNAL(readyReadStandardOutput()), worker, SLOT(Worker::readyReadStandardError()));
qCritical() << QDir::current().absolutePath()
<< "git log -n 1 --pretty=format:%H -- " << fileList[i] << r;
vec.push_back(QPair<QString, QString>(QFileInfo(fileList[i]).fileName(), r)); vec.push_back(QPair<QString, QString>(QFileInfo(fileList[i]).fileName(), r));
} }
@ -113,7 +137,7 @@ QVector<QPair<QString, QString>> Utils::installedTariffFiles(QDir const &custome
QVector<QPair<QString, QString>> Utils::installedPackages() { QVector<QPair<QString, QString>> Utils::installedPackages() {
QVector<QPair<QString, QString>> vec; QVector<QPair<QString, QString>> vec;
if (QFile::exists("/usr/bin/ptuPackageVersions")) { if (QFile::exists("/usr/bin/")) {
QProcess p; QProcess p;
QStringList params; QStringList params;
params << "-c" << R"(/usr/bin/ptuPackageVersions -i -o json)"; params << "-c" << R"(/usr/bin/ptuPackageVersions -i -o json)";

View File

@ -10,7 +10,9 @@
#include <QDir> #include <QDir>
#include <QDebug> #include <QDebug>
#include <QPair> #include <QPair>
#include <QProcess>
class Worker;
namespace Utils { namespace Utils {
int read1stLineOfFile(QString fileName); int read1stLineOfFile(QString fileName);
QString getLocation(QString fileName); QString getLocation(QString fileName);
@ -36,8 +38,10 @@ namespace Utils {
bool isATBQTRunning(); bool isATBQTRunning();
QVector<QPair<QString, QString>> installedPackages(); QVector<QPair<QString, QString>> installedPackages();
QVector<QPair<QString, QString>> installedJsonFiles(QDir const &customerDir); QVector<QPair<QString, QString>> installedJsonFiles(Worker const *worker, QDir const &customerDir);
QVector<QPair<QString, QString>> installedTariffFiles(QDir const &customerDir); QVector<QPair<QString, QString>> installedTariffFiles(Worker const *worker, QDir const &customerDir);
void finished(int exitCode, QProcess::ExitStatus exitStatus);
} }
#endif // UTILS_H_INCLUDED #endif // UTILS_H_INCLUDED

View File

@ -1514,6 +1514,14 @@ PSAInstalled Worker::getPSAInstalled() {
return psaInstalled; return psaInstalled;
} }
void Worker::readyReadStandardOutput() {
QProcess *p = (QProcess *)sender();
m_standardOutput = p->readAllStandardOutput();
qCritical() << "ZZZZ" << m_standardOutput;
}
bool Worker::jsUpdate() { bool Worker::jsUpdate() {
return m_dcDownloadJsonFiles->start("/opt/app/tools/atbupdate"); return m_dcDownloadJsonFiles->start("/opt/app/tools/atbupdate");
} }
@ -1527,8 +1535,8 @@ void Worker::summary() {
QString summary, first, second, line, tmp; QString summary, first, second, line, tmp;
QVector<QPair<QString, QString>> vec = Utils::installedPackages(); QVector<QPair<QString, QString>> vec = Utils::installedPackages();
vec.append(Utils::installedTariffFiles(m_customerRepository)); vec.append(Utils::installedTariffFiles(this, m_customerRepository));
vec.append(Utils::installedJsonFiles(m_customerRepository)); vec.append(Utils::installedJsonFiles(this, m_customerRepository));
int max_first = 0, max_second = 0; int max_first = 0, max_second = 0;
for (int i = 0; i < vec.size(); ++i) { for (int i = 0; i < vec.size(); ++i) {

View File

@ -11,6 +11,7 @@
#include <QMap> #include <QMap>
#include <QDebug> #include <QDebug>
#include <QThread> #include <QThread>
#include <QByteArray>
#include <optional> #include <optional>
#include <initializer_list> #include <initializer_list>
@ -466,6 +467,8 @@ public:
void summary(); void summary();
QDateTime start() { return m_start; } QDateTime start() { return m_start; }
QByteArray standardOutput() const { return m_standardOutput; }
signals: signals:
void appendText(QString, QString suffix = ""); void appendText(QString, QString suffix = "");
void insertText(QString); void insertText(QString);
@ -495,6 +498,9 @@ private slots:
// bool sendIsmasLastVersionNotification(int progress); // bool sendIsmasLastVersionNotification(int progress);
bool saveLogFile(); bool saveLogFile();
public slots:
void readyReadStandardOutput();
private: private:
PSAInstalled getPSAInstalled(); PSAInstalled getPSAInstalled();
static bool sendLastVersionOnce; static bool sendLastVersionOnce;
@ -503,6 +509,7 @@ private:
bool execOpkgCommands(); bool execOpkgCommands();
QDateTime m_start; QDateTime m_start;
QByteArray m_standardOutput;
static const QMap<UPDATE_STEP, const char*> smap; static const QMap<UPDATE_STEP, const char*> smap;