2020-11-14 16:34:31 +01:00
|
|
|
// Python includes
|
|
|
|
#include <Python.h>
|
|
|
|
|
2017-03-02 10:50:31 +01:00
|
|
|
#include "utils/SysInfo.h"
|
2020-10-20 20:18:51 +02:00
|
|
|
#include "utils/FileUtils.h"
|
2017-03-02 10:50:31 +01:00
|
|
|
|
2017-03-04 22:17:42 +01:00
|
|
|
#include <QHostInfo>
|
2017-03-02 10:50:31 +01:00
|
|
|
#include <QSysInfo>
|
2020-10-20 20:18:51 +02:00
|
|
|
#include <QRegularExpression>
|
|
|
|
#include <QRegularExpressionMatch>
|
|
|
|
|
|
|
|
#include <iostream>
|
2017-03-02 10:50:31 +01:00
|
|
|
|
|
|
|
SysInfo* SysInfo::_instance = nullptr;
|
|
|
|
|
|
|
|
SysInfo::SysInfo()
|
|
|
|
: QObject()
|
|
|
|
{
|
2020-05-12 19:51:19 +02:00
|
|
|
_sysinfo.kernelType = QSysInfo::kernelType();
|
|
|
|
_sysinfo.kernelVersion = QSysInfo::kernelVersion();
|
|
|
|
_sysinfo.architecture = QSysInfo::currentCpuArchitecture();
|
2017-03-04 22:17:42 +01:00
|
|
|
_sysinfo.wordSize = QString::number(QSysInfo::WordSize);
|
2020-05-12 19:51:19 +02:00
|
|
|
_sysinfo.productType = QSysInfo::productType();
|
|
|
|
_sysinfo.productVersion = QSysInfo::productVersion();
|
|
|
|
_sysinfo.prettyName = QSysInfo::prettyProductName();
|
2017-03-04 22:17:42 +01:00
|
|
|
_sysinfo.hostName = QHostInfo::localHostName();
|
2020-05-12 19:51:19 +02:00
|
|
|
_sysinfo.domainName = QHostInfo::localDomainName();
|
2020-10-20 20:18:51 +02:00
|
|
|
getCPUInfo();
|
2020-11-14 16:34:31 +01:00
|
|
|
_sysinfo.qtVersion = QT_VERSION_STR;
|
|
|
|
_sysinfo.pyVersion = PY_VERSION;
|
2017-03-02 10:50:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
SysInfo::HyperionSysInfo SysInfo::get()
|
|
|
|
{
|
2020-06-28 23:12:22 +02:00
|
|
|
if (SysInfo::_instance == nullptr)
|
2017-03-02 10:50:31 +01:00
|
|
|
SysInfo::_instance = new SysInfo();
|
|
|
|
|
2020-05-12 19:51:19 +02:00
|
|
|
return SysInfo::_instance->_sysinfo;
|
2017-03-02 10:50:31 +01:00
|
|
|
}
|
2020-10-20 20:18:51 +02:00
|
|
|
|
|
|
|
void SysInfo::getCPUInfo()
|
|
|
|
{
|
|
|
|
QString cpuInfo;
|
|
|
|
if( FileUtils::readFile("/proc/cpuinfo", cpuInfo, Logger::getInstance("DAEMON"), true) )
|
|
|
|
{
|
|
|
|
QRegularExpression regEx ("^model\\s*:\\s(.*)", QRegularExpression::CaseInsensitiveOption | QRegularExpression::MultilineOption);
|
|
|
|
QRegularExpressionMatch match;
|
|
|
|
|
|
|
|
match = regEx.match(cpuInfo);
|
|
|
|
if ( match.hasMatch() )
|
|
|
|
{
|
|
|
|
_sysinfo.cpuModelType = match.captured(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
regEx.setPattern("^model name\\s*:\\s(.*)");
|
|
|
|
match = regEx.match(cpuInfo);
|
|
|
|
if ( match.hasMatch() )
|
|
|
|
{
|
|
|
|
_sysinfo.cpuModelName = match.captured(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
regEx.setPattern("^hardware\\s*:\\s(.*)");
|
|
|
|
match = regEx.match(cpuInfo);
|
|
|
|
if ( match.hasMatch() )
|
|
|
|
{
|
|
|
|
_sysinfo.cpuHardware = match.captured(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
regEx.setPattern("^revision\\s*:\\s(.*)");
|
|
|
|
match = regEx.match(cpuInfo);
|
|
|
|
if ( match.hasMatch() )
|
|
|
|
{
|
|
|
|
_sysinfo.cpuRevision = match.captured(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
regEx.setPattern("^revision\\s*:\\s(.*)");
|
|
|
|
match = regEx.match(cpuInfo);
|
|
|
|
if ( match.hasMatch() )
|
|
|
|
{
|
|
|
|
_sysinfo.cpuRevision = match.captured(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|