Changeset - 8da5b4edcb7e
[Not reviewed]
default
0 3 0
Drew Perttula - 6 years ago 2019-05-27 07:03:27
drewp@bigasterisk.com
type fixes, especially for collector_client
Ignore-this: c4ad6f85a477fc034ceb6e996e701de8
3 files changed with 12 insertions and 10 deletions:
0 comments (0 inline, 0 general)
bin/keyboardcomposer
Show inline comments
 
@@ -9,7 +9,7 @@ from twisted.internet import reactor, tk
 
from twisted.web import resource
 
from rdflib import URIRef, Literal
 
import tkinter.tix as tk
 
from typing import Dict, Tuple, List
 
from typing import Any, Dict, Tuple, List
 

	
 
from light9.Fadable import Fadable
 
from light9.subclient import SubClient
 
@@ -181,7 +181,7 @@ class SubmasterBox(tk.Frame):
 

	
 
class KeyboardComposer(tk.Frame, SubClient):
 

	
 
    def __init__(self, root, graph, session, hw_sliders=True):
 
    def __init__(self, root: tk.Tk, graph: SyncedGraph, session: URIRef, hw_sliders=True):
 
        tk.Frame.__init__(self, root, bg='black')
 
        SubClient.__init__(self)
 
        self.graph = graph
 
@@ -239,7 +239,7 @@ class KeyboardComposer(tk.Frame, SubClie
 
        self.sub_name = tk.Entry(self.buttonframe, bg='black', fg='white')
 
        self.sub_name.pack(side=tk.LEFT)
 

	
 
    def redraw_sliders(self):
 
    def redraw_sliders(self) -> None:
 
        self.draw_sliders()
 
        if len(self.rows):
 
            self.change_row(self.current_row)
 
@@ -372,7 +372,7 @@ class KeyboardComposer(tk.Frame, SubClie
 
            self.graph.value(self.session, L9['currentRow'], default=0)),
 
                        fromGraph=True)
 

	
 
    def change_row(self, row, fromGraph=False):
 
    def change_row(self, row: int, fromGraph=False) -> None:
 
        old_row = self.current_row
 
        self.current_row = row
 
        self.current_row = max(0, self.current_row)
 
@@ -633,7 +633,7 @@ class Sliders(BCF2000):
 
            self.valueOut(name, 0)
 

	
 

	
 
def launch(opts, root, graph, session):
 
def launch(opts: Any, root: tk.Tk, graph: SyncedGraph, session: URIRef):
 
    tl = toplevelat("Keyboard Composer - %s" % opts.session,
 
                    existingtoplevel=root,
 
                    graph=graph,
light9/collector/collector_client.py
Show inline comments
 
@@ -20,7 +20,7 @@ class TwistedZmqClient(object):
 
        self.conn.push(msg)
 

	
 

	
 
def toCollectorJson(client, session, settings):
 
def toCollectorJson(client, session, settings) -> str:
 
    assert isinstance(settings, DeviceSettings)
 
    return json.dumps({
 
        'settings': settings.asList(),
 
@@ -41,7 +41,7 @@ def sendToCollectorZmq(msg):
 
def sendToCollector(client, session, settings, useZmq=False):
 
    """deferred to the time in seconds it took to get a response from collector"""
 
    sendTime = time.time()
 
    msg = toCollectorJson(client, session, settings)
 
    msg = toCollectorJson(client, session, settings).encode('utf8')
 

	
 
    if useZmq:
 
        d = sendToCollectorZmq(msg)
light9/networking.py
Show inline comments
 
from rdflib import URIRef
 
from urllib.parse import urlparse
 
from .showconfig import getGraph, showUri
 
from .namespaces import L9
 
@@ -8,14 +9,15 @@ class ServiceAddress(object):
 
    def __init__(self, service):
 
        self.service = service
 

	
 
    def _url(self):
 
    def _url(self) -> URIRef:
 
        graph = getGraph()
 
        net = graph.value(showUri(), L9['networking'])
 
        ret = graph.value(net, self.service)
 
        if ret is None:
 
            raise ValueError("no url for %s -> %s -> %s" %
 
                             (showUri(), L9['networking'], self.service))
 
        return str(ret)
 
        assert isinstance(ret, URIRef)
 
        return ret
 

	
 
    @property
 
    def port(self):
 
@@ -26,7 +28,7 @@ class ServiceAddress(object):
 
        return urlparse(self._url()).hostname
 

	
 
    @property
 
    def url(self):
 
    def url(self) -> URIRef:
 
        return self._url()
 

	
 
    value = url
0 comments (0 inline, 0 general)