@@ -130,7 +130,6 @@ def __init__(
130
130
commandLineOptions : Optional [str ] = None ,
131
131
variableFilter : Optional [str ] = None ,
132
132
customBuildDirectory : Optional [str | os .PathLike ] = None ,
133
- verbose : bool = True ,
134
133
omhome : Optional [str ] = None ,
135
134
session : Optional [OMCSessionBase ] = None
136
135
):
@@ -157,7 +156,6 @@ def __init__(
157
156
customBuildDirectory: Path to a directory to be used for temporary
158
157
files like the model executable. If left unspecified, a tmp
159
158
directory will be created.
160
- verbose: If True, enable verbose logging.
161
159
omhome: OPENMODELICAHOME value to be used when creating the OMC
162
160
session.
163
161
session: OMC session to be used. If unspecified, a new session
@@ -187,8 +185,6 @@ def __init__(
187
185
self .linearstates = [] # linearization states list
188
186
self .tempdir = ""
189
187
190
- self ._verbose = verbose
191
-
192
188
if session is not None :
193
189
if not isinstance (session , OMCSessionZMQ ):
194
190
raise ModelicaSystemError ("Invalid session data provided!" )
@@ -314,12 +310,13 @@ def _run_cmd(self, cmd: list, timeout: Optional[int] = None):
314
310
timeout = timeout )
315
311
stdout = cmdres .stdout .strip ()
316
312
stderr = cmdres .stderr .strip ()
313
+
314
+ logger .debug ("OM output for command %s:\n %s" , cmd , stdout )
315
+
317
316
if cmdres .returncode != 0 :
318
317
raise ModelicaSystemError (f"Error running command { cmd } : nonzero return code" )
319
318
if stderr :
320
319
raise ModelicaSystemError (f"Error running command { cmd } : { stderr } " )
321
- if self ._verbose and stdout :
322
- logger .info ("OM output for command %s:\n %s" , cmd , stdout )
323
320
except subprocess .TimeoutExpired :
324
321
raise ModelicaSystemError (f"Timeout running command { repr (cmd )} " )
325
322
except Exception as ex :
@@ -335,8 +332,7 @@ def buildModel(self, variableFilter=None):
335
332
varFilter = 'variableFilter=".*"'
336
333
logger .debug ("varFilter=%s" , varFilter )
337
334
buildModelResult = self .requestApi ("buildModel" , self .modelName , properties = varFilter )
338
- if self ._verbose :
339
- logger .info ("OM model build result: %s" , buildModelResult )
335
+ logger .debug ("OM model build result: %s" , buildModelResult )
340
336
341
337
self .xmlFile = pathlib .Path (buildModelResult [0 ]).parent / buildModelResult [1 ]
342
338
self .xmlparse ()
@@ -346,6 +342,9 @@ def sendExpression(self, expr, parsed=True):
346
342
retval = self .getconn .sendExpression (expr , parsed )
347
343
except OMCSessionException as ex :
348
344
raise ModelicaSystemError (f"Error executing { repr (expr )} " ) from ex
345
+
346
+ logger .debug (f"Result of executing { repr (expr )} : { repr (retval )} " )
347
+
349
348
return retval
350
349
351
350
# request to OMC
@@ -838,12 +837,10 @@ def setParameters(self, pvals): # 14
838
837
def isParameterChangeable (self , name , value ):
839
838
q = self .getQuantities (name )
840
839
if q [0 ]["changeable" ] == "false" :
841
- if self ._verbose :
842
- logger .info ("setParameters() failed : It is not possible to set "
843
- f'the following signal "{ name } ", It seems to be structural, final, '
844
- "protected or evaluated or has a non-constant binding, use sendExpression("
845
- f"setParameterValue({ self .modelName } , { name } , { value } ), "
846
- "parsed=false) and rebuild the model using buildModel() API" )
840
+ logger .verbose (f"setParameters() failed : It is not possible to set the following signal { repr (name )} . "
841
+ "It seems to be structural, final, protected or evaluated or has a non-constant binding, "
842
+ f"use sendExpression(\" setParameterValue({ self .modelName } , { name } , { value } )\" , "
843
+ "parsed=False) and rebuild the model using buildModel() API" )
847
844
return False
848
845
return True
849
846
0 commit comments