# Path: thingsboard_gateway/connectors/connector.py
# class Connector(ABC):
#     def open(self):
#     def close(self):
#     def get_name(self):
#     def is_connected(self):
#     def on_attributes_update(self, content):
#     def server_side_rpc_handler(self, content):
# 
# Path: thingsboard_gateway/tb_utility/tb_loader.py
# class TBModuleLoader:
#     PATHS = []
#     LOADED_CONNECTORS = {}
# 
#     @staticmethod
#     def find_paths():
#         root_path = path.abspath(path.dirname(path.dirname(__file__)))
#         log.debug("Root path is: " + root_path)
#         if path.exists(DEB_INSTALLATION_EXTENSION_PATH):
#             log.debug("Debian installation extensions folder exists.")
#             TBModuleLoader.PATHS.append(DEB_INSTALLATION_EXTENSION_PATH)
#         TBModuleLoader.PATHS.append(root_path + EXTENSIONS_FOLDER)
#         TBModuleLoader.PATHS.append(root_path + CONNECTORS_FOLDER)
# 
#     @staticmethod
#     def import_module(extension_type, module_name):
#         if len(TBModuleLoader.PATHS) == 0:
#             TBModuleLoader.find_paths()
#         buffered_module_name = extension_type + module_name
#         if TBModuleLoader.LOADED_CONNECTORS.get(buffered_module_name) is not None:
#             return TBModuleLoader.LOADED_CONNECTORS[buffered_module_name]
#         try:
#             for current_path in TBModuleLoader.PATHS:
#                 current_extension_path = current_path + path.sep + extension_type
#                 if path.exists(current_extension_path):
#                     for file in listdir(current_extension_path):
#                         if not file.startswith('__') and file.endswith('.py'):
#                             try:
#                                 module_spec = spec_from_file_location(module_name, current_extension_path + path.sep + file)
#                                 log.debug(module_spec)
# 
#                                 if module_spec is None:
#                                     continue
# 
#                                 module = module_from_spec(module_spec)
#                                 module_spec.loader.exec_module(module)
#                                 for extension_class in getmembers(module, isclass):
#                                     if module_name in extension_class:
#                                         log.info("Import %s from %s.", module_name, current_extension_path)
#                                         TBModuleLoader.LOADED_CONNECTORS[buffered_module_name] = extension_class[1]
#                                         return extension_class[1]
#                             except ImportError:
#                                 continue
#         except Exception as e:
#             log.exception(e)


import socket
from queue import Queue
from random import choice
from string import ascii_lowercase
from threading import Thread
from time import sleep
from thingsboard_gateway.connectors.connector import Connector, log
from thingsboard_gateway.tb_utility.tb_loader import TBModuleLoader
        self.daemon = True
        self.__stopped = False
        self._connected = False
        self.__socket_type = config['type'].upper()
        self.__socket_address = config['address']
        self.__socket_port = config['port']
        self.__socket_buff_size = config['bufferSize']
        self.__socket = socket.socket(socket.AF_INET, SOCKET_TYPE[self.__socket_type])
        self.__converting_requests = Queue(-1)

        self.__devices = self.__convert_devices_list()
        self.__connections = {}

    def __convert_devices_list(self):
        devices = self.__config.get('devices', [])

        converted_devices = {}
        for device in devices:
            address = device.get('address')
            module = self.__load_converter(device)
            converter = module(
                {'deviceName': device['deviceName'],
                 'deviceType': device.get('deviceType', 'default')}) if module else None
            device['converter'] = converter
            converted_devices[address] = device

        return converted_devices

    def __load_converter(self, device):
        converter_class_name = device.get('converter', DEFAULT_UPLINK_CONVERTER)

# Path: thingsboard_gateway/connectors/connector.py
# class Connector(ABC):
#     def open(self):
#     def close(self):
#     def get_name(self):
#     def is_connected(self):
#     def on_attributes_update(self, content):
#     def server_side_rpc_handler(self, content):
# 
# Path: thingsboard_gateway/tb_utility/tb_loader.py
# class TBModuleLoader:
#     PATHS = []
#     LOADED_CONNECTORS = {}
# 
#     @staticmethod
#     def find_paths():
#         root_path = path.abspath(path.dirname(path.dirname(__file__)))
#         log.debug("Root path is: " + root_path)
#         if path.exists(DEB_INSTALLATION_EXTENSION_PATH):
#             log.debug("Debian installation extensions folder exists.")
#             TBModuleLoader.PATHS.append(DEB_INSTALLATION_EXTENSION_PATH)
#         TBModuleLoader.PATHS.append(root_path + EXTENSIONS_FOLDER)
#         TBModuleLoader.PATHS.append(root_path + CONNECTORS_FOLDER)
# 
#     @staticmethod
#     def import_module(extension_type, module_name):
#         if len(TBModuleLoader.PATHS) == 0:
#             TBModuleLoader.find_paths()
#         buffered_module_name = extension_type + module_name
#         if TBModuleLoader.LOADED_CONNECTORS.get(buffered_module_name) is not None:
#             return TBModuleLoader.LOADED_CONNECTORS[buffered_module_name]
#         try:
#             for current_path in TBModuleLoader.PATHS:
#                 current_extension_path = current_path + path.sep + extension_type
#                 if path.exists(current_extension_path):
#                     for file in listdir(current_extension_path):
#                         if not file.startswith('__') and file.endswith('.py'):
#                             try:
#                                 module_spec = spec_from_file_location(module_name, current_extension_path + path.sep + file)
#                                 log.debug(module_spec)
# 
#                                 if module_spec is None:
#                                     continue
# 
#                                 module = module_from_spec(module_spec)
#                                 module_spec.loader.exec_module(module)
#                                 for extension_class in getmembers(module, isclass):
#                                     if module_name in extension_class:
#                                         log.info("Import %s from %s.", module_name, current_extension_path)
#                                         TBModuleLoader.LOADED_CONNECTORS[buffered_module_name] = extension_class[1]
#                                         return extension_class[1]
#                             except ImportError:
#                                 continue
#         except Exception as e:
#             log.exception(e)


# Path: thingsboard_gateway/connectors/socket/socket_connector.py
import socket
from queue import Queue
from random import choice
from string import ascii_lowercase
from threading import Thread
from time import sleep
from thingsboard_gateway.connectors.connector import Connector, log
from thingsboard_gateway.tb_utility.tb_loader import TBModuleLoader

        self.daemon = True
        self.__stopped = False
        self._connected = False
        self.__socket_type = config['type'].upper()
        self.__socket_address = config['address']
        self.__socket_port = config['port']
        self.__socket_buff_size = config['bufferSize']
        self.__socket = socket.socket(socket.AF_INET, SOCKET_TYPE[self.__socket_type])
        self.__converting_requests = Queue(-1)

        self.__devices = self.__convert_devices_list()
        self.__connections = {}

    def __convert_devices_list(self):
        devices = self.__config.get('devices', [])

        converted_devices = {}
        for device in devices:
            address = device.get('address')
            module = self.__load_converter(device)
            converter = module(
                {'deviceName': device['deviceName'],
                 'deviceType': device.get('deviceType', 'default')}) if module else None
            device['converter'] = converter
            converted_devices[address] = device

        return converted_devices

    def __load_converter(self, device):
        converter_class_name = device.get('converter', DEFAULT_UPLINK_CONVERTER)

        module = TBModuleLoader.import_module(self._connector_type, converter_class_name)