bnovo plugin
scheduller
This commit is contained in:
@@ -7,27 +7,31 @@ from asgiref.sync import sync_to_async
|
||||
|
||||
class PluginLoader:
|
||||
PLUGIN_PATH = Path(__file__).parent / "plugins"
|
||||
print("Путь к папке плагинов:", PLUGIN_PATH.resolve())
|
||||
print("Содержимое папки:", list(PLUGIN_PATH.iterdir()))
|
||||
|
||||
@staticmethod
|
||||
def load_plugins():
|
||||
plugins = {}
|
||||
if not PluginLoader.PLUGIN_PATH.exists():
|
||||
print("Папка с плагинами не существует:", PluginLoader.PLUGIN_PATH)
|
||||
return plugins
|
||||
|
||||
print("Загрузка плагинов:")
|
||||
for file in os.listdir(PluginLoader.PLUGIN_PATH):
|
||||
if file.endswith("_pms.py") and not file.startswith("__"):
|
||||
print(f" Plugin {file}")
|
||||
module_name = f"pms_integration.plugins.{file[:-3]}"
|
||||
try:
|
||||
module = importlib.import_module(module_name)
|
||||
for attr in dir(module):
|
||||
cls = getattr(module, attr)
|
||||
if isinstance(cls, type) and issubclass(cls, BasePMSPlugin) and cls is not BasePMSPlugin:
|
||||
plugins[cls.__name__] = cls
|
||||
print(f"Загружен плагин: {cls.__name__}")
|
||||
plugin_name = file[:-7] # Убираем `_pms` из имени файла
|
||||
print(f" Загружен плагин {plugin_name}: {cls.__name__}")
|
||||
plugins[plugin_name] = cls
|
||||
except Exception as e:
|
||||
print(f"Ошибка при загрузке модуля {module_name}: {e}")
|
||||
print(f"Итоговый список плагинов: {list(plugins.keys())}")
|
||||
print(f" Ошибка загрузки плагина {module_name}: {e}")
|
||||
return plugins
|
||||
|
||||
|
||||
class PMSIntegrationManager:
|
||||
def __init__(self, hotel_id):
|
||||
self.hotel_id = hotel_id
|
||||
|
||||
Reference in New Issue
Block a user