Files
@ 02f74275a21f
Branch filter:
Location: light9/bin/vidrefsetup - annotation
02f74275a21f
2.7 KiB
text/plain
effectclass mappings
Ignore-this: 14c6fb4e7497f5014f3c59f250c7dfbd
Ignore-this: 14c6fb4e7497f5014f3c59f250c7dfbd
087f6cbe4b22 087f6cbe4b22 087f6cbe4b22 087f6cbe4b22 087f6cbe4b22 087f6cbe4b22 087f6cbe4b22 087f6cbe4b22 087f6cbe4b22 087f6cbe4b22 087f6cbe4b22 087f6cbe4b22 087f6cbe4b22 087f6cbe4b22 087f6cbe4b22 087f6cbe4b22 087f6cbe4b22 087f6cbe4b22 087f6cbe4b22 087f6cbe4b22 087f6cbe4b22 087f6cbe4b22 087f6cbe4b22 087f6cbe4b22 087f6cbe4b22 087f6cbe4b22 087f6cbe4b22 087f6cbe4b22 087f6cbe4b22 087f6cbe4b22 087f6cbe4b22 087f6cbe4b22 087f6cbe4b22 087f6cbe4b22 087f6cbe4b22 087f6cbe4b22 087f6cbe4b22 087f6cbe4b22 087f6cbe4b22 087f6cbe4b22 087f6cbe4b22 087f6cbe4b22 087f6cbe4b22 087f6cbe4b22 087f6cbe4b22 087f6cbe4b22 087f6cbe4b22 087f6cbe4b22 087f6cbe4b22 087f6cbe4b22 087f6cbe4b22 087f6cbe4b22 087f6cbe4b22 087f6cbe4b22 a38955ba6f40 087f6cbe4b22 087f6cbe4b22 087f6cbe4b22 087f6cbe4b22 087f6cbe4b22 087f6cbe4b22 087f6cbe4b22 087f6cbe4b22 087f6cbe4b22 087f6cbe4b22 087f6cbe4b22 087f6cbe4b22 087f6cbe4b22 087f6cbe4b22 087f6cbe4b22 | #!bin/python
""" this should be part of vidref, but I haven't worked out sharing
camera captures with a continuous camera capture yet """
from run_local import log
import sys, optparse, logging, json, subprocess, datetime
from dateutil.tz import tzlocal
from twisted.internet import reactor, defer
import cyclone.web, cyclone.httpclient, cyclone.websocket
from rdflib import RDF, URIRef, Literal
import pyjade.utils
from light9.rdfdb.syncedgraph import SyncedGraph
from light9.rdfdb.patch import Patch
from light9.namespaces import L9, DCTERMS
from light9 import networking, showconfig
from lib.cycloneerr import PrettyErrorHandler
class RedirToCamera(PrettyErrorHandler, cyclone.web.RequestHandler):
def get(self):
return self.redirect(networking.picamserve.path(
'pic?' + self.request.query))
class UrlToCamera(PrettyErrorHandler, cyclone.web.RequestHandler):
def get(self):
self.set_header('Content-Type', 'text/plain')
self.write(networking.picamserve.path('pic'))
class VidrefCamRequest(PrettyErrorHandler, cyclone.web.RequestHandler):
def get(self):
graph = self.settings.graph
show = showconfig.showUri()
with graph.currentState(tripleFilter=(show, None, None)) as g:
ret = g.value(show, L9['vidrefCamRequest'])
if ret is None:
self.send_error(404)
self.redirect(ret)
def put(self):
graph = self.settings.graph
show = showconfig.showUri()
graph.patchObject(context=URIRef(show + '/vidrefConfig'),
subject=show,
predicate=L9['vidrefCamRequest'],
newObject=URIRef(self.get_argument('uri')))
self.send_error(202)
def main():
parser = optparse.OptionParser()
parser.add_option("-v", "--verbose", action="store_true",
help="logging.DEBUG")
(options, args) = parser.parse_args()
log.setLevel(logging.DEBUG if options.verbose else logging.INFO)
graph = SyncedGraph(networking.rdfdb.url, "vidrefsetup")
# deliberately conflict with vidref since they can't talk at once to cam
port = networking.vidref.port
reactor.listenTCP(port, cyclone.web.Application(handlers=[
(r'/pic', RedirToCamera),
(r'/picUrl', UrlToCamera),
(r'/vidrefCamRequest', VidrefCamRequest),
(r'/static/(.*)', cyclone.web.StaticFileHandler, {'path': 'static/'}),
(r'/()', cyclone.web.StaticFileHandler, {'path': 'light9/vidref/', 'default_filename': 'vidref.html'}),
], debug=True, graph=graph))
log.info("serving on %s" % port)
reactor.run()
main()
|