Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Get Nodes - Python
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment