import asyncio
import jsonschema # type: ignore
-from controlpi.messagebus import MessageBus, Message, MessageTemplate
+from controlpi.messagebus import (MessageBus, BusException,
+ Message, MessageTemplate)
from controlpi.pluginregistry import PluginRegistry
from controlpi.baseplugin import BasePlugin, PluginConf, ConfException
return conf
-class ConfigChangeHandler(pyinotify.ProcessEvent):
+class ConfigHandler(pyinotify.ProcessEvent):
def process_IN_MODIFY(self, event):
if event.pathname == os.path.abspath(sys.argv[1]):
print(f"Configuration file modified: {event.pathname}")
wm = pyinotify.WatchManager()
loop = asyncio.get_running_loop()
notifier = pyinotify.AsyncioNotifier(wm, loop,
- default_proc_fun=ConfigChangeHandler())
+ default_proc_fun=ConfigHandler())
wm.add_watch(os.path.dirname(sys.argv[1]), pyinotify.ALL_EVENTS)
return notifier
answer = Message('')
answer['client'] = client
answer['plugin'] = self._plugins[client]
- answer['sends'] = self._send_reg.get_templates(client)
- answer['receives'] = self._recv_reg.get_templates(client)
+ answer['sends'] = (self._send_reg
+ .get_templates(client))
+ answer['receives'] = (self._recv_reg
+ .get_templates(client))
await self._queue.put(answer)
elif message['command'] == 'push conf':
conf = {}
try:
with open(sys.argv[1]) as conf_file:
conf = json.load(conf_file)
- except (IndexError, FileNotFoundError, json.decoder.JSONDecodeError):
+ except (IndexError, FileNotFoundError,
+ json.decoder.JSONDecodeError):
pass
if conf == message['conf']:
- await self._queue.put(Message('', {'event': 'conf unchanged'}))
+ await (self._queue
+ .put(Message('',
+ {'event': 'conf unchanged'})))
else:
- await self._queue.put(Message('', {'event': 'conf changed'}))
+ await (self._queue
+ .put(Message('',
+ {'event': 'conf changed'})))
with open(sys.argv[1], 'w') as conf_file:
json.dump(message['conf'], conf_file)
for client in self._recv_reg.get(message):