adding commnds to execute
This commit is contained in:
parent
b6f0615e9c
commit
7b4bee524f
@ -0,0 +1,6 @@
|
||||
#include "process/check_and_fetch_customer_repository_command.h"
|
||||
|
||||
CheckAndFetchCustomerRepositoryCommand::CheckAndFetchCustomerRepositoryCommand(
|
||||
QString const &command, Worker *worker, int start_timeout, int finish_timeout)
|
||||
: UpdateCommand(command, worker, start_timeout, finish_timeout) {
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
#ifndef CHECK_AND_FETCH_CUSTOMER_REPOSITORY_COMMAND_H_INCLUDED
|
||||
#define CHECK_AND_FETCH_CUSTOMER_REPOSITORY_COMMAND_H_INCLUDED
|
||||
|
||||
#include "update_command.h"
|
||||
|
||||
class CheckAndFetchCustomerRepositoryCommand : public UpdateCommand {
|
||||
public:
|
||||
explicit CheckAndFetchCustomerRepositoryCommand(QString const &command,
|
||||
Worker *worker,
|
||||
int start_timeout = 100000,
|
||||
int finish_timeout = 100000);
|
||||
};
|
||||
|
||||
#endif // CHECK_AND_FETCH_CUSTOMER_REPOSITORY_COMMAND_H_INCLUDED
|
@ -0,0 +1,9 @@
|
||||
#include "process/check_ismas_connectivity_command.h"
|
||||
|
||||
|
||||
CheckIsmasConnectivityCommand::CheckIsmasConnectivityCommand(QString const &command,
|
||||
Worker *worker,
|
||||
int start_timeout,
|
||||
int finish_timeout)
|
||||
: UpdateCommand(command, worker, start_timeout, finish_timeout) {
|
||||
}
|
14
UpdatePTUDevCtrl/process/check_ismas_connectivity_command.h
Normal file
14
UpdatePTUDevCtrl/process/check_ismas_connectivity_command.h
Normal file
@ -0,0 +1,14 @@
|
||||
#ifndef CHECK_ISMAS_CONNECTIVITY_COMMAND_H_INCLUDED
|
||||
#define CHECK_ISMAS_CONNECTIVITY_COMMAND_H_INCLUDED
|
||||
|
||||
#include "update_command.h"
|
||||
|
||||
class CheckIsmasConnectivityCommand : public UpdateCommand {
|
||||
public:
|
||||
explicit CheckIsmasConnectivityCommand(QString const &command,
|
||||
Worker *worker,
|
||||
int start_timeout = 100000,
|
||||
int finish_timeout = 100000);
|
||||
};
|
||||
|
||||
#endif // CHECK_ISMAS_CONNECTIVITY_COMMAND_H_INCLUDED
|
@ -0,0 +1,9 @@
|
||||
#include "process/check_update_activation_command.h"
|
||||
|
||||
|
||||
CheckUpdateActivationCommand::CheckUpdateActivationCommand(QString const &command,
|
||||
Worker *worker,
|
||||
int start_timeout,
|
||||
int finish_timeout)
|
||||
: UpdateCommand(command, worker, start_timeout, finish_timeout) {
|
||||
}
|
14
UpdatePTUDevCtrl/process/check_update_activation_command.h
Normal file
14
UpdatePTUDevCtrl/process/check_update_activation_command.h
Normal file
@ -0,0 +1,14 @@
|
||||
#ifndef CHECK_UPDATE_ACTIVATION_COMMAND_H_INCLUDED
|
||||
#define CHECK_UPDATE_ACTIVATION_COMMAND_H_INCLUDED
|
||||
|
||||
#include "update_command.h"
|
||||
|
||||
class CheckUpdateActivationCommand : public UpdateCommand {
|
||||
public:
|
||||
explicit CheckUpdateActivationCommand(QString const &command,
|
||||
Worker *worker,
|
||||
int start_timeout = 100000,
|
||||
int finish_timeout = 100000);
|
||||
};
|
||||
|
||||
#endif // CHECK_UPDATE_ACTIVATION_COMMAND_H_INCLUDED
|
@ -92,6 +92,7 @@ void Command::readyReadStandardError() {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: nach UpdateCommands ziehen
|
||||
void Command::finished(int /*exitCode*/, QProcess::ExitStatus /*exitStatus*/) {
|
||||
QProcess *p = (QProcess *)sender();
|
||||
// read all remaining data sent to the process, just in case
|
||||
@ -109,6 +110,7 @@ void Command::finished(int /*exitCode*/, QProcess::ExitStatus /*exitStatus*/) {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: nach UpdateCommand ziehen
|
||||
bool Command::start(QString workingDirectory, QStringList args) {
|
||||
if (!QDir::setCurrent(workingDirectory)) {
|
||||
qCritical() << "SET WORKING_DIRECTORY" << workingDirectory
|
||||
|
@ -1,6 +1,5 @@
|
||||
#ifndef COMMAND_H_INCLUDED
|
||||
#define COMMAND_H_INCLUDED
|
||||
#endif // COMMAND_H_INCLUDED
|
||||
|
||||
#include <QObject>
|
||||
#include <QCoreApplication>
|
||||
@ -13,14 +12,24 @@ class Worker;
|
||||
class Command : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
protected:
|
||||
QString m_command;
|
||||
mutable QString m_commandResult;
|
||||
|
||||
private:
|
||||
int m_waitForStartTimeout;
|
||||
int m_waitForFinishTimeout;
|
||||
int m_exitCode;
|
||||
|
||||
protected:
|
||||
mutable QMutex m_mtx;
|
||||
|
||||
private:
|
||||
QProcess *m_p;
|
||||
|
||||
protected:
|
||||
Worker *m_worker;
|
||||
|
||||
public:
|
||||
explicit Command(QString const &command,
|
||||
int start_timeout = 100000,
|
||||
@ -35,8 +44,10 @@ public:
|
||||
|
||||
void setWorker(Worker *worker) {m_worker = worker; }
|
||||
|
||||
private slots:
|
||||
protected slots:
|
||||
void readyReadStandardOutput();
|
||||
void readyReadStandardError();
|
||||
void finished(int exitCode, QProcess::ExitStatus exitStatus);
|
||||
virtual void finished(int exitCode, QProcess::ExitStatus exitStatus);
|
||||
};
|
||||
|
||||
#endif // COMMAND_H_INCLUDED
|
||||
|
10
UpdatePTUDevCtrl/process/exec_opkg_command.cpp
Normal file
10
UpdatePTUDevCtrl/process/exec_opkg_command.cpp
Normal file
@ -0,0 +1,10 @@
|
||||
#include "process/exec_opkg_command.h"
|
||||
|
||||
|
||||
ExecOpkgCommand::ExecOpkgCommand(QString const &command,
|
||||
Worker *worker,
|
||||
int start_timeout,
|
||||
int finish_timeout)
|
||||
: UpdateCommand(command, worker, start_timeout, finish_timeout)
|
||||
, m_noaction(m_noaction) {
|
||||
}
|
17
UpdatePTUDevCtrl/process/exec_opkg_command.h
Normal file
17
UpdatePTUDevCtrl/process/exec_opkg_command.h
Normal file
@ -0,0 +1,17 @@
|
||||
#ifndef EXEC_OPKG_COMMAND_H_INCLUDED
|
||||
#define EXEC_OPKG_COMMAND_H_INCLUDED
|
||||
|
||||
|
||||
#include "update_command.h"
|
||||
|
||||
class ExecOpkgCommand : public UpdateCommand {
|
||||
bool m_noaction{false};
|
||||
public:
|
||||
explicit ExecOpkgCommand(QString const &command,
|
||||
Worker *worker,
|
||||
bool noaction,
|
||||
int start_timeout = 100000,
|
||||
int finish_timeout = 100000);
|
||||
};
|
||||
|
||||
#endif // EXEC_OPKG_COMMAND_H_INCLUDED
|
@ -0,0 +1,9 @@
|
||||
#include "process/show_software_status_command.h"
|
||||
|
||||
|
||||
ShowSoftwareStatusCommand::ShowSoftwareStatusCommand(QString const &command,
|
||||
Worker *worker,
|
||||
int start_timeout,
|
||||
int finish_timeout)
|
||||
: UpdateCommand(command, worker, start_timeout, finish_timeout) {
|
||||
}
|
13
UpdatePTUDevCtrl/process/show_software_status_command.h
Normal file
13
UpdatePTUDevCtrl/process/show_software_status_command.h
Normal file
@ -0,0 +1,13 @@
|
||||
#ifndef SHOW_SOFTWARE_STATUS_COMMAND_H_INCLUDED
|
||||
#define SHOW_SOFTWARE_STATUS_COMMAND_H_INCLUDED
|
||||
|
||||
#include "update_command.h"
|
||||
|
||||
class ShowSoftwareStatusCommand : public UpdateCommand {
|
||||
public:
|
||||
explicit ShowSoftwareStatusCommand(QString const &command,
|
||||
Worker *worker,
|
||||
int start_timeout = 100000,
|
||||
int finish_timeout = 100000);
|
||||
};
|
||||
#endif // SHOW_SOFTWARE_STATUS_COMMAND_H_INCLUDED
|
45
UpdatePTUDevCtrl/process/update_command.cpp
Normal file
45
UpdatePTUDevCtrl/process/update_command.cpp
Normal file
@ -0,0 +1,45 @@
|
||||
#include "update_command.h"
|
||||
#include "worker.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QProcess>
|
||||
|
||||
UpdateCommand::UpdateCommand(QString const &command,
|
||||
Worker *worker,
|
||||
int start_timeout,
|
||||
int finish_timeout)
|
||||
: Command(command, start_timeout, finish_timeout) {
|
||||
setWorker(worker);
|
||||
}
|
||||
|
||||
bool UpdateCommand::stopUpdateOnFailure() {
|
||||
return true;
|
||||
}
|
||||
|
||||
void UpdateCommand::finished(int exitCode, QProcess::ExitStatus exitStatus) {
|
||||
|
||||
qCritical() << __func__ << ":" << __LINE__ << m_command
|
||||
<< "exitCode" << exitCode
|
||||
<< "exitStatus" << exitStatus;
|
||||
|
||||
QProcess *p = (QProcess *)sender();
|
||||
if (p) {
|
||||
// read all remaining data sent to the process, just in case
|
||||
m_commandResult += p->readAllStandardOutput();
|
||||
|
||||
disconnect(p, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(readyReadStandardOutput()));
|
||||
disconnect(p, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(readyReadStandardError()));
|
||||
disconnect(p, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(finished(int,QProcess::ExitStatus)));
|
||||
}
|
||||
|
||||
if (!m_worker->workList().empty()) {
|
||||
if (exitCode == 0 && exitStatus == QProcess::ExitStatus::NormalExit) {
|
||||
if (m_worker->workList().nextExec()) {
|
||||
m_worker->workList().exec();
|
||||
}
|
||||
} else {
|
||||
bool execShowStatus = true;
|
||||
m_worker->workList().exec(execShowStatus);
|
||||
}
|
||||
}
|
||||
}
|
20
UpdatePTUDevCtrl/process/update_command.h
Normal file
20
UpdatePTUDevCtrl/process/update_command.h
Normal file
@ -0,0 +1,20 @@
|
||||
#ifndef UPDATE_COMMAND_H_INCLUDED
|
||||
#define UPDATE_COMMAND_H_INCLUDED
|
||||
|
||||
#include "process/command.h"
|
||||
|
||||
class Worker;
|
||||
class UpdateCommand : public Command {
|
||||
public:
|
||||
explicit UpdateCommand(QString const &command,
|
||||
Worker *worker,
|
||||
int start_timeout = 100000,
|
||||
int finish_timeout = 100000);
|
||||
|
||||
virtual bool stopUpdateOnFailure();
|
||||
|
||||
private slots:
|
||||
virtual void finished(int exitCode, QProcess::ExitStatus exitStatus) override;
|
||||
};
|
||||
|
||||
#endif // UPDATE_COMMAND_H_INCLUDED
|
8
UpdatePTUDevCtrl/process/update_dc_command.cpp
Normal file
8
UpdatePTUDevCtrl/process/update_dc_command.cpp
Normal file
@ -0,0 +1,8 @@
|
||||
#include "process/update_dc_command.h"
|
||||
|
||||
UpdateDCCommand::UpdateDCCommand(QString const &command,
|
||||
Worker *worker,
|
||||
int start_timeout,
|
||||
int finish_timeout)
|
||||
: UpdateCommand(command, worker, start_timeout, finish_timeout) {
|
||||
}
|
14
UpdatePTUDevCtrl/process/update_dc_command.h
Normal file
14
UpdatePTUDevCtrl/process/update_dc_command.h
Normal file
@ -0,0 +1,14 @@
|
||||
#ifndef UPDATE_DC_COMMAND_H_INCLUDED
|
||||
#define UPDATE_DC_COMMAND_H_INCLUDED
|
||||
|
||||
#include "update_command.h"
|
||||
|
||||
class UpdateDCCommand : public UpdateCommand {
|
||||
public:
|
||||
explicit UpdateDCCommand(QString const &command,
|
||||
Worker *worker,
|
||||
int start_timeout = 100000,
|
||||
int finish_timeout = 100000);
|
||||
};
|
||||
|
||||
#endif // UPDATE_DC_COMMAND_H_INCLUDED
|
8
UpdatePTUDevCtrl/process/update_filesystem_command.cpp
Normal file
8
UpdatePTUDevCtrl/process/update_filesystem_command.cpp
Normal file
@ -0,0 +1,8 @@
|
||||
#include "process/update_filesystem_command.h"
|
||||
|
||||
UpdateFileSystemCommand::UpdateFileSystemCommand(QString const &command,
|
||||
Worker *worker,
|
||||
int start_timeout,
|
||||
int finish_timeout)
|
||||
: UpdateCommand(command, worker, start_timeout, finish_timeout) {
|
||||
}
|
14
UpdatePTUDevCtrl/process/update_filesystem_command.h
Normal file
14
UpdatePTUDevCtrl/process/update_filesystem_command.h
Normal file
@ -0,0 +1,14 @@
|
||||
#ifndef UPDATE_FS_COMMAND_H_INCLUDED
|
||||
#define UPDATE_FS_COMMAND_H_INCLUDED
|
||||
|
||||
#include "update_command.h"
|
||||
|
||||
class UpdateFileSystemCommand : public UpdateCommand {
|
||||
public:
|
||||
explicit UpdateFileSystemCommand(QString const &command,
|
||||
Worker *worker,
|
||||
int start_timeout = 100000,
|
||||
int finish_timeout = 100000);
|
||||
};
|
||||
|
||||
#endif // UPDATE_FS_COMMAND_H_INCLUDED
|
8
UpdatePTUDevCtrl/process/update_json_command.cpp
Normal file
8
UpdatePTUDevCtrl/process/update_json_command.cpp
Normal file
@ -0,0 +1,8 @@
|
||||
#include "process/update_json_command.h"
|
||||
|
||||
UpdateJsonCommand::UpdateJsonCommand(QString const &command,
|
||||
Worker *worker,
|
||||
int start_timeout,
|
||||
int finish_timeout)
|
||||
: UpdateCommand(command, worker, start_timeout, finish_timeout) {
|
||||
}
|
14
UpdatePTUDevCtrl/process/update_json_command.h
Normal file
14
UpdatePTUDevCtrl/process/update_json_command.h
Normal file
@ -0,0 +1,14 @@
|
||||
#ifndef UPDATE_JSON_COMMAND_H_INCLUDED
|
||||
#define UPDATE_JSON_COMMAND_H_INCLUDED
|
||||
|
||||
#include "process/update_command.h"
|
||||
|
||||
class UpdateJsonCommand : public UpdateCommand {
|
||||
public:
|
||||
explicit UpdateJsonCommand(QString const &command,
|
||||
Worker *worker,
|
||||
int start_timeout = 100000,
|
||||
int finish_timeout = 100000);
|
||||
};
|
||||
|
||||
#endif // UPDATE_JSON_HANDLER_H_INCLUDED
|
Loading…
x
Reference in New Issue
Block a user