This archive is retained to ensure existing URLs remain functional. It will not contain any emails sent to this mailing list after July 1, 2024. For all messages, including those sent before and after this date, please visit the new location of the archive at https://mailman.ripe.net/archives/list/ripe-atlas@ripe.net/
[atlas] Problems with DNS measurements and NSID
- Previous message (by thread): [atlas] Problems with DNS measurements and NSID
- Next message (by thread): [atlas] Problems with DNS measurements and NSID
Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Klaus Darilion
klaus.mailinglists at pernau.at
Wed May 21 10:07:04 CEST 2014
Hi Daniel! Thanks. Meanwhile I managed to iterate over the JSON list and print the nsid: import json from ripe.atlas.sagan import DnsResult f=open("dns-from-de-anycast.json","r") data = f.read() jdata = json.loads(data) for d in jdata: print d result = DnsResult.get(d) print(result.responses[0].edns0.options[0].nsid) print "" But the problem is if there was an error during the measurement (eg timeout), then my script terminates: {u'from': u'84.132.219.105', u'msm_id': 1666006, u'timestamp': 1400570732, u'fw': 4610, u'proto': u'UDP', u'af': 4, u'msm_name': u'Tdig', u'prb_id': 2960, u'error': {u'timeout': 5000}, u'src_addr': u'192.168.179.20', u'group_id': 1666005, u'type': u'dns', u'dst_addr': u'194.0.25.16'} Traceback (most recent call last): File "json-file.py", line 11, in <module> print(result.responses[0].edns0.options[0].nsid) IndexError: list index out of range What is the suggested way to find out if a result is valid and exists? Thanks Klaus On 20.05.2014 17:47, Daniel Quinn wrote: > On Tue 20 May 2014 17:08:47 CEST, Klaus Darilion wrote: > > Hi Daniel! > > Hi! > > Actually I tried it today but failed obviously due to my lack of Python. > It would be great if you could add an example to the README e.g. with > full result parsing: > > * load the json file from disk > * loop over every result (json list) > * print some value > > The full documentation already has a few examples > <https://atlas.ripe.net/docs/sagan/#examples> that should be enough to > get you going (I’ve just added some more), but here’s a breakdown of > what you’re wanting: > > |from ripe.atlas.sagan import Result > > my_results_file = "/path/to/file.txt" > with open(my_results_file) as results: > for result in results.readlines(): > parsed_result = Result.get(result) > print(parsed_result.origin) > | > > Once you have a |parsed_result|, you have access to all of the > properties of that result, which are defined in the full documentation > <https://atlas.ripe.net/docs/sagan/#attributes-methods>. > > Why do I have to use the responses[0] object? Can there be multiple > responses with different nsids? > > In some cases, DNS results /can/ contain multiple responses. In an > effort to maintain consistency for all DNS results, we opted to treat > all DNS results as if they contain a list of responses — even if that > list is of only one response. This makes it easier to write scripts that > make use of the object, since you always have a consistent data type in > |parsed_result.responses|. > > I hope that helps! >
- Previous message (by thread): [atlas] Problems with DNS measurements and NSID
- Next message (by thread): [atlas] Problems with DNS measurements and NSID
Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]