Update plugin and code generation subprocess output (#1048)

This commit is contained in:
Wu Clan
2026-01-29 13:02:04 +08:00
committed by GitHub
parent ac19f8480f
commit 89f8fe141e
3 changed files with 22 additions and 28 deletions

1
.gitignore vendored
View File

@@ -9,3 +9,4 @@ venv/
.pytest_cache/
.claude/
.serena/
.agents/

View File

@@ -25,10 +25,10 @@ async def format_python_code(code: str) -> str:
'ruff',
'format',
str(temp_file),
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE,
stdout=asyncio.subprocess.DEVNULL,
stderr=asyncio.subprocess.DEVNULL,
)
await process.communicate()
await process.wait()
if process.returncode == 0:
async with await open_file(temp_file, encoding='utf-8') as f:

View File

@@ -57,32 +57,25 @@ def install_requirements(plugin: str | None) -> None: # noqa: C901
missing_dependencies = True
if missing_dependencies:
try:
pip_install = ['uv', 'pip', 'install', '-r', requirements_file]
if not _is_in_virtualenv():
pip_install.append('--system')
if settings.PLUGIN_PIP_CHINA:
pip_install.extend(['-i', settings.PLUGIN_PIP_INDEX_URL])
pip_install = ['uv', 'pip', 'install', '-r', requirements_file]
if not _is_in_virtualenv():
pip_install.append('--system')
if settings.PLUGIN_PIP_CHINA:
pip_install.extend(['-i', settings.PLUGIN_PIP_INDEX_URL])
max_retries = settings.PLUGIN_PIP_MAX_RETRY
for attempt in range(max_retries):
try:
subprocess.check_call(
pip_install,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
)
break
except subprocess.TimeoutExpired:
if attempt == max_retries - 1:
raise PluginInstallError(f'插件 {plugin} 依赖安装超时')
continue
except subprocess.CalledProcessError as e:
if attempt == max_retries - 1:
raise PluginInstallError(f'插件 {plugin} 依赖安装失败:{e}') from e
continue
except subprocess.CalledProcessError as e:
raise PluginInstallError(f'插件 {plugin} 依赖安装失败:{e}') from e
max_retries = settings.PLUGIN_PIP_MAX_RETRY
for attempt in range(max_retries):
try:
subprocess.check_call(pip_install)
break
except subprocess.TimeoutExpired:
if attempt == max_retries - 1:
raise PluginInstallError(f'插件 {plugin} 依赖安装超时')
continue
except subprocess.CalledProcessError as e:
if attempt == max_retries - 1:
raise PluginInstallError(f'插件 {plugin} 依赖安装失败:{e}') from e
continue
def uninstall_requirements(plugin: str) -> None: