Add handling of VERSION. Add test-mode.
This commit is contained in:
parent
027529161d
commit
6bb46e165c
18
main.cpp
18
main.cpp
@ -36,9 +36,9 @@
|
|||||||
|
|
||||||
class hwinf;
|
class hwinf;
|
||||||
static void doWork(hwinf *hw, QString update_ctrl_file,
|
static void doWork(hwinf *hw, QString update_ctrl_file,
|
||||||
QString workingDir, bool maintenanceMode) {
|
QString workingDir, bool maintenanceMode, bool testMode) {
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(2000));
|
std::this_thread::sleep_for(std::chrono::milliseconds(2000));
|
||||||
Update update(hw, update_ctrl_file, workingDir, maintenanceMode);
|
Update update(hw, update_ctrl_file, workingDir, maintenanceMode, testMode);
|
||||||
update.doUpdate();
|
update.doUpdate();
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(2000));
|
std::this_thread::sleep_for(std::chrono::milliseconds(2000));
|
||||||
QCoreApplication::quit();
|
QCoreApplication::quit();
|
||||||
@ -54,7 +54,7 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
QApplication::setApplicationName("ATBUpdateTool");
|
QApplication::setApplicationName("ATBUpdateTool");
|
||||||
QApplication::setApplicationVersion("1.0");
|
QApplication::setApplicationVersion(APP_VERSION);
|
||||||
|
|
||||||
if (!messageHandlerInstalled()) { // change internal qt-QDebug-handling
|
if (!messageHandlerInstalled()) { // change internal qt-QDebug-handling
|
||||||
atbInstallMessageHandler(atbDebugOutput);
|
atbInstallMessageHandler(atbDebugOutput);
|
||||||
@ -92,6 +92,12 @@ int main(int argc, char *argv[]) {
|
|||||||
QCoreApplication::translate("main", "Maintenance mode for underlying script"));
|
QCoreApplication::translate("main", "Maintenance mode for underlying script"));
|
||||||
parser.addOption(maintenanceOption);
|
parser.addOption(maintenanceOption);
|
||||||
|
|
||||||
|
// test-mode: edit the file update_log.csv and execute the commands
|
||||||
|
// contained in it. Do not call the update-script.
|
||||||
|
QCommandLineOption testOption("t",
|
||||||
|
QCoreApplication::translate("main", "Test mode for ATBUpdateTool"));
|
||||||
|
parser.addOption(testOption);
|
||||||
|
|
||||||
// TODO:
|
// TODO:
|
||||||
// add some additional parameters
|
// add some additional parameters
|
||||||
// --dry-run
|
// --dry-run
|
||||||
@ -106,6 +112,7 @@ int main(int argc, char *argv[]) {
|
|||||||
QString plugInName = parser.value(pluginNameOption);
|
QString plugInName = parser.value(pluginNameOption);
|
||||||
QString workingDir = parser.value(workingDirectoryOption);
|
QString workingDir = parser.value(workingDirectoryOption);
|
||||||
bool maintenanceMode = parser.isSet(maintenanceOption);
|
bool maintenanceMode = parser.isSet(maintenanceOption);
|
||||||
|
bool testMode = parser.isSet(testOption);
|
||||||
QString const rtPath = QCoreApplication::applicationDirPath();
|
QString const rtPath = QCoreApplication::applicationDirPath();
|
||||||
|
|
||||||
if (plugInDir == pluginDefault) {
|
if (plugInDir == pluginDefault) {
|
||||||
@ -121,6 +128,7 @@ int main(int argc, char *argv[]) {
|
|||||||
qInfo() << "plugInName" << "=" << plugInName;
|
qInfo() << "plugInName" << "=" << plugInName;
|
||||||
qInfo() << "workingDir" << "=" << workingDir;
|
qInfo() << "workingDir" << "=" << workingDir;
|
||||||
qInfo() << "maintenanceMode" << "=" << maintenanceMode;
|
qInfo() << "maintenanceMode" << "=" << maintenanceMode;
|
||||||
|
qInfo() << "testMode" << "=" << testMode;
|
||||||
|
|
||||||
// before loading the library, delete all possible shared memory segments
|
// before loading the library, delete all possible shared memory segments
|
||||||
#if defined Q_OS_LINUX || defined Q_OS_UNIX
|
#if defined Q_OS_LINUX || defined Q_OS_UNIX
|
||||||
@ -130,10 +138,10 @@ int main(int argc, char *argv[]) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
hwinf *hw = Update::loadDCPlugin(QDir(plugInDir), plugInName);
|
hwinf *hw = Update::loadDCPlugin(QDir(plugInDir), plugInName);
|
||||||
hw->dc_autoRequest(false);
|
// hw->dc_autoRequest(false);
|
||||||
|
|
||||||
QString const update_ctrl_file = "/opt/app/tools/atbupdate/update_log.csv";
|
QString const update_ctrl_file = "/opt/app/tools/atbupdate/update_log.csv";
|
||||||
std::thread t(doWork, hw, update_ctrl_file, workingDir, maintenanceMode);
|
std::thread t(doWork, hw, update_ctrl_file, workingDir, maintenanceMode, testMode);
|
||||||
|
|
||||||
int ret = a.exec();
|
int ret = a.exec();
|
||||||
t.join();
|
t.join();
|
||||||
|
Loading…
Reference in New Issue
Block a user