mirror of
https://github.com/craigerl/aprsd.git
synced 2025-09-02 21:27:56 -04:00
Added client_exists() for client factory
This patch adds a method in the factory to detect if we have created the client yet or not.
This commit is contained in:
parent
95094b874c
commit
505565d3a6
@ -42,6 +42,7 @@ class Client(Protocol):
|
||||
class ClientFactory:
|
||||
_instance = None
|
||||
clients = []
|
||||
client = None
|
||||
|
||||
def __new__(cls, *args, **kwargs):
|
||||
"""This magic turns this into a singleton."""
|
||||
@ -62,9 +63,13 @@ class ClientFactory:
|
||||
def create(self, key=None):
|
||||
for client in self.clients:
|
||||
if client.is_enabled():
|
||||
return client()
|
||||
self.client = client()
|
||||
return self.client
|
||||
raise Exception("No client is configured!!")
|
||||
|
||||
def client_exists(self):
|
||||
return bool(self.client)
|
||||
|
||||
def is_client_enabled(self):
|
||||
"""Make sure at least one client is enabled."""
|
||||
enabled = False
|
||||
|
Loading…
x
Reference in New Issue
Block a user