mirror of
https://github.com/Nezumi-2711/astrbot_plugin_qq_group_daily_analysis.git
synced 2026-09-22 13:38:43 +00:00
Ruff:收敛异常处理并清理未使用导入/变量
This commit is contained in:
@@ -179,7 +179,6 @@ class UserTitleAnalyzer(BaseAnalyzer):
|
||||
|
||||
# 分析用户特征
|
||||
night_messages = sum(stats["hours"][h] for h in range(6))
|
||||
day_messages = stats["message_count"] - night_messages
|
||||
avg_chars = (
|
||||
stats["char_count"] / stats["message_count"]
|
||||
if stats["message_count"] > 0
|
||||
|
||||
@@ -313,7 +313,6 @@ class ConfigManager:
|
||||
"""检查 pyppeteer 可用性"""
|
||||
try:
|
||||
import pyppeteer
|
||||
from pyppeteer import launch
|
||||
|
||||
self._pyppeteer_available = True
|
||||
|
||||
@@ -348,7 +347,6 @@ class ConfigManager:
|
||||
# 强制重新导入
|
||||
try:
|
||||
import pyppeteer
|
||||
from pyppeteer import launch
|
||||
|
||||
# 更新全局变量
|
||||
self._pyppeteer_available = True
|
||||
|
||||
@@ -485,8 +485,8 @@ class ReportGenerator:
|
||||
for page in pages:
|
||||
try:
|
||||
await page.close()
|
||||
except:
|
||||
pass
|
||||
except Exception as close_err:
|
||||
logger.debug(f"关闭页面时忽略的异常: {close_err}")
|
||||
|
||||
# 等待一小段时间让资源释放
|
||||
await asyncio.sleep(0.5)
|
||||
@@ -499,8 +499,8 @@ class ReportGenerator:
|
||||
# 强制清理
|
||||
try:
|
||||
await browser.disconnect()
|
||||
except:
|
||||
pass
|
||||
except Exception as disc_err:
|
||||
logger.debug(f"断开浏览器连接时忽略的异常: {disc_err}")
|
||||
|
||||
except Exception as e:
|
||||
error_msg = str(e)
|
||||
|
||||
@@ -170,7 +170,7 @@ class PDFInstaller:
|
||||
)
|
||||
|
||||
# 只下载 Chromium
|
||||
chromium_revision = launcher._get_chromium_revision()
|
||||
launcher._get_chromium_revision()
|
||||
await launcher._download_chromium()
|
||||
|
||||
logger.info("✅ Chromium 下载完成")
|
||||
|
||||
Reference in New Issue
Block a user