Initialize a module for execution
(self, module_path)
| 59 | self.logger.debug(traceback.format_exc()) |
| 60 | |
| 61 | def init_module(self, module_path): |
| 62 | """Initialize a module for execution""" |
| 63 | module = None |
| 64 | module = self.load_module(module_path) |
| 65 | |
| 66 | if module: |
| 67 | self.logger.debug(f"Supported protocols: {module.supported_protocols}") |
| 68 | self.logger.debug(f"Protocol: {self.args.protocol}") |
| 69 | if self.args.protocol in module.supported_protocols: |
| 70 | try: |
| 71 | module_logger = NXCAdapter(extra={"module_name": module.name.upper()}) |
| 72 | except Exception as e: |
| 73 | self.logger.fail(f"Error loading NXCAdaptor for module {module.name.upper()}: {e}") |
| 74 | context = Context(self.db, module_logger, self.args) |
| 75 | module_options = {} |
| 76 | |
| 77 | for option in self.args.module_options: |
| 78 | key, value = option.split("=", 1) |
| 79 | module_options[str(key).upper()] = value |
| 80 | |
| 81 | module.options(context, module_options) |
| 82 | return module |
| 83 | else: |
| 84 | self.logger.fail(f"Module {module.name.upper()} is not supported for protocol {self.args.protocol}") |
| 85 | sys.exit(1) |
| 86 | |
| 87 | def get_module_info(self, module_path): |
| 88 | """Get the path, description, and options from a module""" |
no test coverage detected