diff bin/subserver @ 1858:7772cc48e016

reformat all python Ignore-this: 1135b78893f8b3d31badddda7f45678f
author drewp@bigasterisk.com
date Tue, 21 May 2019 23:56:12 +0000
parents 6fa4288da8a6
children 40cc863d2b63
line wrap: on
line diff
--- a/bin/subserver	Tue May 21 23:55:35 2019 +0000
+++ b/bin/subserver	Tue May 21 23:56:12 2019 +0000
@@ -16,17 +16,19 @@
 from light9 import networking, showconfig
 
 from lib.cycloneerr import PrettyErrorHandler
-        
+
+
 class Static(PrettyErrorHandler, cyclone.web.StaticFileHandler):
+
     def get(self, path, *args, **kw):
         if path in ['', 'effects']:
             return self.respondStaticJade("light9/subserver/%s.jade" %
                                           (path or 'index'))
-            
+
         if path.endswith(".js"):
             return self.responseStaticCoffee(
                 'light9/subserver/%s' %
-                path.replace(".js", ".coffee")) # potential security hole
+                path.replace(".js", ".coffee"))  # potential security hole
 
         cyclone.web.StaticFileHandler.get(self, path, *args, **kw)
 
@@ -35,14 +37,18 @@
         self.write(html)
 
     def responseStaticCoffee(self, src):
-        self.write(subprocess.check_output([
-            '/usr/bin/coffee', '--compile', '--print', src]))
+        self.write(
+            subprocess.check_output(
+                ['/usr/bin/coffee', '--compile', '--print', src]))
+
 
 class Snapshot(PrettyErrorHandler, cyclone.web.RequestHandler):
+
     @defer.inlineCallbacks
     def post(self):
         about = URIRef(self.get_argument("about"))
-        response = yield cyclone.httpclient.fetch(networking.vidref.path("snapshot"), method="POST", timeout=1)
+        response = yield cyclone.httpclient.fetch(
+            networking.vidref.path("snapshot"), method="POST", timeout=1)
 
         snapUri = URIRef(json.loads(response.body)['snapshot'])
         # vidref could write about when it was taken, etc. would it be
@@ -50,15 +56,17 @@
         # the graph, and then it doesn't even have to return anything?
 
         ctx = showconfig.showUri() + "/snapshots"
-        
-        self.settings.graph.patch(Patch(addQuads=[
-            (about, L9['image'], snapUri, ctx),
-            (snapUri, DCTERMS['created'],
-             Literal(datetime.datetime.now(tzlocal())), ctx),
+
+        self.settings.graph.patch(
+            Patch(addQuads=[
+                (about, L9['image'], snapUri, ctx),
+                (snapUri, DCTERMS['created'],
+                 Literal(datetime.datetime.now(tzlocal())), ctx),
             ]))
-        
+
         self.write(json.dumps({'snapshot': snapUri}))
 
+
 def newestImage(subject):
     newest = (None, None)
     for img in graph.objects(subject, L9['image']):
@@ -66,10 +74,13 @@
         if created > newest[0]:
             newest = (created, img)
     return newest[1]
-        
+
+
 if __name__ == "__main__":
     parser = optparse.OptionParser()
-    parser.add_option("-v", "--verbose", action="store_true",
+    parser.add_option("-v",
+                      "--verbose",
+                      action="store_true",
                       help="logging.DEBUG")
     (options, args) = parser.parse_args()
 
@@ -77,13 +88,17 @@
 
     graph = SyncedGraph(networking.rdfdb.url, "subServer")
 
-    
     port = networking.subServer.port
-    reactor.listenTCP(port, cyclone.web.Application(handlers=[
-        (r'/snapshot', Snapshot),
-        (r'/(.*)', Static,
-         {"path" : "light9/subserver",
-          "default_filename" : "index.jade"}),
-        ], debug=True, graph=graph))
+    reactor.listenTCP(
+        port,
+        cyclone.web.Application(handlers=[
+            (r'/snapshot', Snapshot),
+            (r'/(.*)', Static, {
+                "path": "light9/subserver",
+                "default_filename": "index.jade"
+            }),
+        ],
+                                debug=True,
+                                graph=graph))
     log.info("serving on %s" % port)
     reactor.run()