mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-05-11 18:10:15 +08:00
fix module test
This commit is contained in:
@@ -73,11 +73,14 @@ class ModuleManager(metaclass=Singleton):
|
||||
测试模块
|
||||
"""
|
||||
if modleid not in self._running_modules:
|
||||
return False, "模块未加载,请检查参数设置"
|
||||
return False, ""
|
||||
module = self._running_modules[modleid]
|
||||
if hasattr(module, "test") \
|
||||
and ObjectUtils.check_method(getattr(module, "test")):
|
||||
return module.test()
|
||||
result = module.test()
|
||||
if not result:
|
||||
return False, ""
|
||||
return result
|
||||
return True, "模块不支持测试"
|
||||
|
||||
@staticmethod
|
||||
|
||||
@@ -42,7 +42,7 @@ class _ModuleBase(metaclass=ABCMeta):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def test(self) -> Tuple[bool, str]:
|
||||
def test(self) -> Optional[Tuple[bool, str]]:
|
||||
"""
|
||||
模块测试, 返回测试结果和错误信息
|
||||
"""
|
||||
|
||||
@@ -31,12 +31,12 @@ class EmbyModule(_ModuleBase, _MediaServerBase):
|
||||
def stop(self):
|
||||
pass
|
||||
|
||||
def test(self) -> Tuple[bool, str]:
|
||||
def test(self) -> Optional[Tuple[bool, str]]:
|
||||
"""
|
||||
测试模块连接性
|
||||
"""
|
||||
if not self._servers:
|
||||
return False, "未配置Emby服务器"
|
||||
return None
|
||||
for name, server in self._servers.items():
|
||||
if server.is_inactive():
|
||||
server.reconnect()
|
||||
|
||||
@@ -44,12 +44,12 @@ class JellyfinModule(_ModuleBase, _MediaServerBase):
|
||||
def stop(self):
|
||||
pass
|
||||
|
||||
def test(self) -> Tuple[bool, str]:
|
||||
def test(self) -> Optional[Tuple[bool, str]]:
|
||||
"""
|
||||
测试模块连接性
|
||||
"""
|
||||
if not self._servers:
|
||||
return False, "未配置Jellyfin服务器"
|
||||
return None
|
||||
for name, server in self._servers.items():
|
||||
if server.is_inactive():
|
||||
server.reconnect()
|
||||
|
||||
@@ -31,12 +31,12 @@ class PlexModule(_ModuleBase, _MediaServerBase):
|
||||
def stop(self):
|
||||
pass
|
||||
|
||||
def test(self) -> Tuple[bool, str]:
|
||||
def test(self) -> Optional[Tuple[bool, str]]:
|
||||
"""
|
||||
测试模块连接性
|
||||
"""
|
||||
if not self._servers:
|
||||
return False, "未配置Plex服务器"
|
||||
return None
|
||||
for name, server in self._servers.items():
|
||||
if server.is_inactive():
|
||||
server.reconnect()
|
||||
|
||||
@@ -43,10 +43,12 @@ class QbittorrentModule(_ModuleBase, _DownloaderBase):
|
||||
def stop(self):
|
||||
pass
|
||||
|
||||
def test(self) -> Tuple[bool, str]:
|
||||
def test(self) -> Optional[Tuple[bool, str]]:
|
||||
"""
|
||||
测试模块连接性
|
||||
"""
|
||||
if not self._servers:
|
||||
return None
|
||||
for name, server in self._servers.items():
|
||||
if server.is_inactive():
|
||||
server.reconnect()
|
||||
|
||||
@@ -38,10 +38,12 @@ class SlackModule(_ModuleBase, _MessageBase):
|
||||
for client in self._clients.values():
|
||||
client.stop()
|
||||
|
||||
def test(self) -> Tuple[bool, str]:
|
||||
def test(self) -> Optional[Tuple[bool, str]]:
|
||||
"""
|
||||
测试模块连接性
|
||||
"""
|
||||
if not self._clients:
|
||||
return None
|
||||
for name, client in self._clients.items():
|
||||
state = client.get_state()
|
||||
if not state:
|
||||
|
||||
@@ -20,7 +20,7 @@ class SynologyChatModule(_ModuleBase, _MessageBase):
|
||||
self._configs = {}
|
||||
self._clients = {}
|
||||
for client in clients:
|
||||
if client.type == "telegram" and client.enabled:
|
||||
if client.type == "slack" and client.enabled:
|
||||
self._configs[client.name] = client
|
||||
self._clients[client.name] = SynologyChat(**client.config)
|
||||
|
||||
@@ -31,10 +31,12 @@ class SynologyChatModule(_ModuleBase, _MessageBase):
|
||||
def stop(self):
|
||||
pass
|
||||
|
||||
def test(self) -> Tuple[bool, str]:
|
||||
def test(self) -> Optional[Tuple[bool, str]]:
|
||||
"""
|
||||
测试模块连接性
|
||||
"""
|
||||
if not self._clients:
|
||||
return None
|
||||
for name, client in self._clients.items():
|
||||
state = client.get_state()
|
||||
if not state:
|
||||
|
||||
@@ -37,10 +37,12 @@ class TelegramModule(_ModuleBase, _MessageBase):
|
||||
for client in self._clients.values():
|
||||
client.stop()
|
||||
|
||||
def test(self) -> Tuple[bool, str]:
|
||||
def test(self) -> Optional[Tuple[bool, str]]:
|
||||
"""
|
||||
测试模块连接性
|
||||
"""
|
||||
if not self._clients:
|
||||
return None
|
||||
for name, client in self._clients.items():
|
||||
state = client.get_state()
|
||||
if not state:
|
||||
|
||||
@@ -40,12 +40,12 @@ class TransmissionModule(_ModuleBase, _DownloaderBase):
|
||||
def stop(self):
|
||||
pass
|
||||
|
||||
def test(self) -> Tuple[bool, str]:
|
||||
def test(self) -> Optional[Tuple[bool, str]]:
|
||||
"""
|
||||
测试模块连接性
|
||||
"""
|
||||
if not self._servers:
|
||||
return False, "未配置Transmission下载器"
|
||||
return None
|
||||
for name, server in self._servers.items():
|
||||
if server.is_inactive():
|
||||
server.reconnect()
|
||||
|
||||
@@ -33,10 +33,12 @@ class VoceChatModule(_ModuleBase, _MessageBase):
|
||||
def stop(self):
|
||||
pass
|
||||
|
||||
def test(self) -> Tuple[bool, str]:
|
||||
def test(self) -> Optional[Tuple[bool, str]]:
|
||||
"""
|
||||
测试模块连接性
|
||||
"""
|
||||
if not self._clients:
|
||||
return None
|
||||
for name, client in self._clients.items():
|
||||
state = client.get_state()
|
||||
if not state:
|
||||
|
||||
@@ -34,10 +34,12 @@ class WechatModule(_ModuleBase, _MessageBase):
|
||||
def stop(self):
|
||||
pass
|
||||
|
||||
def test(self) -> Tuple[bool, str]:
|
||||
def test(self) -> Optional[Tuple[bool, str]]:
|
||||
"""
|
||||
测试模块连接性
|
||||
"""
|
||||
if not self._clients:
|
||||
return None
|
||||
for name, client in self._clients.items():
|
||||
state = client.get_state()
|
||||
if not state:
|
||||
|
||||
Reference in New Issue
Block a user