SDS via Python
2008-11-06 @ 01:52#
i got bored this evening and decided to whip up a simple python script to pull data from SDS data stores. the following script is very small; no error-handling; not properly formatted, etc. but it shows how easy it is to access SDS data via their REST interface using python.
i did this using Active Python running on Windows XP. other flavors should run just fine.
# 2008-11-06 (mca) : access SDS via python # # usage: sds-query.py "username:password" "/authority/container/entity" # import sys, httplib, urllib, binascii a1 = sys.argv[1] a2 = sys.argv[2] # create headers u = binascii.b2a_base64(a1)[:-1] b = "Basic %s" % u h = {"Accept":"application/x-ssds+xml","Authorization":b} # do call to sds proxy q = "/sds-proxy%s" % a2 c = httplib.HTTPConnection("amundsen.com") c.request("GET",q,"",h) r = c.getresponse() print r.read() c.close() # eof