Mercurial > code > home > repos > light9
annotate bin/clientdemo @ 2050:7ed414bdaab9
wip porting asco to TS and not-jquery
author | drewp@bigasterisk.com |
---|---|
date | Wed, 11 May 2022 00:07:13 -0700 |
parents | f066d6e874db |
children |
rev | line source |
---|---|
796 | 1 #!bin/python |
2 | |
3 import os, sys | |
4 sys.path.append(".") | |
5 from twisted.internet import reactor | |
6 import cyclone.web, cyclone.httpclient, logging | |
798
5c158d37f1ce
autoretry websocket. fix rdflib quad patching. only rerun handlers that asked for the affected subj-preds.
drewp@bigasterisk.com
parents:
797
diff
changeset
|
7 from rdflib import Namespace, Literal, URIRef |
1114
a38955ba6f40
rdfdb port is now in the config
Drew Perttula <drewp@bigasterisk.com>
parents:
798
diff
changeset
|
8 from light9 import networking |
1692 | 9 from rdfdb.patch import Patch |
10 from rdfdb.syncedgraph import SyncedGraph | |
796 | 11 |
12 if __name__ == "__main__": | |
13 logging.basicConfig(level=logging.DEBUG) | |
14 log = logging.getLogger() | |
15 | |
1114
a38955ba6f40
rdfdb port is now in the config
Drew Perttula <drewp@bigasterisk.com>
parents:
798
diff
changeset
|
16 g = SyncedGraph(networking.rdfdb.url, "clientdemo") |
796 | 17 |
798
5c158d37f1ce
autoretry websocket. fix rdflib quad patching. only rerun handlers that asked for the affected subj-preds.
drewp@bigasterisk.com
parents:
797
diff
changeset
|
18 from light9.Submaster import PersistentSubmaster |
1858 | 19 sub = PersistentSubmaster( |
20 graph=g, uri=URIRef("http://light9.bigasterisk.com/sub/bcools")) | |
798
5c158d37f1ce
autoretry websocket. fix rdflib quad patching. only rerun handlers that asked for the affected subj-preds.
drewp@bigasterisk.com
parents:
797
diff
changeset
|
21 |
5c158d37f1ce
autoretry websocket. fix rdflib quad patching. only rerun handlers that asked for the affected subj-preds.
drewp@bigasterisk.com
parents:
797
diff
changeset
|
22 #get sub to show its updating name, then push that all the way into KC gui so we can see just names refresh in there |
5c158d37f1ce
autoretry websocket. fix rdflib quad patching. only rerun handlers that asked for the affected subj-preds.
drewp@bigasterisk.com
parents:
797
diff
changeset
|
23 |
1858 | 24 L9 = Namespace("http://light9.bigasterisk.com/") |
798
5c158d37f1ce
autoretry websocket. fix rdflib quad patching. only rerun handlers that asked for the affected subj-preds.
drewp@bigasterisk.com
parents:
797
diff
changeset
|
25 |
796 | 26 def updateDemoValue(): |
27 v = list(g.objects(L9['demo'], L9['is'])) | |
1859
f066d6e874db
2to3 with these fixers: all idioms set_literal
drewp@bigasterisk.com
parents:
1858
diff
changeset
|
28 print("demo value is %r" % v) |
796 | 29 |
30 g.addHandler(updateDemoValue) | |
31 | |
32 def adj(): | |
1858 | 33 g.patch( |
34 Patch(addQuads=[(L9['demo'], L9['is'], Literal(os.getpid()), | |
35 L9['clientdemo'])], | |
36 delQuads=[])) | |
37 | |
796 | 38 reactor.callLater(2, adj) |
39 reactor.run() |