save for weekend
This commit is contained in:
parent
8f822c5383
commit
f1aad81a0c
@ -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 <QObject>
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
#include <QDebug>
|
||||
@ -23,7 +25,7 @@
|
||||
|
||||
#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;
|
||||
QStringList fileList;
|
||||
|
||||
@ -47,12 +49,26 @@ QVector<QPair<QString, QString>> 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<QString, QString>(QFileInfo(fileList[i]).fileName(), r));
|
||||
}
|
||||
@ -66,7 +82,7 @@ QVector<QPair<QString, QString>> Utils::installedJsonFiles(QDir const &customerD
|
||||
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;
|
||||
QStringList fileList;
|
||||
|
||||
@ -93,11 +109,19 @@ QVector<QPair<QString, QString>> 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<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>> 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)";
|
||||
|
@ -10,7 +10,9 @@
|
||||
#include <QDir>
|
||||
#include <QDebug>
|
||||
#include <QPair>
|
||||
#include <QProcess>
|
||||
|
||||
class Worker;
|
||||
namespace Utils {
|
||||
int read1stLineOfFile(QString fileName);
|
||||
QString getLocation(QString fileName);
|
||||
@ -36,8 +38,10 @@ namespace Utils {
|
||||
bool isATBQTRunning();
|
||||
|
||||
QVector<QPair<QString, QString>> installedPackages();
|
||||
QVector<QPair<QString, QString>> installedJsonFiles(QDir const &customerDir);
|
||||
QVector<QPair<QString, QString>> installedTariffFiles(QDir const &customerDir);
|
||||
QVector<QPair<QString, QString>> installedJsonFiles(Worker const *worker, 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
|
||||
|
@ -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<QPair<QString, QString>> 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) {
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include <QMap>
|
||||
#include <QDebug>
|
||||
#include <QThread>
|
||||
#include <QByteArray>
|
||||
|
||||
#include <optional>
|
||||
#include <initializer_list>
|
||||
@ -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<UPDATE_STEP, const char*> smap;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user