-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
docs: add frontend update guide to CLI deployment docs #8060
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
32b2971
0b57734
57b3210
74bfcb1
3afff5c
984784a
2254e48
0947ab6
c877af5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -123,7 +123,9 @@ async def load_platform(self, platform_config: dict) -> None: | |||||
| return | ||||||
|
|
||||||
| logger.info( | ||||||
| f"载入 {platform_config['type']}({platform_config['id']}) 平台适配器 ...", | ||||||
| "Loading IM platform adapter %s(%s) ...", | ||||||
| platform_config["type"], | ||||||
| platform_config["id"], | ||||||
| ) | ||||||
| match platform_config["type"]: | ||||||
| case "aiocqhttp": | ||||||
|
|
@@ -201,7 +203,7 @@ async def load_platform(self, platform_config: dict) -> None: | |||||
|
|
||||||
| if platform_config["type"] not in platform_cls_map: | ||||||
| logger.error( | ||||||
| f"未找到适用于 {platform_config['type']}({platform_config['id']}) 平台适配器,请检查是否已经安装或者名称填写错误", | ||||||
| f"Platform adapter not found: {platform_config['type']}({platform_config['id']}).", | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 建议在此处统一使用延迟格式化(使用 %s 占位符),这与本次提交中其他日志风格的修改保持一致,也是 Python 日志记录的最佳实践。
Suggested change
References
|
||||||
| ) | ||||||
| return | ||||||
| cls_type = platform_cls_map[platform_config["type"]] | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -136,12 +136,14 @@ async def download_file(url: str, path: str, show_progress: bool = False) -> Non | |
| ) as session: | ||
| async with session.get(url, timeout=1800) as resp: | ||
| if resp.status != 200: | ||
| raise Exception(f"下载文件失败: {resp.status}") | ||
| logger.error( | ||
| f"Failed to download file from {url}. HTTP status code: {resp.status}" | ||
|
Comment on lines
+139
to
+140
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue (bug_risk): Non-200 responses are logged but no longer abort the download, which can lead to writing error pages as files. This change removes the early exit on non-200 responses, so the rest of the logic still runs and will likely save an error/empty response to |
||
| ) | ||
|
Comment on lines
+139
to
+141
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 在检测到 HTTP 状态码不为 200 时,代码仅记录了错误日志而不再抛出异常。这会导致程序继续执行后续逻辑(如读取 content-length),可能会引发后续的 AttributeError 或导致下载损坏的文件。建议保留抛出异常的逻辑,以确保在下载失败时及时中断。此外,根据项目规则,新增的功能(如文件下载处理)应包含相应的单元测试。 raise Exception(f"Failed to download file from {url}. HTTP status code: {resp.status}")References
|
||
| total_size = int(resp.headers.get("content-length", 0)) | ||
| downloaded_size = 0 | ||
| start_time = time.time() | ||
| if show_progress: | ||
| print(f"文件大小: {total_size / 1024:.2f} KB | 文件地址: {url}") | ||
| print(f"Downloading: {url} | Size: {total_size / 1024:.2f} KB") | ||
| with open(path, "wb") as f: | ||
| while True: | ||
| chunk = await resp.content.read(8192) | ||
|
|
@@ -157,13 +159,14 @@ async def download_file(url: str, path: str, show_progress: bool = False) -> Non | |
| ) | ||
| speed = downloaded_size / 1024 / elapsed_time # KB/s | ||
| print( | ||
| f"\r下载进度: {downloaded_size / total_size:.2%} 速度: {speed:.2f} KB/s", | ||
| f"\rProgress: {downloaded_size / total_size:.2%} Speed: {speed:.2f} KB/s", | ||
| end="", | ||
| ) | ||
| except (aiohttp.ClientConnectorSSLError, aiohttp.ClientConnectorCertificateError): | ||
| # 关闭SSL验证(仅在证书验证失败时作为fallback) | ||
| logger.warning( | ||
| "SSL 证书验证失败,已关闭 SSL 验证(不安全,仅用于临时下载)。请检查目标服务器的证书配置。" | ||
| f"SSL certificate verification failed for {url}. " | ||
| "Falling back to unverified connection (CERT_NONE). " | ||
| ) | ||
|
Comment on lines
167
to
170
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| logger.warning( | ||
| f"SSL certificate verification failed for {url}. " | ||
|
|
@@ -180,7 +183,7 @@ async def download_file(url: str, path: str, show_progress: bool = False) -> Non | |
| downloaded_size = 0 | ||
| start_time = time.time() | ||
| if show_progress: | ||
| print(f"文件大小: {total_size / 1024:.2f} KB | 文件地址: {url}") | ||
| print(f"Size: {total_size / 1024:.2f} KB | URL: {url}") | ||
| with open(path, "wb") as f: | ||
| while True: | ||
| chunk = await resp.content.read(8192) | ||
|
|
@@ -192,7 +195,7 @@ async def download_file(url: str, path: str, show_progress: bool = False) -> Non | |
| elapsed_time = time.time() - start_time | ||
| speed = downloaded_size / 1024 / elapsed_time # KB/s | ||
| print( | ||
| f"\r下载进度: {downloaded_size / total_size:.2%} 速度: {speed:.2f} KB/s", | ||
| f"\rProgress: {downloaded_size / total_size:.2%} Speed: {speed:.2f} KB/s", | ||
| end="", | ||
| ) | ||
| if show_progress: | ||
|
|
@@ -252,7 +255,7 @@ async def download_dashboard( | |
| ver_name = "latest" if latest else version | ||
| dashboard_release_url = f"https://astrbot-registry.soulter.top/download/astrbot-dashboard/{ver_name}/dist.zip" | ||
| logger.info( | ||
| f"准备下载指定发行版本的 AstrBot WebUI 文件: {dashboard_release_url}", | ||
| f"Downloading AstrBot WebUI from {dashboard_release_url}", | ||
| ) | ||
| try: | ||
| await download_file( | ||
|
|
@@ -274,7 +277,7 @@ async def download_dashboard( | |
| ) | ||
| else: | ||
| url = f"https://github.com/AstrBotDevs/astrbot-release-harbour/releases/download/release-{version}/dist.zip" | ||
| logger.info(f"准备下载指定版本的 AstrBot WebUI: {url}") | ||
| logger.info(f"Downloading AstrBot WebUI from {url}") | ||
| if proxy: | ||
| url = f"{proxy}/{url}" | ||
| await download_file(url, str(zip_path), show_progress=True) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,3 +4,5 @@ venv/ | |
| node_modules/ | ||
| .vitepress/cache | ||
| *dist | ||
| scripts/deploy-cli.sh | ||
| scripts/deploy-cli.ps1 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import { chmod, copyFile, mkdir } from "node:fs/promises"; | ||
| import { dirname, resolve } from "node:path"; | ||
| import { fileURLToPath } from "node:url"; | ||
|
|
||
| const scriptDir = dirname(fileURLToPath(import.meta.url)); | ||
| const repoRoot = resolve(scriptDir, "../.."); | ||
|
|
||
| const files = [ | ||
| { name: "deploy-cli.sh", mode: 0o755 }, | ||
| { name: "deploy-cli.ps1", mode: 0o644 }, | ||
| ]; | ||
|
|
||
| await mkdir(scriptDir, { recursive: true }); | ||
|
|
||
| for (const file of files) { | ||
| const source = resolve(repoRoot, "scripts", file.name); | ||
| const target = resolve(scriptDir, file.name); | ||
| await copyFile(source, target); | ||
| await chmod(target, file.mode); | ||
| console.log(`Copied ${file.name} to docs/scripts/`); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
变量 path_ 已定义但未在随后的日志消息中使用。建议在日志中包含该路径信息,以便用户明确是哪个配置项缺失。