mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-20 10:34:30 +00:00
Simplify connector creation.
This commit is contained in:
parent
c2c5cce683
commit
093247355b
@ -124,15 +124,23 @@ class Santiago(object):
|
|||||||
self.gpg = gnupg.GPG(use_agent = True)
|
self.gpg = gnupg.GPG(use_agent = True)
|
||||||
self.protocols = set()
|
self.protocols = set()
|
||||||
|
|
||||||
for k, v in (("listeners", "Listener"), ("senders", "Sender"),
|
self.listeners = self.create_connectors(listeners, "Listener")
|
||||||
("monitors", "Monitor"),):
|
self.senders = self.create_connectors(senders, "Sender")
|
||||||
setattr(self, k, self._create_connectors(locals()[k], v))
|
self.monitors = self.create_connectors(monitors, "Monitor")
|
||||||
self.protocols |= set(getattr(self, k).keys())
|
|
||||||
|
|
||||||
self.shelf = shelve.open(str(self.me))
|
self.shelf = shelve.open(str(self.me))
|
||||||
self.hosting = hosting if hosting else self.load_data("hosting")
|
self.hosting = hosting if hosting else self.load_data("hosting")
|
||||||
self.consuming = consuming if consuming else self.load_data("consuming")
|
self.consuming = consuming if consuming else self.load_data("consuming")
|
||||||
|
|
||||||
|
self.require_gpg = require_gpg
|
||||||
|
|
||||||
|
def create_connectors(self, data, type):
|
||||||
|
connectors = self._create_connectors(data, type)
|
||||||
|
self.protocols |= set(connectors.keys())
|
||||||
|
|
||||||
|
return connectors
|
||||||
|
|
||||||
|
|
||||||
def _create_connectors(self, settings, connector):
|
def _create_connectors(self, settings, connector):
|
||||||
"""Iterates through each protocol given, creating connectors for all.
|
"""Iterates through each protocol given, creating connectors for all.
|
||||||
|
|
||||||
@ -184,11 +192,6 @@ class Santiago(object):
|
|||||||
list(self.senders.itervalues())):
|
list(self.senders.itervalues())):
|
||||||
connector.start()
|
connector.start()
|
||||||
|
|
||||||
# debug_log("Starting monitors.")
|
|
||||||
|
|
||||||
# for monitor in list(self.monitors.itervalues()):
|
|
||||||
# monitor.start()
|
|
||||||
|
|
||||||
for protocol in self.protocols:
|
for protocol in self.protocols:
|
||||||
sys.modules[Santiago.CONTROLLER_MODULE.format(protocol)].start()
|
sys.modules[Santiago.CONTROLLER_MODULE.format(protocol)].start()
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user