# HG changeset patch # User Drew Perttula # Date 2019-05-27 07:03:27 # Node ID 8da5b4edcb7e708b9446367c40d879bf0948a285 # Parent 382d3c7470034e084e67657a0d016545410cd3ae type fixes, especially for collector_client Ignore-this: c4ad6f85a477fc034ceb6e996e701de8 diff --git a/bin/keyboardcomposer b/bin/keyboardcomposer --- a/bin/keyboardcomposer +++ b/bin/keyboardcomposer @@ -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, diff --git a/light9/collector/collector_client.py b/light9/collector/collector_client.py --- a/light9/collector/collector_client.py +++ b/light9/collector/collector_client.py @@ -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) diff --git a/light9/networking.py b/light9/networking.py --- a/light9/networking.py +++ b/light9/networking.py @@ -1,3 +1,4 @@ +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