2020-05-12 19:51:19 +02:00
|
|
|
#ifdef _WIN32
|
|
|
|
#include <utils/Logger.h>
|
|
|
|
#include <QString>
|
|
|
|
#include <QByteArray>
|
|
|
|
namespace Process {
|
|
|
|
|
2020-08-08 00:21:19 +02:00
|
|
|
void restartHyperion(bool asNewProcess) {}
|
2020-05-12 19:51:19 +02:00
|
|
|
|
2020-08-08 00:21:19 +02:00
|
|
|
QByteArray command_exec(const QString& /*cmd*/, const QByteArray& /*data*/)
|
2020-05-12 19:51:19 +02:00
|
|
|
{
|
|
|
|
return QSTRING_CSTR(QString());
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
2016-09-15 20:42:58 +02:00
|
|
|
#include <utils/Process.h>
|
|
|
|
#include <utils/Logger.h>
|
|
|
|
|
|
|
|
#include <QCoreApplication>
|
2020-07-22 18:15:39 +02:00
|
|
|
#include <QProcess>
|
2016-09-15 20:42:58 +02:00
|
|
|
#include <QStringList>
|
|
|
|
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <cstdio>
|
|
|
|
#include <iostream>
|
|
|
|
#include <memory>
|
|
|
|
#include <stdexcept>
|
|
|
|
|
|
|
|
namespace Process {
|
2018-12-27 23:11:32 +01:00
|
|
|
|
2016-09-15 20:42:58 +02:00
|
|
|
void restartHyperion(bool asNewProcess)
|
|
|
|
{
|
|
|
|
Logger* log = Logger::getInstance("Process");
|
2020-07-22 18:15:39 +02:00
|
|
|
Info(log, "Restarting hyperion ...");
|
|
|
|
|
2016-09-15 20:42:58 +02:00
|
|
|
std::cout << std::endl
|
|
|
|
<< " *******************************************" << std::endl
|
|
|
|
<< " * hyperion will restart now *" << std::endl
|
|
|
|
<< " *******************************************" << std::endl << std::endl;
|
2018-12-27 23:11:32 +01:00
|
|
|
|
2020-07-22 18:15:39 +02:00
|
|
|
auto arguments = QCoreApplication::arguments();
|
|
|
|
if (!arguments.contains("--wait-hyperion"))
|
|
|
|
arguments << "--wait-hyperion";
|
2018-12-27 23:11:32 +01:00
|
|
|
|
2020-07-22 18:15:39 +02:00
|
|
|
QProcess::startDetached(QCoreApplication::applicationFilePath(), arguments);
|
2016-09-15 20:42:58 +02:00
|
|
|
|
2020-07-22 18:15:39 +02:00
|
|
|
QCoreApplication::quit();
|
2016-09-15 20:42:58 +02:00
|
|
|
}
|
|
|
|
|
2020-08-08 00:21:19 +02:00
|
|
|
QByteArray command_exec(const QString& cmd, const QByteArray& data)
|
2016-09-15 20:42:58 +02:00
|
|
|
{
|
|
|
|
char buffer[128];
|
2020-06-28 23:12:22 +02:00
|
|
|
QString result;
|
2017-01-29 21:20:12 +01:00
|
|
|
|
|
|
|
std::shared_ptr<FILE> pipe(popen(cmd.toLocal8Bit().constData(), "r"), pclose);
|
2018-12-27 23:11:32 +01:00
|
|
|
if (pipe)
|
2016-09-15 20:42:58 +02:00
|
|
|
{
|
2017-01-29 21:20:12 +01:00
|
|
|
while (!feof(pipe.get()))
|
|
|
|
{
|
|
|
|
if (fgets(buffer, 128, pipe.get()) != NULL)
|
|
|
|
result += buffer;
|
|
|
|
}
|
2016-09-15 20:42:58 +02:00
|
|
|
}
|
2017-03-04 22:17:42 +01:00
|
|
|
return QSTRING_CSTR(result);
|
2016-09-15 20:42:58 +02:00
|
|
|
}
|
|
|
|
|
2018-12-27 23:11:32 +01:00
|
|
|
};
|
2020-05-12 19:51:19 +02:00
|
|
|
|
2020-06-28 23:12:22 +02:00
|
|
|
#endif
|