diff --git a/UpdatePTUDevCtrl/utils.cpp b/UpdatePTUDevCtrl/utils.cpp index 7b529a3..5f578a4 100644 --- a/UpdatePTUDevCtrl/utils.cpp +++ b/UpdatePTUDevCtrl/utils.cpp @@ -1,12 +1,14 @@ #include "utils.h" #include "message_handler.h" #include "git/git_client.h" +#include "worker.h" #if defined (Q_OS_UNIX) || defined (Q_OS_LINUX) #include "unistd.h" #endif +#include #include #include #include @@ -23,7 +25,7 @@ #include -QVector> Utils::installedJsonFiles(QDir const &customerDir) { +QVector> Utils::installedJsonFiles(Worker const *worker, QDir const &customerDir) { QVector> vec; QStringList fileList; @@ -47,12 +49,26 @@ QVector> Utils::installedJsonFiles(QDir const &customerD for (int i = 0; i < fileList.size(); ++i) { QProcess p; + + // connect(&p, SIGNAL(finished(int,QProcess::ExitStatus)), , SLOT(finished(int,QProcess::ExitStatus))); + QStringList params; 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.waitForReadyRead(); + p.write("exit"); 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(QFileInfo(fileList[i]).fileName(), r)); } @@ -66,7 +82,7 @@ QVector> Utils::installedJsonFiles(QDir const &customerD return vec; } -QVector> Utils::installedTariffFiles(QDir const &customerDir) { +QVector> Utils::installedTariffFiles(Worker const *worker, QDir const &customerDir) { QVector> vec; QStringList fileList; @@ -93,11 +109,19 @@ QVector> Utils::installedTariffFiles(QDir const &custome QStringList params; 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.waitForReadyRead(); + p.write("exit"); 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(QFileInfo(fileList[i]).fileName(), r)); } @@ -113,7 +137,7 @@ QVector> Utils::installedTariffFiles(QDir const &custome QVector> Utils::installedPackages() { QVector> vec; - if (QFile::exists("/usr/bin/ptuPackageVersions")) { + if (QFile::exists("/usr/bin/")) { QProcess p; QStringList params; params << "-c" << R"(/usr/bin/ptuPackageVersions -i -o json)"; diff --git a/UpdatePTUDevCtrl/utils.h b/UpdatePTUDevCtrl/utils.h index 9300f10..80efe7c 100644 --- a/UpdatePTUDevCtrl/utils.h +++ b/UpdatePTUDevCtrl/utils.h @@ -10,7 +10,9 @@ #include #include #include +#include +class Worker; namespace Utils { int read1stLineOfFile(QString fileName); QString getLocation(QString fileName); @@ -36,8 +38,10 @@ namespace Utils { bool isATBQTRunning(); QVector> installedPackages(); - QVector> installedJsonFiles(QDir const &customerDir); - QVector> installedTariffFiles(QDir const &customerDir); + QVector> installedJsonFiles(Worker const *worker, QDir const &customerDir); + QVector> installedTariffFiles(Worker const *worker, QDir const &customerDir); + + void finished(int exitCode, QProcess::ExitStatus exitStatus); } #endif // UTILS_H_INCLUDED diff --git a/UpdatePTUDevCtrl/worker.cpp b/UpdatePTUDevCtrl/worker.cpp index 862272f..22ff1a8 100644 --- a/UpdatePTUDevCtrl/worker.cpp +++ b/UpdatePTUDevCtrl/worker.cpp @@ -1514,6 +1514,14 @@ PSAInstalled Worker::getPSAInstalled() { return psaInstalled; } +void Worker::readyReadStandardOutput() { + QProcess *p = (QProcess *)sender(); + m_standardOutput = p->readAllStandardOutput(); + + + qCritical() << "ZZZZ" << m_standardOutput; +} + bool Worker::jsUpdate() { return m_dcDownloadJsonFiles->start("/opt/app/tools/atbupdate"); } @@ -1527,8 +1535,8 @@ void Worker::summary() { QString summary, first, second, line, tmp; QVector> vec = Utils::installedPackages(); - vec.append(Utils::installedTariffFiles(m_customerRepository)); - vec.append(Utils::installedJsonFiles(m_customerRepository)); + vec.append(Utils::installedTariffFiles(this, m_customerRepository)); + vec.append(Utils::installedJsonFiles(this, m_customerRepository)); int max_first = 0, max_second = 0; for (int i = 0; i < vec.size(); ++i) { diff --git a/UpdatePTUDevCtrl/worker.h b/UpdatePTUDevCtrl/worker.h index 4b6358f..039575c 100644 --- a/UpdatePTUDevCtrl/worker.h +++ b/UpdatePTUDevCtrl/worker.h @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -466,6 +467,8 @@ public: void summary(); QDateTime start() { return m_start; } + QByteArray standardOutput() const { return m_standardOutput; } + signals: void appendText(QString, QString suffix = ""); void insertText(QString); @@ -495,6 +498,9 @@ private slots: // bool sendIsmasLastVersionNotification(int progress); bool saveLogFile(); +public slots: + void readyReadStandardOutput(); + private: PSAInstalled getPSAInstalled(); static bool sendLastVersionOnce; @@ -503,6 +509,7 @@ private: bool execOpkgCommands(); QDateTime m_start; + QByteArray m_standardOutput; static const QMap smap;