Mercurial > code > home > repos > homeauto
diff service/reasoning/rdflibtrig.py @ 240:0c306e76d8c5
ipv6 fetch support. refactor Actions to new class and file
Ignore-this: 200d7093919cf001706ad9c02347fabb
author | drewp@bigasterisk.com |
---|---|
date | Mon, 01 Feb 2016 03:28:17 -0800 |
parents | 5ad229334a88 |
children | e5c27d2f11ab |
line wrap: on
line diff
--- a/service/reasoning/rdflibtrig.py Mon Feb 01 03:09:08 2016 -0800 +++ b/service/reasoning/rdflibtrig.py Mon Feb 01 03:28:17 2016 -0800 @@ -1,16 +1,14 @@ -import re, time -import restkit -from rdflib.parser import StringInputSource +import time +import requests from rdflib import ConjunctiveGraph def addTrig(graph, url, timeout=2): t1 = time.time() - response = restkit.request(url, timeout=timeout) - if response.status_int != 200: + response = requests.get(url, stream=True, timeout=timeout) + if response.status_code != 200: raise ValueError("status %s from %s" % (response.status, url)) - trig = response.body_string() + g = ConjunctiveGraph() + g.parse(response.raw, format='trig') fetchTime = time.time() - t1 - g = ConjunctiveGraph() - g.parse(StringInputSource(trig), format='trig') graph.addN(g.quads()) return fetchTime