diff options
author | Sébastien Dailly <sebastien@dailly.me> | 2025-05-07 11:31:20 +0200 |
---|---|---|
committer | Sébastien Dailly <sebastien@dailly.me> | 2025-07-07 08:32:41 +0200 |
commit | bae4e80500b552f7b3658a1a6a158fef02047f58 (patch) | |
tree | 1f8ea0764cce5b32b8cc2178a20211b3c993e7ff /consumer.py | |
parent | 4bf1c1ffe795a1d28a543a20cc3771a30a090b89 (diff) |
Remove the existing handler (and unused) in socketserver
Diffstat (limited to 'consumer.py')
-rw-r--r-- | consumer.py | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/consumer.py b/consumer.py index 9e36dd0..31fd581 100644 --- a/consumer.py +++ b/consumer.py @@ -1,20 +1,22 @@ -from typing import Dict
+import time
+import abc
+from threading import Thread
+from queue import Queue, Empty, Full
from zope import component, interface
+from interfaces import endpoint, configuration
+from interfaces.configuration import IConfiguration
from interfaces.message import ISocketMessage, Debug
@interface.implementer(ISocketMessage)
-class Mapping(object):
+class Mapping():
""" Send an event requesting a layer change to the endpoint.
"""
def __init__(self, message):
self.content = {"layer": message}
-import abc
-from threading import Thread
-from queue import Queue, Empty, Full
class EventConsummer(Thread, metaclass=abc.ABCMeta):
""" Thread processing messages. This class does nothing and is intended to
@@ -65,9 +67,6 @@ class EventConsummer(Thread, metaclass=abc.ABCMeta): except Full:
component.handle(Debug("Ignoring event: queue is full"))
-import time
-from interfaces import endpoint, configuration
-from interfaces.configuration import IConfiguration
class SocketMessageConsumer(EventConsummer):
""" Provide a handler consuming events and sending them to the endpoint.
@@ -128,8 +127,7 @@ class SocketMessageConsumer(EventConsummer): configuration = component.getUtility(IConfiguration)
if isinstance(mapping, dict):
self._endpoint.send(mapping)
- elif isinstance(data, str):
- # TODO Query the json from the configuration
+ elif isinstance(mapping, str):
layer = configuration.get(mapping, None)
if layer is not None:
self._endpoint.send(layer)
@@ -137,7 +135,9 @@ class SocketMessageConsumer(EventConsummer): if name is not None:
# We received a name to associate the configuration with.
# Register the element in the configuration
- # TODO use an event
configuration[name] = mapping
for key in mapping.keys():
- component.handle(Debug("Associating %s with %s" % (name, key)))
+ # We do not want to log the keycode sent to the keyboard, only
+ # the name is interresting. We are supposed to have only one, but
+ # it’s the easer way to log it
+ component.handle(Debug(f"Associating {name} with {key}"))
|