@@ -35,7 +35,7 @@ from installer.constants import (MODE_ALL, MODE_COMPILE_AND_INSTALL, MODE_CONFIG
3535 PARAM_JOBS , PARAM_BRANCH , PARAM_GIT_COMMAND , PARAM_TEST_PRO , PARAM_TEST_PRO , PARAM_TEST_FUNC , PARAM_MODEL_PATH ,
3636 PARAM_MODELS_DIRECTORY , PARAM_KEEP_OUTPUT , PARAM_SHOW_TESTS , PARAM_TEST_NAME , PARAM_UPDATE ,
3737 PARAM_OVERWRITE , BUILD_PATH , INSTALL_PATH , BUILD_TYPE , SOURCES_PATH , XMIPP_SOURCES , XMIPP ,
38- LOG_FILE , CMAKE_ERROR , MODE_GET_SOURCES , VERSION_FILE , PARAMS , LONG_VERSION , SHORT_VERSION )
38+ LOG_FILE , CMAKE_ERROR , MODE_GET_SOURCES , VERSION_FILE , PARAMS , LONG_VERSION , SHORT_VERSION , SEND_INSTALLATION_STATISTICS )
3939from installer .utils import runStreamingJob , runJob
4040from installer .parser import ModeHelpFormatter , GeneralHelpFormatter , ErrorHandlerArgumentParser , getParamNames
4141from installer .config import readConfig , writeConfig
@@ -122,22 +122,25 @@ def modeCompileAndInstall(args: argparse.Namespace, configDict: Dict={}):
122122 logger .startLogFile (LOG_FILE )
123123 configDict = readConfig (CONFIG_FILE )
124124 if not getCMake (configDict ):
125- handleRetCode (CMAKE_ERROR , predefinedErrorCode = CMAKE_ERROR )
125+ apiPost = True if configDict .get (SEND_INSTALLATION_STATISTICS ) == 'ON' else False
126+ handleRetCode (CMAKE_ERROR , predefinedErrorCode = CMAKE_ERROR , sendAPI = apiPost )
126127
127128 # Compile with CMake
128129 cmakeExecutable = getCMake (configDict )
129130 logger (getSectionMessage ("Compiling with CMake" ), forceConsoleOutput = True )
130131 retCode = runStreamingJob (f"{ cmakeExecutable } --build { BUILD_PATH } --config { BUILD_TYPE } -j { args .jobs } " ,
131132 showOutput = True , substitute = True )
132- handleRetCode (retCode , predefinedErrorCode = CMAKE_COMPILE_ERROR )
133+ apiPost = True if configDict .get (
134+ SEND_INSTALLATION_STATISTICS ) == 'ON' else False
135+ handleRetCode (retCode , predefinedErrorCode = CMAKE_COMPILE_ERROR , sendAPI = apiPost )
133136
134137 # Install with CMake
135138 logger (getSectionMessage ("Installing with CMake" ), forceConsoleOutput = True )
136139 retCode = runStreamingJob (f"{ cmakeExecutable } --install { BUILD_PATH } --config { BUILD_TYPE } " ,
137140 showOutput = True , substitute = True )
138- handleRetCode (retCode , predefinedErrorCode = CMAKE_INSTALL_ERROR )
141+ handleRetCode (retCode , predefinedErrorCode = CMAKE_INSTALL_ERROR , sendAPI = apiPost )
139142
140- def modeConfigBuild (configDict : Dict = {}):
143+ def modeConfigBuild (configDict : Dict = {}, sendAPIPost : bool = False ):
141144 """
142145 ### Configures the project using CMake.
143146
@@ -153,13 +156,13 @@ def modeConfigBuild(configDict: Dict={}):
153156 # Check if CMake exists
154157 cmakeExecutable = getCMake (configDict )
155158 if not getCMake (configDict ):
156- handleRetCode (CMAKE_ERROR , predefinedErrorCode = CMAKE_ERROR )
159+ handleRetCode (CMAKE_ERROR , predefinedErrorCode = CMAKE_ERROR , sendAPI = sendAPIPost )
157160
158161 logger (getSectionMessage ("Configuring with CMake" ), forceConsoleOutput = True )
159162 configureCmd = f"{ cmakeExecutable } -S . -B { BUILD_PATH } -D CMAKE_BUILD_TYPE={ BUILD_TYPE } "
160163 configureCmd += f" { getCMakeVarsStr (configDict )} "
161164 retCode = runStreamingJob (configureCmd , showOutput = True , substitute = True )
162- handleRetCode (retCode , predefinedErrorCode = CMAKE_CONFIGURE_ERROR )
165+ handleRetCode (retCode , predefinedErrorCode = CMAKE_CONFIGURE_ERROR , sendAPI = sendAPIPost )
163166
164167def modeConfig (overwrite : bool = False ) -> Dict :
165168 """
@@ -232,7 +235,6 @@ def modeTest(args: argparse.Namespace):
232235 logger ("Running all tests--------------------------------------" , forceConsoleOutput = True )
233236 runTests (PARAMS [PARAM_TEST_PRO ][LONG_VERSION ])
234237 elif args .allFuncs :
235- print (args .allPrograms )
236238 runTests (PARAMS [PARAM_TEST_FUNC ][LONG_VERSION ])
237239
238240 elif args .testName :
@@ -265,7 +267,7 @@ def modeAll(args: argparse.Namespace):
265267 modeGetSources (args )
266268
267269 # Configure with CMake
268- modeConfigBuild (configDict = configDict )
270+ modeConfigBuild (configDict = configDict , sendAPIPost = True )
269271
270272 # Compile and install with CMake
271273 modeCompileAndInstall (args , configDict = configDict )
@@ -282,8 +284,8 @@ def runSelectedMode(parser: ErrorHandlerArgumentParser, args: argparse.Namespace
282284 if args .mode == MODE_ADD_MODEL :
283285 modeAddModel (args )
284286 elif args .mode == MODE_ALL :
285- modeAll (args )
286287 sendAPI = True
288+ modeAll (args )
287289 elif args .mode == MODE_CLEAN_ALL :
288290 modeCleanAll ()
289291 elif args .mode == MODE_CLEAN_BIN :
@@ -292,8 +294,8 @@ def runSelectedMode(parser: ErrorHandlerArgumentParser, args: argparse.Namespace
292294 modeCompileAndInstall (args )
293295 sendAPI = True
294296 elif args .mode == MODE_CONFIG_BUILD :
295- modeConfigBuild ()
296297 sendAPI = True
298+ modeConfigBuild ()
297299 elif args .mode == MODE_CONFIG :
298300 modeConfig (overwrite = args .overwrite )
299301 elif args .mode == MODE_GET_MODELS :
@@ -312,7 +314,9 @@ def runSelectedMode(parser: ErrorHandlerArgumentParser, args: argparse.Namespace
312314 exitXmipp (retCode = 1 )
313315
314316 # Send API message
315- if sendAPI and os .path .exists (VERSION_FILE ):
317+ apiPost = True if readConfig (CONFIG_FILE ).get (
318+ SEND_INSTALLATION_STATISTICS ) == 'ON' else False
319+ if sendAPI and apiPost and os .path .exists (VERSION_FILE ):
316320 sendApiPOST ()
317321
318322 # Print success message for specific modes
0 commit comments