comparison service/reasoning/reasoning.py @ 600:a34dee00a989

comments and logging Ignore-this: 75df9bd5008caef0fd53eaa811f1500a
author drewp@bigasterisk.com
date Tue, 23 Jul 2019 10:16:59 -0700
parents 53a2664f450a
children 62171aa2bc4e
comparison
equal deleted inserted replaced
599:c5a20d0df4ed 600:a34dee00a989
17 from crochet import no_setup 17 from crochet import no_setup
18 no_setup() 18 no_setup()
19 19
20 import json, time, traceback, sys 20 import json, time, traceback, sys
21 from logging import getLogger, DEBUG, WARN 21 from logging import getLogger, DEBUG, WARN
22 sys.path.append('/opt') # docker is putting lib/ here
23 22
24 from colorlog import ColoredFormatter 23 from colorlog import ColoredFormatter
25 from docopt import docopt 24 from docopt import docopt
26 from rdflib import Namespace, Literal, RDF, Graph 25 from rdflib import Namespace, Literal, RDF, Graph
27 from twisted.internet import reactor, task, defer 26 from twisted.internet import reactor, task, defer
33 32
34 from inference import infer, readRules 33 from inference import infer, readRules
35 from actions import Actions 34 from actions import Actions
36 from inputgraph import InputGraph 35 from inputgraph import InputGraph
37 from escapeoutputstatements import unquoteOutputStatements 36 from escapeoutputstatements import unquoteOutputStatements
38 37
39 from standardservice.logsetup import log 38 from standardservice.logsetup import log, verboseLogging
40 39
41 40
42 ROOM = Namespace("http://projects.bigasterisk.com/room/") 41 ROOM = Namespace("http://projects.bigasterisk.com/room/")
43 DEV = Namespace("http://projects.bigasterisk.com/device/") 42 DEV = Namespace("http://projects.bigasterisk.com/device/")
44 43
269 cyclone.web.Application.__init__(self, handlers, reasoning=reasoning) 268 cyclone.web.Application.__init__(self, handlers, reasoning=reasoning)
270 269
271 def configLogging(arg): 270 def configLogging(arg):
272 log.setLevel(WARN) 271 log.setLevel(WARN)
273 272
274 if arg['-i'] or arg['-r'] or arg['-o']: 273 if arg['-i'] or arg['-r'] or arg['-o'] or arg['-v']:
275 log.handlers[0].setFormatter(ColoredFormatter("%(log_color)s%(levelname)-8s %(name)-6s %(filename)-12s:%(lineno)-3s %(funcName)-20s%(reset)s %(white)s%(message)s", 274 log.handlers[0].setFormatter(ColoredFormatter("%(log_color)s%(levelname)-8s %(name)-6s %(filename)-12s:%(lineno)-3s %(funcName)-20s%(reset)s %(white)s%(message)s",
276 datefmt=None, 275 datefmt=None,
277 reset=True, 276 reset=True,
278 log_colors={ 277 log_colors={
279 'DEBUG': 'cyan', 278 'DEBUG': 'cyan',
302 Usage: reasoning.py [options] 301 Usage: reasoning.py [options]
303 302
304 -i Verbose log on the input phase 303 -i Verbose log on the input phase
305 -r Verbose log on the reasoning phase and web stuff 304 -r Verbose log on the reasoning phase and web stuff
306 -o Verbose log on the actions/output phase 305 -o Verbose log on the actions/output phase
306 -v Everywhere verbose
307 """) 307 """)
308 308
309 r = Reasoning() 309 r = Reasoning()
310 configLogging(arg) 310 configLogging(arg)
311 reactor.listenTCP(9071, Application(r), interface='::') 311 reactor.listenTCP(9071, Application(r), interface='::')