Skip to content

Instantly share code, notes, and snippets.

@dave5
Created January 18, 2012 00:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dave5/1629913 to your computer and use it in GitHub Desktop.
Save dave5/1629913 to your computer and use it in GitHub Desktop.
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