# HG changeset patch # User drewp # Date 1580802315 28800 # Node ID 9733063421e1126616cb46272f606b8e8ed1fdb5 # Parent 2b6e939c8b100aea38e70cb8d68e96eec9935f37 add browser_test server for playing with /graph resource Ignore-this: 6112c234b93e0fb99ffe918a022e5a49 darcs-hash:fa614cb62e50d73e2e2f02ad79ec4c497cea8cbc diff -r 2b6e939c8b10 -r 9733063421e1 lib/patchablegraph/Dockerfile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/patchablegraph/Dockerfile Mon Feb 03 23:45:15 2020 -0800 @@ -0,0 +1,18 @@ +FROM bang6:5000/base_x86 + +WORKDIR /opt + +COPY browser_test_requirements.txt ./ + +RUN pip3 install --index-url https://projects.bigasterisk.com/ --extra-index-url https://pypi.org/simple -r browser_test_requirements.txt +# not sure why this doesn't work from inside requirements.txt +RUN pip3 install --index-url https://projects.bigasterisk.com/ --extra-index-url https://pypi.org/simple -U 'https://github.com/drewp/cyclone/archive/python3.zip?v2' + +COPY ./patchablegraph.py ./patchsource.py ./setup.py __init__.py patchablegraph/ +RUN pip3 install patchablegraph/ + +COPY browser_test.py ./ + +EXPOSE 8021 + +CMD [ "python3", "browser_test.py" ] diff -r 2b6e939c8b10 -r 9733063421e1 lib/patchablegraph/browser_test.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/patchablegraph/browser_test.py Mon Feb 03 23:45:15 2020 -0800 @@ -0,0 +1,33 @@ +""" +see how a browser talks to this PatchableGraph +""" + +from rdflib import Namespace, Literal, ConjunctiveGraph, URIRef, RDF +from twisted.internet import reactor +import cyclone.web + +from standardservice.logsetup import log, verboseLogging +from patchablegraph import PatchableGraph, CycloneGraphEventsHandler, CycloneGraphHandler + +verboseLogging(True) + +graph = PatchableGraph() +g = ConjunctiveGraph() +g.add((URIRef('http://example.com/s'), + URIRef('http://example.com/p'), + URIRef('http://example.com/o'), + URIRef('http://example.com/g'))) +graph.setToGraph(g) + +class Application(cyclone.web.Application): + def __init__(self): + handlers = [ + (r'/graph', CycloneGraphHandler, {'masterGraph': graph}), + (r'/graph/events', CycloneGraphEventsHandler, + {'masterGraph': graph}), + ] + cyclone.web.Application.__init__(self, handlers) + + +reactor.listenTCP(8021, Application()) +reactor.run() diff -r 2b6e939c8b10 -r 9733063421e1 lib/patchablegraph/browser_test_requirements.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/patchablegraph/browser_test_requirements.txt Mon Feb 03 23:45:15 2020 -0800 @@ -0,0 +1,10 @@ +rdflib==4.2.2 +Twisted +cyclone + +https://github.com/drewp/cyclone/archive/python3.zip + +twisted_sse==0.3.0 +cycloneerr +rdfdb==0.8.0 +standardservice==0.4.0 diff -r 2b6e939c8b10 -r 9733063421e1 lib/patchablegraph/tasks.py --- a/lib/patchablegraph/tasks.py Mon Feb 03 22:08:54 2020 -0800 +++ b/lib/patchablegraph/tasks.py Mon Feb 03 23:45:15 2020 -0800 @@ -7,3 +7,18 @@ @task def release(ctx): local_release(ctx) + +@task +def browser_test_build(ctx): + ctx.run(f'docker build --network=host -t bang:5000/patchable_graph_browser_test .') + +@task(pre=[browser_test_build]) +def browser_test(ctx): + ctx.run(f'docker run ' + f'--name patchable_graph_browser_test ' + f'--rm -it ' + f'--net=host ' + f'-v `pwd`:/opt ' + f'bang:5000/patchable_graph_browser_test ' + f'/bin/bash' #f'python3 browser_test.py', + pty=True)