public
Created

Get Nodes - Python

  • Download Gist
gistfile1.py
Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
def get_manufacturing_nodes(URL, keydata, verbose=True):
""" Get the nodes from dedicated url.
Uses basic request
"""
URL_full = "%s%s?%s" % (URL, nodesTAG, keydata)
if verbose:
print "Getting Node catalog\n %s" % (URL_full)
req = Request(URL_full)
success, result = basic_request(req)
if not success:
# fail!!
if verbose: print "Error:", result
return (False, result)
else: # Success
nodes = json.loads(result[0])['nodes']
if verbose:
print "Response:\n %s" % (nodes)
# for each node
for i in range(len(nodes)):
print "Node name", nodes[i][u'name']
print " Last updated:", nodes[i][u'materials_updated_at']
print " node_key", nodes[i][u'key']
return (True, nodes)

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.