Mercurial > code > home > repos > homeauto
diff service/store/store.py @ 1453:ea942d383f62
index page is a data browser. support for -v
Ignore-this: cbe181b141420e0d6872203e4738f86f
darcs-hash:ddf89fabcec49046d70987597a5b421a415e2335
author | drewp <drewp@bigasterisk.com> |
---|---|
date | Wed, 25 Sep 2019 17:29:12 -0700 |
parents | 1431cd58803d |
children | 281be4651a2f |
line wrap: on
line diff
--- a/service/store/store.py Wed Sep 25 17:28:38 2019 -0700 +++ b/service/store/store.py Wed Sep 25 17:29:12 2019 -0700 @@ -15,12 +15,10 @@ from twisted.internet import reactor from twisted.python.filepath import FilePath import cyclone.web +from standardservice.logsetup import log, verboseLogging ROOM = Namespace('http://projects.bigasterisk.com/room/') -logging.basicConfig() -log = logging.getLogger() - CTX = ROOM['stored'] class ValuesResource(cyclone.web.RequestHandler): @@ -40,7 +38,7 @@ except ValueError: obj = Literal(turtleLiteral) self._onStatements([(subj, pred, obj)]) - + def _onGraphBodyStatements(self, body, headers): # maybe quads only so we can track who made the input and from what interface? # Or your input of triples gets wrapped in a new quad in here? @@ -49,7 +47,7 @@ if not g: raise ValueError("expected graph body") self._onStatements(list(g.triples((None, None, None)))) - + def _onStatements(self, stmts): g = self.settings.masterGraph for s, p, o in stmts: @@ -59,24 +57,20 @@ g.patch(patch) nquads = g.serialize(None, format='nquads') self.settings.dbFile.setContent(nquads) - + if __name__ == '__main__': arg = docopt(""" Usage: store.py [options] -v Verbose """) - log.setLevel(logging.WARN) - if arg['-v']: - from twisted.python import log as twlog - twlog.startLogging(sys.stdout) - log.setLevel(logging.DEBUG) + verboseLogging(arg['-v']) masterGraph = PatchableGraph() dbFile = FilePath('/opt/homeauto_store/db.nquads') if dbFile.exists(): masterGraph._graph.parse(dbFile.open(), format='nquads') - + port = 10015 reactor.listenTCP(port, cyclone.web.Application([ (r"/()", cyclone.web.StaticFileHandler,