Add handling of VERSION. Add test-mode.
This commit is contained in:
		
							
								
								
									
										18
									
								
								main.cpp
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								main.cpp
									
									
									
									
									
								
							@@ -36,9 +36,9 @@
 | 
			
		||||
 | 
			
		||||
class hwinf;
 | 
			
		||||
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));
 | 
			
		||||
    Update update(hw, update_ctrl_file, workingDir, maintenanceMode);
 | 
			
		||||
    Update update(hw, update_ctrl_file, workingDir, maintenanceMode, testMode);
 | 
			
		||||
    update.doUpdate();
 | 
			
		||||
    std::this_thread::sleep_for(std::chrono::milliseconds(2000));
 | 
			
		||||
    QCoreApplication::quit();
 | 
			
		||||
@@ -54,7 +54,7 @@ int main(int argc, char *argv[]) {
 | 
			
		||||
 | 
			
		||||
    QApplication a(argc, argv);
 | 
			
		||||
    QApplication::setApplicationName("ATBUpdateTool");
 | 
			
		||||
    QApplication::setApplicationVersion("1.0");
 | 
			
		||||
    QApplication::setApplicationVersion(APP_VERSION);
 | 
			
		||||
 | 
			
		||||
    if (!messageHandlerInstalled()) { // change internal qt-QDebug-handling
 | 
			
		||||
        atbInstallMessageHandler(atbDebugOutput);
 | 
			
		||||
@@ -92,6 +92,12 @@ int main(int argc, char *argv[]) {
 | 
			
		||||
        QCoreApplication::translate("main", "Maintenance mode for underlying script"));
 | 
			
		||||
    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:
 | 
			
		||||
    // add some additional parameters
 | 
			
		||||
    // --dry-run
 | 
			
		||||
@@ -106,6 +112,7 @@ int main(int argc, char *argv[]) {
 | 
			
		||||
    QString plugInName = parser.value(pluginNameOption);
 | 
			
		||||
    QString workingDir = parser.value(workingDirectoryOption);
 | 
			
		||||
    bool maintenanceMode = parser.isSet(maintenanceOption);
 | 
			
		||||
    bool testMode = parser.isSet(testOption);
 | 
			
		||||
    QString const rtPath = QCoreApplication::applicationDirPath();
 | 
			
		||||
 | 
			
		||||
    if (plugInDir == pluginDefault) {
 | 
			
		||||
@@ -121,6 +128,7 @@ int main(int argc, char *argv[]) {
 | 
			
		||||
    qInfo() << "plugInName" << "=" << plugInName;
 | 
			
		||||
    qInfo() << "workingDir" << "=" << workingDir;
 | 
			
		||||
    qInfo() << "maintenanceMode" << "=" << maintenanceMode;
 | 
			
		||||
    qInfo() << "testMode" << "=" << testMode;
 | 
			
		||||
 | 
			
		||||
    // before loading the library, delete all possible shared memory segments
 | 
			
		||||
#if defined Q_OS_LINUX || defined Q_OS_UNIX
 | 
			
		||||
@@ -130,10 +138,10 @@ int main(int argc, char *argv[]) {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    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";
 | 
			
		||||
    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();
 | 
			
		||||
    t.join();
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user