-
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
jsnapy as a python module: how to retrieve the ERROR: and FAIL | messages #231
Comments
Hi @nskalis As of today we don't provide the message as part of json data being returned. Adding messages to json was making json look very odd (even with pretty print). Hence we removed it. |
@vnitinv thanks for looking into it, although i did not update jsnapy today. so in that case, if a test case fails, and we do not know what is the error message or where exactly it failed, why ti would be useful ? |
Hi @nskalis If you want the formatted error string while using module version, you can use the following code. import sys
from StringIO import StringIO
old_stdout = sys.stdout
sys.stdout = mystdout = StringIO()
sys.stderr = mystdout
from jnpr.jsnapy import SnapAdmin
from pprint import pprint
from jnpr.junos import Device
js = SnapAdmin()
...
snapvalue = js.snapcheck(config_file, "snap")
sys.stdout = old_stdout
print(mystdout.getvalue()) Replace the If you don't want to do that, you can apply the patch from this pull request . This is not merged into master because of the reasons mentioned above by @vnitinv. This also doesn't suit your needs to extract element level error messages as only top level messages are captured by the pull request |
@eeishaan @vnitinv hmm.. but I can follow the same approach using the original JSNAP utility, which by the way honours the err and info messages instead of mentioning a dict-key. If you could work on it and improve JSNAPy in the user-friendliness that would be great. Also, I have opened 2-3 another issues 1 month ago that are still in Open status. I am working already with the JSNAP version of my configuration file. I would like JSNAP to be more delicate in the stdout messages and display only the error messages, but unfortunately this is not valid at the moment. On the other hand, JSNAPy is not better at that. |
@nskalis Duly noted. We understand that our response dictionary is not the prettiest thing and difficult to use. We will be addressing this in upcoming releases. |
I was having the err message issue. Below is my test file and as you can see, I have mentioned err message in it. But Jsnapy is not printing that error message instead I am getting error message:
|
Hi,
I would like to use jsnapy as a python module,
when I run
or
there are messages in standard output being printed (I am mostly interested in the error messages), for example,
If I look into
xx[0].test_details['show bgp summary']
there is no such error message,could you please advise on how-to retrieve the error messages ?
Many Thanks.
Nikos
The text was updated successfully, but these errors were encountered: