Created
January 18, 2012 00:05
-
-
Save dave5/1629913 to your computer and use it in GitHub Desktop.
Get Nodes - Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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