Skip to content

Commit

Permalink
Added handling for empty config
Browse files Browse the repository at this point in the history
  • Loading branch information
imbeacon committed Nov 24, 2023
1 parent e636826 commit ec44657
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions thingsboard_gateway/gateway/tb_gateway_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,8 @@ def __stop_gateway(self):
log.info("The gateway has been stopped.")
self.tb_client.disconnect()
self.tb_client.stop()
self.manager.shutdown()
if hasattr(self, "manager"):
self.manager.shutdown()

def __init_remote_configuration(self, force=False):
if (self.__config["thingsboard"].get("remoteConfiguration") or force) and self.__remote_configurator is None:
Expand Down Expand Up @@ -730,7 +731,7 @@ def _load_connectors(self, config=None):
connector.get('class')))

if connector_class is None:
log.warning("Connector implementation not found for %s", connector["name"])
log.warning("Connector implementation not found for %s", connector['name'])
else:
self._implemented_connectors[connector['type']] = connector_class
elif connector['type'] == "grpc":
Expand All @@ -757,10 +758,8 @@ def _load_connectors(self, config=None):
if connector['type'] != 'grpc' and isinstance(connector_conf, dict):
connector_conf["name"] = connector['name']
self.connectors_configs[connector['type']].append({"name": connector['name'],
"config": {connector[
'configuration']: connector_conf} if
connector[
'type'] != 'grpc' else connector_conf,
"config": {connector['configuration']: connector_conf} if
connector['type'] != 'grpc' else connector_conf,
"config_updated": stat(config_file_path),
"config_file_path": config_file_path,
"grpc_key": connector_persistent_key})
Expand All @@ -785,7 +784,7 @@ def __connect_with_connectors(self):
connector = None
connector_name = None
try:
if connector_config["config"][config] is not None:
if connector_config["config"][config] is not None and len(connector_config["config"][config].keys()) > 2:
connector_name = connector_config["name"]

if not self.available_connectors.get(connector_name):
Expand All @@ -799,7 +798,7 @@ def __connect_with_connectors(self):
else:
break
else:
log.info("Config not found for %s", connector_type)
log.info("Config not found or empty for %s", connector_type)
except Exception as e:
log.exception(e, attr_name=connector_name)
if connector is not None:
Expand Down

0 comments on commit ec44657

Please sign in to comment.