Strabon

annotate scripts/example-query.py @ 916:b58aa113f25e

added query alias "all" for returning all triples
author Babis Nikolaou <charnik@di.uoa.gr>
date Sun Mar 24 23:33:02 2013 +0200 (2013-03-24)
parents
children
rev   line source
kkyzir@126 1 #!/usr/bin/env python
kkyzir@126 2
kkyzir@126 3 import sys, re, os
kkyzir@126 4 import os
kkyzir@126 5 import glob
kkyzir@126 6 import time
kkyzir@126 7 import shutil
kkyzir@126 8 import httplib, urllib
kkyzir@126 9
kkyzir@126 10 def main(argv):
kkyzir@126 11
kkyzir@126 12 query = 'PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX strdf: <http://strdf.di.uoa.gr/ontology#> PREFIX noa: <http://teleios.di.uoa.gr/ontologies/noaOntology.owl#> SELECT ?H (strdf:transform(?HGEO, <http://www.opengis.net/def/crs/EPSG/0/4326>) AS ?GEO) WHERE { ?H rdf:type noa:Hotspot . ?H noa:hasAcquisitionTime ?HAT . FILTER(str(?HAT) = "2010-08-21T21:20:00") . ?H noa:isDerivedFromSensor ?HS . FILTER(str(?HS) = "MSG1_RSS" ) . ?H noa:hasGeometry ?HGEO . }'
kkyzir@126 13 params = urllib.urlencode({'SPARQLQuery': query, 'format': "XML"})
kkyzir@126 14 headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/xml"}
kkyzir@126 15
kkyzir@126 16 #conn = httplib.HTTPConnection("papos.space.noa.gr:8080")
kkyzir@126 17 #conn.request("POST", "/endpoint/Query", params, headers)
kkyzir@126 18
kkyzir@126 19 conn = httplib.HTTPConnection("test.strabon.di.uoa.gr")
kkyzir@126 20 conn.request("POST", "/NOA/Query", params, headers)
kkyzir@126 21
kkyzir@126 22 response = conn.getresponse()
kkyzir@126 23 print response.status, response.reason
kkyzir@126 24 print response.msg
kkyzir@126 25 print response.read()
kkyzir@126 26 return 0
kkyzir@126 27
kkyzir@126 28 if __name__ == "__main__":
kkyzir@126 29 sys.exit(main(sys.argv))