changeset 2156:c5974a6bbc28

reformat
author drewp@bigasterisk.com
date Thu, 18 May 2023 10:13:55 -0700
parents 092967f313e1
children 94b58da02abc
files light9/collector/output.py light9/web/live/Light9LiveControls.ts light9/web/live/index.html
diffstat 3 files changed, 26 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/light9/collector/output.py	Wed May 17 19:56:17 2023 -0700
+++ b/light9/collector/output.py	Thu May 18 10:13:55 2023 -0700
@@ -6,6 +6,7 @@
 import logging
 from twisted.internet import threads, reactor, task
 from light9.metrics import metrics
+
 log = logging.getLogger('output')
 logAllDmx = logging.getLogger('output.allDmx')
 
@@ -42,8 +43,7 @@
         self._currentBuffer = buf
 
     def _periodicLog(self):
-        msg = '%s: %s' % (self.shortId(), ' '.join(map(str,
-                                                       self._currentBuffer)))
+        msg = '%s: %s' % (self.shortId(), ' '.join(map(str, self._currentBuffer)))
         if msg != self._lastLoggedMsg:
             log.debug(msg)
             self._lastLoggedMsg = msg
@@ -65,7 +65,7 @@
     def __init__(self, uri, **kw):
         super().__init__(uri)
 
-    def update(self, buf:bytes):
+    def update(self, buf: bytes):
         log.info(f'dummy update {list(map(int,buf[:80]))}')
 
 
@@ -87,8 +87,7 @@
 
         def done(worked):
             metrics('write_success', output=self.shortId()).incr()
-            reactor.callLater(max(0, start + 1 / self.rate - time.time()),
-                              self._loop)
+            reactor.callLater(max(0, start + 1 / self.rate - time.time()), self._loop)
 
         def err(e):
             metrics('write_fail', output=self.shortId()).incr()
@@ -120,8 +119,7 @@
 
             if logAllDmx.isEnabledFor(logging.DEBUG):
                 # for testing fps, smooth fades, etc
-                logAllDmx.debug('%s: %s...' %
-                                (self.shortId(), ' '.join(map(str, buf[:32]))))
+                logAllDmx.debug('%s: %s...' % (self.shortId(), ' '.join(map(str, buf[:32]))))
 
             self.dmx.send_dmx(buf)
 
@@ -141,15 +139,14 @@
         self._socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
 
     def _write(self, buf):
-       with metrics('write', output=self.shortId()).time():
+        with metrics('write', output=self.shortId()).time():
             if not buf:
                 logAllDmx.debug('%s: empty buf- no output', self.shortId())
                 return
 
             if logAllDmx.isEnabledFor(logging.DEBUG):
                 # for testing fps, smooth fades, etc
-                logAllDmx.debug('%s: %s...' %
-                                (self.shortId(), ' '.join(map(str, buf[:32]))))
+                logAllDmx.debug('%s: %s...' % (self.shortId(), ' '.join(map(str, buf[:32]))))
 
             if self.sequence_counter:
                 self.sequence_counter += 1
@@ -162,8 +159,7 @@
             packet.append(universe_nr & 0xFF)  # Universe LowByte
             packet.append(universe_nr >> 8 & 0xFF)  # Universe HighByte
 
-            packet.extend(struct.pack(
-                '>h', len(buf)))  # Pack the number of channels Big endian
+            packet.extend(struct.pack('>h', len(buf)))  # Pack the number of channels Big endian
             packet.extend(buf)
 
             self._socket.sendto(packet, ('127.0.0.1', 6454))
@@ -171,7 +167,7 @@
 
 class Udmx(BackgroundLoopOutput):
 
-    def __init__(self, uri, bus, address, lastDmxChannel, rate=22):
+    def __init__(self, uri: URIRef, bus: int, address: int, lastDmxChannel: int, rate=22):
         self.bus = bus
         self.address = address
         self.lastDmxChannel = lastDmxChannel
@@ -216,9 +212,7 @@
 
                 if logAllDmx.isEnabledFor(logging.DEBUG):
                     # for testing fps, smooth fades, etc
-                    logAllDmx.debug(
-                        '%s: %s...' %
-                        (self.shortId(), ' '.join(map(str, buf[:32]))))
+                    logAllDmx.debug('%s: %s...' % (self.shortId(), ' '.join(map(str, buf[:32]))))
 
                 sent = self.dev.send_multi_value(1, buf)
                 if sent != len(buf):
@@ -240,8 +234,7 @@
                     metrics('write_pipe_error', output=self.shortId()).inc()
                     return
 
-                msg = 'usb: sending %s bytes to %r; error %r' % (len(buf),
-                                                                 self.uri, e)
+                msg = 'usb: sending %s bytes to %r; error %r' % (len(buf), self.uri, e)
                 log.warn(msg)
 
                 if e.errno == 13:  # permissions
--- a/light9/web/live/Light9LiveControls.ts	Wed May 17 19:56:17 2023 -0700
+++ b/light9/web/live/Light9LiveControls.ts	Thu May 18 10:13:55 2023 -0700
@@ -96,7 +96,7 @@
 
     this.devices = [];
     let classes = this.graph.subjects(U("rdf:type"), U(":DeviceClass"));
-    log(`found ${classes.length} device classes`)
+    log(`found ${classes.length} device classes`);
     uniq(sortBy(classes, "value"), true).forEach((dc) => {
       sortBy(this.graph.subjects(U("rdf:type"), dc), "value").forEach((dev) => {
         this.devices.push(dev as NamedNode);
--- a/light9/web/live/index.html	Wed May 17 19:56:17 2023 -0700
+++ b/light9/web/live/index.html	Thu May 18 10:13:55 2023 -0700
@@ -1,24 +1,25 @@
-<!doctype html>
+<!DOCTYPE html>
 <html>
   <head>
     <title>device control</title>
     <meta charset="utf-8" />
-    <link rel="stylesheet" href="../style.css">
+    <link rel="stylesheet" href="../style.css" />
     <script type="module" src="../live/Light9LiveControls"></script>
   </head>
   <body>
     <style>
-     body, html {
-         margin: 0;
-     }
-     light9-live-controls {
-         position: absolute;
-         left: 2px;
-         top: 2px;
-         right: 8px;
-         bottom: 0;
-     }
+      body,
+      html {
+        margin: 0;
+      }
+      light9-live-controls {
+        position: absolute;
+        left: 2px;
+        top: 2px;
+        right: 8px;
+        bottom: 0;
+      }
     </style>
-    <light9-live-controls></light9-live-controls>    
+    <light9-live-controls></light9-live-controls>
   </body>
 </html>