Mercurial > code > home > repos > homeauto
comparison service/environment/environment.py @ 1537:f119ed48194b
cors support
Ignore-this: 8f628d753d9770b3b9b22be1194f3307
darcs-hash:d277bc36a7c9d5a672bf326f43ece710ec75c6ca
author | drewp <drewp@bigasterisk.com> |
---|---|
date | Mon, 10 Feb 2020 00:03:11 -0800 |
parents | 13b7e4de3824 |
children | 4167101b816f |
comparison
equal
deleted
inserted
replaced
1536:2e61abb70323 | 1537:f119ed48194b |
---|---|
12 from rdflib import Namespace, Literal | 12 from rdflib import Namespace, Literal |
13 from greplin import scales | 13 from greplin import scales |
14 from greplin.scales.cyclonehandler import StatsHandler | 14 from greplin.scales.cyclonehandler import StatsHandler |
15 from patchablegraph import PatchableGraph, CycloneGraphEventsHandler, CycloneGraphHandler | 15 from patchablegraph import PatchableGraph, CycloneGraphEventsHandler, CycloneGraphHandler |
16 from twilight import isWithinTwilight | 16 from twilight import isWithinTwilight |
17 from logsetup import log, enableTwistedLog | 17 from standardservice.logsetup import log, verboseLogging |
18 | 18 |
19 from rdfdoc import Doc | 19 from rdfdoc import Doc |
20 | 20 |
21 ROOM = Namespace("http://projects.bigasterisk.com/room/") | 21 ROOM = Namespace("http://projects.bigasterisk.com/room/") |
22 DEV = Namespace("http://projects.bigasterisk.com/device/") | 22 DEV = Namespace("http://projects.bigasterisk.com/device/") |
23 | 23 |
24 STATS = scales.collection('/root', | 24 STATS = scales.collection('/root', |
25 scales.PmfStat('update'), | 25 scales.PmfStat('update'), |
26 ) | 26 ) |
27 | |
28 class CycloneGraphEventsHandlerWithCors(CycloneGraphEventsHandler): | |
29 def flush(self): | |
30 self.set_header("Access-Control-Allow-Origin", "*") | |
31 return CycloneGraphEventsHandler.flush(self) | |
32 | |
27 | 33 |
28 @STATS.update.time() | 34 @STATS.update.time() |
29 def update(masterGraph): | 35 def update(masterGraph): |
30 stmt = lambda s, p, o: masterGraph.patchObject(ROOM.environment, s, p, o) | 36 stmt = lambda s, p, o: masterGraph.patchObject(ROOM.environment, s, p, o) |
31 | 37 |