-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use logging in modelica system syntron #228
Use logging in modelica system syntron #228
Conversation
Yes, please rebase this on master so the external dll path commits are not included. |
3e16a13
to
7916694
Compare
Rebased to master (as #226 is included now) |
OMPython/__init__.py
Outdated
## Show notification or warnings to the user when verbose=True OR if some error occurred i.e., not result | ||
if verbose or not result: | ||
print(self.requestApi('getErrorString')) | ||
if not result: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check for self._verbose
flag here. loadLibrary
raises some warnings and notifications that are good to know specially when verbose
is set.
OMPython/__init__.py
Outdated
if verbose: | ||
print("| info | setParameters() failed : It is not possible to set the following signal " + "\"" + name + "\"" + ", It seems to be structural, final, protected or evaluated or has a non-constant binding, use sendExpression(setParameterValue("+ self.modelName + ", " + name + ", " + value + "), parsed=false)" + " and rebuild the model using buildModel() API") | ||
if self._verbose: | ||
logger.warning("setParameters() failed : It is not possible to set " + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be logger.info
OMPython/__init__.py
Outdated
if self._raiseerrors: | ||
raise ModelicaSystemError("OM error: {}".format(errstr)) | ||
else: | ||
logger.warning(errstr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be logger.error
* this simplifies a lot of functions!
* class variable _raiseerrors * functions _check_error() & _raise_error()
8d412f2
to
f23c7f6
Compare
@adeas31 update based on your comments |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
OMPython/__init__.py
Outdated
loadMsg = self.getconn.sendExpression(loadFileExp) | ||
## Show notification or warnings to the user when verbose=True OR if some error occurred i.e., not result | ||
if verbose or not loadMsg: | ||
return print(self.getconn.sendExpression("getErrorString()")) | ||
if not loadMsg: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forgot to add check for self._verbose
flag here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in an added commit; see below ...
@arun3688 can you please review and test it. |
Update ModelicaSystem to use Exceptions / the python logging interface (see #227)
It is based on #226 due to the develop history; if needed it could be rebased or parts could be extracted