ErisPulse 2.3.4.dev0__tar.gz → 2.3.4.dev114514__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {erispulse-2.3.4.dev0 → erispulse-2.3.4.dev114514}/PKG-INFO +1 -1
- {erispulse-2.3.4.dev0 → erispulse-2.3.4.dev114514}/pyproject.toml +1 -1
- {erispulse-2.3.4.dev0/src/ErisPulse/utils/cli → erispulse-2.3.4.dev114514/src/ErisPulse/CLI}/__init__.py +1 -1
- {erispulse-2.3.4.dev0/src/ErisPulse/utils/cli → erispulse-2.3.4.dev114514/src/ErisPulse/CLI}/__init__.pyi +1 -1
- erispulse-2.3.4.dev0/src/ErisPulse/utils/cli/__main__.py → erispulse-2.3.4.dev114514/src/ErisPulse/CLI/cli.py +3 -4
- erispulse-2.3.4.dev0/src/ErisPulse/utils/cli/__main__.pyi → erispulse-2.3.4.dev114514/src/ErisPulse/CLI/cli.pyi +2 -3
- {erispulse-2.3.4.dev0/src/ErisPulse/utils/cli → erispulse-2.3.4.dev114514/src/ErisPulse/CLI}/commands/init.py +4 -9
- {erispulse-2.3.4.dev0/src/ErisPulse/utils/cli → erispulse-2.3.4.dev114514/src/ErisPulse/CLI}/commands/init.pyi +2 -14
- {erispulse-2.3.4.dev0/src/ErisPulse/utils/cli → erispulse-2.3.4.dev114514/src/ErisPulse/CLI}/commands/install.py +2 -7
- {erispulse-2.3.4.dev0/src/ErisPulse/utils/cli → erispulse-2.3.4.dev114514/src/ErisPulse/CLI}/commands/install.pyi +2 -14
- {erispulse-2.3.4.dev0/src/ErisPulse/utils/cli → erispulse-2.3.4.dev114514/src/ErisPulse/CLI}/commands/list.py +2 -7
- {erispulse-2.3.4.dev0/src/ErisPulse/utils/cli → erispulse-2.3.4.dev114514/src/ErisPulse/CLI}/commands/list.pyi +2 -14
- {erispulse-2.3.4.dev0/src/ErisPulse/utils/cli → erispulse-2.3.4.dev114514/src/ErisPulse/CLI}/commands/list_remote.py +2 -7
- {erispulse-2.3.4.dev0/src/ErisPulse/utils/cli → erispulse-2.3.4.dev114514/src/ErisPulse/CLI}/commands/list_remote.pyi +2 -14
- {erispulse-2.3.4.dev0/src/ErisPulse/utils/cli → erispulse-2.3.4.dev114514/src/ErisPulse/CLI}/commands/run.py +3 -7
- {erispulse-2.3.4.dev0/src/ErisPulse/utils/cli → erispulse-2.3.4.dev114514/src/ErisPulse/CLI}/commands/run.pyi +2 -11
- {erispulse-2.3.4.dev0/src/ErisPulse/utils/cli → erispulse-2.3.4.dev114514/src/ErisPulse/CLI}/commands/self_update.py +2 -7
- {erispulse-2.3.4.dev0/src/ErisPulse/utils/cli → erispulse-2.3.4.dev114514/src/ErisPulse/CLI}/commands/self_update.pyi +2 -14
- {erispulse-2.3.4.dev0/src/ErisPulse/utils/cli → erispulse-2.3.4.dev114514/src/ErisPulse/CLI}/commands/uninstall.py +1 -6
- {erispulse-2.3.4.dev0/src/ErisPulse/utils/cli → erispulse-2.3.4.dev114514/src/ErisPulse/CLI}/commands/uninstall.pyi +1 -14
- {erispulse-2.3.4.dev0/src/ErisPulse/utils/cli → erispulse-2.3.4.dev114514/src/ErisPulse/CLI}/commands/upgrade.py +1 -7
- {erispulse-2.3.4.dev0/src/ErisPulse/utils/cli → erispulse-2.3.4.dev114514/src/ErisPulse/CLI}/commands/upgrade.pyi +1 -14
- {erispulse-2.3.4.dev0/src/ErisPulse → erispulse-2.3.4.dev114514/src/ErisPulse/CLI}/utils/__init__.py +1 -5
- {erispulse-2.3.4.dev0/src/ErisPulse → erispulse-2.3.4.dev114514/src/ErisPulse/CLI}/utils/__init__.pyi +0 -2
- {erispulse-2.3.4.dev0/src/ErisPulse → erispulse-2.3.4.dev114514/src/ErisPulse/CLI}/utils/package_manager.py +146 -20
- {erispulse-2.3.4.dev0/src/ErisPulse → erispulse-2.3.4.dev114514/src/ErisPulse/CLI}/utils/package_manager.pyi +20 -3
- {erispulse-2.3.4.dev0/src/ErisPulse → erispulse-2.3.4.dev114514/src/ErisPulse/CLI}/utils/reload_handler.py +7 -8
- {erispulse-2.3.4.dev0/src/ErisPulse → erispulse-2.3.4.dev114514/src/ErisPulse/CLI}/utils/reload_handler.pyi +1 -1
- {erispulse-2.3.4.dev0 → erispulse-2.3.4.dev114514}/src/ErisPulse/__main__.py +1 -1
- {erispulse-2.3.4.dev0 → erispulse-2.3.4.dev114514}/src/ErisPulse/__main__.pyi +1 -1
- {erispulse-2.3.4.dev0 → erispulse-2.3.4.dev114514}/.gitignore +0 -0
- {erispulse-2.3.4.dev0 → erispulse-2.3.4.dev114514}/LICENSE +0 -0
- {erispulse-2.3.4.dev0 → erispulse-2.3.4.dev114514}/README.md +0 -0
- {erispulse-2.3.4.dev0/src/ErisPulse/utils/cli → erispulse-2.3.4.dev114514/src/ErisPulse/CLI}/base.py +0 -0
- {erispulse-2.3.4.dev0/src/ErisPulse/utils/cli → erispulse-2.3.4.dev114514/src/ErisPulse/CLI}/base.pyi +0 -0
- {erispulse-2.3.4.dev0/src/ErisPulse/utils/cli → erispulse-2.3.4.dev114514/src/ErisPulse/CLI}/commands/__init__.py +0 -0
- {erispulse-2.3.4.dev0/src/ErisPulse/utils/cli → erispulse-2.3.4.dev114514/src/ErisPulse/CLI}/commands/__init__.pyi +0 -0
- {erispulse-2.3.4.dev0/src/ErisPulse/utils → erispulse-2.3.4.dev114514/src/ErisPulse/CLI}/console.py +0 -0
- {erispulse-2.3.4.dev0/src/ErisPulse/utils → erispulse-2.3.4.dev114514/src/ErisPulse/CLI}/console.pyi +0 -0
- {erispulse-2.3.4.dev0/src/ErisPulse/utils/cli → erispulse-2.3.4.dev114514/src/ErisPulse/CLI}/registry.py +0 -0
- {erispulse-2.3.4.dev0/src/ErisPulse/utils/cli → erispulse-2.3.4.dev114514/src/ErisPulse/CLI}/registry.pyi +0 -0
- {erispulse-2.3.4.dev0 → erispulse-2.3.4.dev114514}/src/ErisPulse/Core/Bases/__init__.py +0 -0
- {erispulse-2.3.4.dev0 → erispulse-2.3.4.dev114514}/src/ErisPulse/Core/Bases/__init__.pyi +0 -0
- {erispulse-2.3.4.dev0 → erispulse-2.3.4.dev114514}/src/ErisPulse/Core/Bases/adapter.py +0 -0
- {erispulse-2.3.4.dev0 → erispulse-2.3.4.dev114514}/src/ErisPulse/Core/Bases/adapter.pyi +0 -0
- {erispulse-2.3.4.dev0 → erispulse-2.3.4.dev114514}/src/ErisPulse/Core/Bases/module.py +0 -0
- {erispulse-2.3.4.dev0 → erispulse-2.3.4.dev114514}/src/ErisPulse/Core/Bases/module.pyi +0 -0
- {erispulse-2.3.4.dev0 → erispulse-2.3.4.dev114514}/src/ErisPulse/Core/Event/__init__.py +0 -0
- {erispulse-2.3.4.dev0 → erispulse-2.3.4.dev114514}/src/ErisPulse/Core/Event/__init__.pyi +0 -0
- {erispulse-2.3.4.dev0 → erispulse-2.3.4.dev114514}/src/ErisPulse/Core/Event/base.py +0 -0
- {erispulse-2.3.4.dev0 → erispulse-2.3.4.dev114514}/src/ErisPulse/Core/Event/base.pyi +0 -0
- {erispulse-2.3.4.dev0 → erispulse-2.3.4.dev114514}/src/ErisPulse/Core/Event/command.py +0 -0
- {erispulse-2.3.4.dev0 → erispulse-2.3.4.dev114514}/src/ErisPulse/Core/Event/command.pyi +0 -0
- {erispulse-2.3.4.dev0 → erispulse-2.3.4.dev114514}/src/ErisPulse/Core/Event/exceptions.py +0 -0
- {erispulse-2.3.4.dev0 → erispulse-2.3.4.dev114514}/src/ErisPulse/Core/Event/exceptions.pyi +0 -0
- {erispulse-2.3.4.dev0 → erispulse-2.3.4.dev114514}/src/ErisPulse/Core/Event/message.py +0 -0
- {erispulse-2.3.4.dev0 → erispulse-2.3.4.dev114514}/src/ErisPulse/Core/Event/message.pyi +0 -0
- {erispulse-2.3.4.dev0 → erispulse-2.3.4.dev114514}/src/ErisPulse/Core/Event/meta.py +0 -0
- {erispulse-2.3.4.dev0 → erispulse-2.3.4.dev114514}/src/ErisPulse/Core/Event/meta.pyi +0 -0
- {erispulse-2.3.4.dev0 → erispulse-2.3.4.dev114514}/src/ErisPulse/Core/Event/notice.py +0 -0
- {erispulse-2.3.4.dev0 → erispulse-2.3.4.dev114514}/src/ErisPulse/Core/Event/notice.pyi +0 -0
- {erispulse-2.3.4.dev0 → erispulse-2.3.4.dev114514}/src/ErisPulse/Core/Event/request.py +0 -0
- {erispulse-2.3.4.dev0 → erispulse-2.3.4.dev114514}/src/ErisPulse/Core/Event/request.pyi +0 -0
- {erispulse-2.3.4.dev0 → erispulse-2.3.4.dev114514}/src/ErisPulse/Core/Event/wrapper.py +0 -0
- {erispulse-2.3.4.dev0 → erispulse-2.3.4.dev114514}/src/ErisPulse/Core/Event/wrapper.pyi +0 -0
- {erispulse-2.3.4.dev0 → erispulse-2.3.4.dev114514}/src/ErisPulse/Core/__init__.py +0 -0
- {erispulse-2.3.4.dev0 → erispulse-2.3.4.dev114514}/src/ErisPulse/Core/__init__.pyi +0 -0
- {erispulse-2.3.4.dev0 → erispulse-2.3.4.dev114514}/src/ErisPulse/Core/_self_config.py +0 -0
- {erispulse-2.3.4.dev0 → erispulse-2.3.4.dev114514}/src/ErisPulse/Core/_self_config.pyi +0 -0
- {erispulse-2.3.4.dev0 → erispulse-2.3.4.dev114514}/src/ErisPulse/Core/adapter.py +0 -0
- {erispulse-2.3.4.dev0 → erispulse-2.3.4.dev114514}/src/ErisPulse/Core/adapter.pyi +0 -0
- {erispulse-2.3.4.dev0 → erispulse-2.3.4.dev114514}/src/ErisPulse/Core/config.py +0 -0
- {erispulse-2.3.4.dev0 → erispulse-2.3.4.dev114514}/src/ErisPulse/Core/config.pyi +0 -0
- {erispulse-2.3.4.dev0 → erispulse-2.3.4.dev114514}/src/ErisPulse/Core/exceptions.py +0 -0
- {erispulse-2.3.4.dev0 → erispulse-2.3.4.dev114514}/src/ErisPulse/Core/exceptions.pyi +0 -0
- {erispulse-2.3.4.dev0 → erispulse-2.3.4.dev114514}/src/ErisPulse/Core/lifecycle.py +0 -0
- {erispulse-2.3.4.dev0 → erispulse-2.3.4.dev114514}/src/ErisPulse/Core/lifecycle.pyi +0 -0
- {erispulse-2.3.4.dev0 → erispulse-2.3.4.dev114514}/src/ErisPulse/Core/logger.py +0 -0
- {erispulse-2.3.4.dev0 → erispulse-2.3.4.dev114514}/src/ErisPulse/Core/logger.pyi +0 -0
- {erispulse-2.3.4.dev0 → erispulse-2.3.4.dev114514}/src/ErisPulse/Core/module.py +0 -0
- {erispulse-2.3.4.dev0 → erispulse-2.3.4.dev114514}/src/ErisPulse/Core/module.pyi +0 -0
- {erispulse-2.3.4.dev0 → erispulse-2.3.4.dev114514}/src/ErisPulse/Core/router.py +0 -0
- {erispulse-2.3.4.dev0 → erispulse-2.3.4.dev114514}/src/ErisPulse/Core/router.pyi +0 -0
- {erispulse-2.3.4.dev0 → erispulse-2.3.4.dev114514}/src/ErisPulse/Core/storage.py +0 -0
- {erispulse-2.3.4.dev0 → erispulse-2.3.4.dev114514}/src/ErisPulse/Core/storage.pyi +0 -0
- {erispulse-2.3.4.dev0 → erispulse-2.3.4.dev114514}/src/ErisPulse/__init__.py +0 -0
- {erispulse-2.3.4.dev0 → erispulse-2.3.4.dev114514}/src/ErisPulse/__init__.pyi +0 -0
- {erispulse-2.3.4.dev0 → erispulse-2.3.4.dev114514}/src/ErisPulse/sdk_protocol.py +0 -0
- {erispulse-2.3.4.dev0 → erispulse-2.3.4.dev114514}/src/ErisPulse/sdk_protocol.pyi +0 -0
|
@@ -10,12 +10,11 @@ import importlib.metadata
|
|
|
10
10
|
import asyncio
|
|
11
11
|
import traceback
|
|
12
12
|
import pkgutil
|
|
13
|
-
from pathlib import Path
|
|
14
13
|
from argparse import ArgumentParser, RawDescriptionHelpFormatter
|
|
15
14
|
|
|
16
15
|
from rich.panel import Panel
|
|
17
16
|
|
|
18
|
-
from
|
|
17
|
+
from .console import console
|
|
19
18
|
from .registry import CommandRegistry
|
|
20
19
|
from .base import Command
|
|
21
20
|
|
|
@@ -43,7 +42,7 @@ class CLI:
|
|
|
43
42
|
parser = ArgumentParser(
|
|
44
43
|
prog="epsdk",
|
|
45
44
|
formatter_class=RawDescriptionHelpFormatter,
|
|
46
|
-
description="ErisPulse SDK
|
|
45
|
+
description="ErisPulse SDK 命令行工具",
|
|
47
46
|
)
|
|
48
47
|
parser._positionals.title = "命令"
|
|
49
48
|
parser._optionals.title = "选项"
|
|
@@ -79,7 +78,7 @@ class CLI:
|
|
|
79
78
|
并自动注册到命令注册表中。
|
|
80
79
|
"""
|
|
81
80
|
# 获取 commands 包的路径
|
|
82
|
-
commands_package = 'ErisPulse.
|
|
81
|
+
commands_package = 'ErisPulse.CLI.commands'
|
|
83
82
|
|
|
84
83
|
try:
|
|
85
84
|
# 遍历 commands 包中的所有模块
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# type: ignore
|
|
2
2
|
#
|
|
3
|
-
# Auto-generated type stub for
|
|
3
|
+
# Auto-generated type stub for cli.py
|
|
4
4
|
# DO NOT EDIT MANUALLY - Generated by generate-type-stubs.py
|
|
5
5
|
#
|
|
6
6
|
|
|
@@ -16,10 +16,9 @@ import importlib.metadata
|
|
|
16
16
|
import asyncio
|
|
17
17
|
import traceback
|
|
18
18
|
import pkgutil
|
|
19
|
-
from pathlib import Path
|
|
20
19
|
from argparse import ArgumentParser, RawDescriptionHelpFormatter
|
|
21
20
|
from rich.panel import Panel
|
|
22
|
-
from
|
|
21
|
+
from .console import console
|
|
23
22
|
from .registry import CommandRegistry
|
|
24
23
|
from .base import Command
|
|
25
24
|
|
|
@@ -12,23 +12,19 @@ from argparse import ArgumentParser
|
|
|
12
12
|
from pathlib import Path
|
|
13
13
|
from rich.prompt import Confirm, Prompt
|
|
14
14
|
|
|
15
|
-
from
|
|
16
|
-
from
|
|
15
|
+
from ..console import console
|
|
16
|
+
from ..utils import PackageManager
|
|
17
17
|
from ..base import Command
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
class InitCommand(Command):
|
|
21
|
-
"""初始化命令"""
|
|
22
|
-
|
|
23
21
|
name = "init"
|
|
24
|
-
description = "
|
|
22
|
+
description = "初始化 ErisPulse 项目"
|
|
25
23
|
|
|
26
24
|
def __init__(self):
|
|
27
|
-
"""初始化命令"""
|
|
28
25
|
self.package_manager = PackageManager()
|
|
29
26
|
|
|
30
27
|
def add_arguments(self, parser: ArgumentParser):
|
|
31
|
-
"""添加命令参数"""
|
|
32
28
|
parser.add_argument(
|
|
33
29
|
'--project-name', '-n',
|
|
34
30
|
help='项目名称 (可选,交互式初始化时将会询问)'
|
|
@@ -45,7 +41,6 @@ class InitCommand(Command):
|
|
|
45
41
|
)
|
|
46
42
|
|
|
47
43
|
def execute(self, args):
|
|
48
|
-
"""执行命令"""
|
|
49
44
|
if args.quick and args.project_name:
|
|
50
45
|
# 快速模式:只创建项目,不进行交互配置
|
|
51
46
|
success = self._init_project(args.project_name, [])
|
|
@@ -263,7 +258,7 @@ class InitCommand(Command):
|
|
|
263
258
|
:param adapter_names: 适配器名称列表
|
|
264
259
|
:param adapters_info: 适配器信息字典
|
|
265
260
|
"""
|
|
266
|
-
from
|
|
261
|
+
from ..utils import PackageManager
|
|
267
262
|
pkg_manager = PackageManager()
|
|
268
263
|
|
|
269
264
|
for adapter_name in adapter_names:
|
|
@@ -17,28 +17,16 @@ import sys
|
|
|
17
17
|
from argparse import ArgumentParser
|
|
18
18
|
from pathlib import Path
|
|
19
19
|
from rich.prompt import Confirm, Prompt
|
|
20
|
-
from
|
|
21
|
-
from
|
|
20
|
+
from ..console import console
|
|
21
|
+
from ..utils import PackageManager
|
|
22
22
|
from ..base import Command
|
|
23
23
|
|
|
24
24
|
class InitCommand(Command):
|
|
25
|
-
"""
|
|
26
|
-
初始化命令
|
|
27
|
-
"""
|
|
28
25
|
def __init__(self: None) -> ...:
|
|
29
|
-
"""
|
|
30
|
-
初始化命令
|
|
31
|
-
"""
|
|
32
26
|
...
|
|
33
27
|
def add_arguments(self: object, parser: ArgumentParser) -> ...:
|
|
34
|
-
"""
|
|
35
|
-
添加命令参数
|
|
36
|
-
"""
|
|
37
28
|
...
|
|
38
29
|
def execute(self: object, args: ...) -> ...:
|
|
39
|
-
"""
|
|
40
|
-
执行命令
|
|
41
|
-
"""
|
|
42
30
|
...
|
|
43
31
|
def _init_project(self: object, project_name: str, adapter_list: list = ...) -> bool:
|
|
44
32
|
"""
|
|
@@ -13,23 +13,19 @@ from rich.prompt import Confirm, Prompt
|
|
|
13
13
|
from rich.table import Table
|
|
14
14
|
from rich.box import SIMPLE
|
|
15
15
|
|
|
16
|
-
from
|
|
17
|
-
from
|
|
16
|
+
from ..utils import PackageManager
|
|
17
|
+
from ..console import console
|
|
18
18
|
from ..base import Command
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
class InstallCommand(Command):
|
|
22
|
-
"""安装命令"""
|
|
23
|
-
|
|
24
22
|
name = "install"
|
|
25
23
|
description = "安装模块/适配器包(不指定包名时进入交互式安装)"
|
|
26
24
|
|
|
27
25
|
def __init__(self):
|
|
28
|
-
"""初始化命令"""
|
|
29
26
|
self.package_manager = PackageManager()
|
|
30
27
|
|
|
31
28
|
def add_arguments(self, parser: ArgumentParser):
|
|
32
|
-
"""添加命令参数"""
|
|
33
29
|
parser.add_argument(
|
|
34
30
|
'package',
|
|
35
31
|
nargs='*',
|
|
@@ -47,7 +43,6 @@ class InstallCommand(Command):
|
|
|
47
43
|
)
|
|
48
44
|
|
|
49
45
|
def execute(self, args):
|
|
50
|
-
"""执行命令"""
|
|
51
46
|
if args.package:
|
|
52
47
|
# 批量安装
|
|
53
48
|
success = self.package_manager.install_package(
|
|
@@ -17,28 +17,16 @@ from rich.panel import Panel
|
|
|
17
17
|
from rich.prompt import Confirm, Prompt
|
|
18
18
|
from rich.table import Table
|
|
19
19
|
from rich.box import SIMPLE
|
|
20
|
-
from
|
|
21
|
-
from
|
|
20
|
+
from ..utils import PackageManager
|
|
21
|
+
from ..console import console
|
|
22
22
|
from ..base import Command
|
|
23
23
|
|
|
24
24
|
class InstallCommand(Command):
|
|
25
|
-
"""
|
|
26
|
-
安装命令
|
|
27
|
-
"""
|
|
28
25
|
def __init__(self: None) -> ...:
|
|
29
|
-
"""
|
|
30
|
-
初始化命令
|
|
31
|
-
"""
|
|
32
26
|
...
|
|
33
27
|
def add_arguments(self: object, parser: ArgumentParser) -> ...:
|
|
34
|
-
"""
|
|
35
|
-
添加命令参数
|
|
36
|
-
"""
|
|
37
28
|
...
|
|
38
29
|
def execute(self: object, args: ...) -> ...:
|
|
39
|
-
"""
|
|
40
|
-
执行命令
|
|
41
|
-
"""
|
|
42
30
|
...
|
|
43
31
|
def _interactive_install(self: object, upgrade: bool = ..., pre: bool = ...) -> ...:
|
|
44
32
|
"""
|
|
@@ -10,23 +10,19 @@ from argparse import ArgumentParser
|
|
|
10
10
|
from rich.table import Table
|
|
11
11
|
from rich.box import SIMPLE
|
|
12
12
|
|
|
13
|
-
from
|
|
14
|
-
from
|
|
13
|
+
from ..utils import PackageManager
|
|
14
|
+
from ..console import console
|
|
15
15
|
from ..base import Command
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
class ListCommand(Command):
|
|
19
|
-
"""列表命令"""
|
|
20
|
-
|
|
21
19
|
name = "list"
|
|
22
20
|
description = "列出已安装的组件"
|
|
23
21
|
|
|
24
22
|
def __init__(self):
|
|
25
|
-
"""初始化命令"""
|
|
26
23
|
self.package_manager = PackageManager()
|
|
27
24
|
|
|
28
25
|
def add_arguments(self, parser: ArgumentParser):
|
|
29
|
-
"""添加命令参数"""
|
|
30
26
|
parser.add_argument(
|
|
31
27
|
'--type', '-t',
|
|
32
28
|
choices=['modules', 'adapters', 'cli', 'all'],
|
|
@@ -40,7 +36,6 @@ class ListCommand(Command):
|
|
|
40
36
|
)
|
|
41
37
|
|
|
42
38
|
def execute(self, args):
|
|
43
|
-
"""执行命令"""
|
|
44
39
|
pkg_type = args.type
|
|
45
40
|
outdated_only = args.outdated
|
|
46
41
|
|
|
@@ -14,28 +14,16 @@ import asyncio
|
|
|
14
14
|
from argparse import ArgumentParser
|
|
15
15
|
from rich.table import Table
|
|
16
16
|
from rich.box import SIMPLE
|
|
17
|
-
from
|
|
18
|
-
from
|
|
17
|
+
from ..utils import PackageManager
|
|
18
|
+
from ..console import console
|
|
19
19
|
from ..base import Command
|
|
20
20
|
|
|
21
21
|
class ListCommand(Command):
|
|
22
|
-
"""
|
|
23
|
-
列表命令
|
|
24
|
-
"""
|
|
25
22
|
def __init__(self: None) -> ...:
|
|
26
|
-
"""
|
|
27
|
-
初始化命令
|
|
28
|
-
"""
|
|
29
23
|
...
|
|
30
24
|
def add_arguments(self: object, parser: ArgumentParser) -> ...:
|
|
31
|
-
"""
|
|
32
|
-
添加命令参数
|
|
33
|
-
"""
|
|
34
25
|
...
|
|
35
26
|
def execute(self: object, args: ...) -> ...:
|
|
36
|
-
"""
|
|
37
|
-
执行命令
|
|
38
|
-
"""
|
|
39
27
|
...
|
|
40
28
|
def _print_installed_packages(self: object, pkg_type: str, outdated_only: bool = ...) -> ...:
|
|
41
29
|
"""
|
|
@@ -10,23 +10,19 @@ from argparse import ArgumentParser
|
|
|
10
10
|
from rich.table import Table
|
|
11
11
|
from rich.box import SIMPLE
|
|
12
12
|
|
|
13
|
-
from
|
|
14
|
-
from
|
|
13
|
+
from ..utils import PackageManager
|
|
14
|
+
from ..console import console
|
|
15
15
|
from ..base import Command
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
class ListRemoteCommand(Command):
|
|
19
|
-
"""远程列表命令"""
|
|
20
|
-
|
|
21
19
|
name = "list-remote"
|
|
22
20
|
description = "列出远程可用的组件"
|
|
23
21
|
|
|
24
22
|
def __init__(self):
|
|
25
|
-
"""初始化命令"""
|
|
26
23
|
self.package_manager = PackageManager()
|
|
27
24
|
|
|
28
25
|
def add_arguments(self, parser: ArgumentParser):
|
|
29
|
-
"""添加命令参数"""
|
|
30
26
|
parser.add_argument(
|
|
31
27
|
'--type', '-t',
|
|
32
28
|
choices=['modules', 'adapters', 'cli', 'all'],
|
|
@@ -40,7 +36,6 @@ class ListRemoteCommand(Command):
|
|
|
40
36
|
)
|
|
41
37
|
|
|
42
38
|
def execute(self, args):
|
|
43
|
-
"""执行命令"""
|
|
44
39
|
pkg_type = args.type
|
|
45
40
|
force_refresh = args.refresh
|
|
46
41
|
|
|
@@ -14,28 +14,16 @@ import asyncio
|
|
|
14
14
|
from argparse import ArgumentParser
|
|
15
15
|
from rich.table import Table
|
|
16
16
|
from rich.box import SIMPLE
|
|
17
|
-
from
|
|
18
|
-
from
|
|
17
|
+
from ..utils import PackageManager
|
|
18
|
+
from ..console import console
|
|
19
19
|
from ..base import Command
|
|
20
20
|
|
|
21
21
|
class ListRemoteCommand(Command):
|
|
22
|
-
"""
|
|
23
|
-
远程列表命令
|
|
24
|
-
"""
|
|
25
22
|
def __init__(self: None) -> ...:
|
|
26
|
-
"""
|
|
27
|
-
初始化命令
|
|
28
|
-
"""
|
|
29
23
|
...
|
|
30
24
|
def add_arguments(self: object, parser: ArgumentParser) -> ...:
|
|
31
|
-
"""
|
|
32
|
-
添加命令参数
|
|
33
|
-
"""
|
|
34
25
|
...
|
|
35
26
|
def execute(self: object, args: ...) -> ...:
|
|
36
|
-
"""
|
|
37
|
-
执行命令
|
|
38
|
-
"""
|
|
39
27
|
...
|
|
40
28
|
def _print_remote_packages(self: object, pkg_type: str, force_refresh: bool = ...) -> ...:
|
|
41
29
|
"""
|
|
@@ -10,19 +10,16 @@ from argparse import ArgumentParser
|
|
|
10
10
|
from watchdog.observers import Observer
|
|
11
11
|
from rich.panel import Panel
|
|
12
12
|
|
|
13
|
-
from
|
|
14
|
-
from
|
|
13
|
+
from ..console import console
|
|
14
|
+
from ..utils import ReloadHandler
|
|
15
15
|
from ..base import Command
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
class RunCommand(Command):
|
|
19
|
-
"""运行命令"""
|
|
20
|
-
|
|
21
19
|
name = "run"
|
|
22
20
|
description = "运行主程序"
|
|
23
21
|
|
|
24
22
|
def add_arguments(self, parser: ArgumentParser):
|
|
25
|
-
"""添加命令参数"""
|
|
26
23
|
parser.add_argument(
|
|
27
24
|
'script',
|
|
28
25
|
nargs='?',
|
|
@@ -40,12 +37,11 @@ class RunCommand(Command):
|
|
|
40
37
|
)
|
|
41
38
|
|
|
42
39
|
def execute(self, args):
|
|
43
|
-
"""执行命令"""
|
|
44
40
|
script = args.script or "main.py"
|
|
45
41
|
|
|
46
42
|
# 检查脚本是否存在
|
|
47
43
|
if not os.path.exists(script):
|
|
48
|
-
from
|
|
44
|
+
from ... import _prepare_environment
|
|
49
45
|
import asyncio
|
|
50
46
|
asyncio.run(_prepare_environment())
|
|
51
47
|
|
|
@@ -15,23 +15,14 @@ import time
|
|
|
15
15
|
from argparse import ArgumentParser
|
|
16
16
|
from watchdog.observers import Observer
|
|
17
17
|
from rich.panel import Panel
|
|
18
|
-
from
|
|
19
|
-
from
|
|
18
|
+
from ..console import console
|
|
19
|
+
from ..utils import ReloadHandler
|
|
20
20
|
from ..base import Command
|
|
21
21
|
|
|
22
22
|
class RunCommand(Command):
|
|
23
|
-
"""
|
|
24
|
-
运行命令
|
|
25
|
-
"""
|
|
26
23
|
def add_arguments(self: object, parser: ArgumentParser) -> ...:
|
|
27
|
-
"""
|
|
28
|
-
添加命令参数
|
|
29
|
-
"""
|
|
30
24
|
...
|
|
31
25
|
def execute(self: object, args: ...) -> ...:
|
|
32
|
-
"""
|
|
33
|
-
执行命令
|
|
34
|
-
"""
|
|
35
26
|
...
|
|
36
27
|
def _setup_watchdog(self: object, script_path: str, reload_mode: bool) -> ...:
|
|
37
28
|
"""
|
|
@@ -10,23 +10,19 @@ from argparse import ArgumentParser
|
|
|
10
10
|
from rich.prompt import Confirm, Prompt
|
|
11
11
|
from rich.panel import Panel
|
|
12
12
|
|
|
13
|
-
from
|
|
14
|
-
from
|
|
13
|
+
from ..utils import PackageManager
|
|
14
|
+
from ..console import console
|
|
15
15
|
from ..base import Command
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
class SelfUpdateCommand(Command):
|
|
19
|
-
"""自更新命令"""
|
|
20
|
-
|
|
21
19
|
name = "self-update"
|
|
22
20
|
description = "更新 ErisPulse SDK 本身"
|
|
23
21
|
|
|
24
22
|
def __init__(self):
|
|
25
|
-
"""初始化命令"""
|
|
26
23
|
self.package_manager = PackageManager()
|
|
27
24
|
|
|
28
25
|
def add_arguments(self, parser: ArgumentParser):
|
|
29
|
-
"""添加命令参数"""
|
|
30
26
|
parser.add_argument(
|
|
31
27
|
'version',
|
|
32
28
|
nargs='?',
|
|
@@ -44,7 +40,6 @@ class SelfUpdateCommand(Command):
|
|
|
44
40
|
)
|
|
45
41
|
|
|
46
42
|
def execute(self, args):
|
|
47
|
-
"""执行命令"""
|
|
48
43
|
current_version = self.package_manager.get_installed_version()
|
|
49
44
|
console.print(Panel(
|
|
50
45
|
f"[title]ErisPulse SDK 自更新[/]\n"
|
|
@@ -15,28 +15,16 @@ import asyncio
|
|
|
15
15
|
from argparse import ArgumentParser
|
|
16
16
|
from rich.prompt import Confirm, Prompt
|
|
17
17
|
from rich.panel import Panel
|
|
18
|
-
from
|
|
19
|
-
from
|
|
18
|
+
from ..utils import PackageManager
|
|
19
|
+
from ..console import console
|
|
20
20
|
from ..base import Command
|
|
21
21
|
|
|
22
22
|
class SelfUpdateCommand(Command):
|
|
23
|
-
"""
|
|
24
|
-
自更新命令
|
|
25
|
-
"""
|
|
26
23
|
def __init__(self: None) -> ...:
|
|
27
|
-
"""
|
|
28
|
-
初始化命令
|
|
29
|
-
"""
|
|
30
24
|
...
|
|
31
25
|
def add_arguments(self: object, parser: ArgumentParser) -> ...:
|
|
32
|
-
"""
|
|
33
|
-
添加命令参数
|
|
34
|
-
"""
|
|
35
26
|
...
|
|
36
27
|
def execute(self: object, args: ...) -> ...:
|
|
37
|
-
"""
|
|
38
|
-
执行命令
|
|
39
|
-
"""
|
|
40
28
|
...
|
|
41
29
|
def _select_target_version(self: object, versions: ..., specified_version: str = ..., include_pre: bool = ...) -> str:
|
|
42
30
|
"""
|
|
@@ -7,23 +7,19 @@ Uninstall 命令实现
|
|
|
7
7
|
import sys
|
|
8
8
|
from argparse import ArgumentParser
|
|
9
9
|
|
|
10
|
-
from
|
|
11
|
-
from ...console import console
|
|
10
|
+
from ..utils import PackageManager
|
|
12
11
|
from ..base import Command
|
|
13
12
|
|
|
14
13
|
|
|
15
14
|
class UninstallCommand(Command):
|
|
16
|
-
"""卸载命令"""
|
|
17
15
|
|
|
18
16
|
name = "uninstall"
|
|
19
17
|
description = "卸载模块/适配器包"
|
|
20
18
|
|
|
21
19
|
def __init__(self):
|
|
22
|
-
"""初始化命令"""
|
|
23
20
|
self.package_manager = PackageManager()
|
|
24
21
|
|
|
25
22
|
def add_arguments(self, parser: ArgumentParser):
|
|
26
|
-
"""添加命令参数"""
|
|
27
23
|
parser.add_argument(
|
|
28
24
|
'package',
|
|
29
25
|
nargs='+',
|
|
@@ -31,7 +27,6 @@ class UninstallCommand(Command):
|
|
|
31
27
|
)
|
|
32
28
|
|
|
33
29
|
def execute(self, args):
|
|
34
|
-
"""执行命令"""
|
|
35
30
|
success = self.package_manager.uninstall_package(args.package)
|
|
36
31
|
if not success:
|
|
37
32
|
sys.exit(1)
|
|
@@ -12,26 +12,13 @@ Uninstall 命令实现
|
|
|
12
12
|
|
|
13
13
|
import sys
|
|
14
14
|
from argparse import ArgumentParser
|
|
15
|
-
from
|
|
16
|
-
from ...console import console
|
|
15
|
+
from ..utils import PackageManager
|
|
17
16
|
from ..base import Command
|
|
18
17
|
|
|
19
18
|
class UninstallCommand(Command):
|
|
20
|
-
"""
|
|
21
|
-
卸载命令
|
|
22
|
-
"""
|
|
23
19
|
def __init__(self: None) -> ...:
|
|
24
|
-
"""
|
|
25
|
-
初始化命令
|
|
26
|
-
"""
|
|
27
20
|
...
|
|
28
21
|
def add_arguments(self: object, parser: ArgumentParser) -> ...:
|
|
29
|
-
"""
|
|
30
|
-
添加命令参数
|
|
31
|
-
"""
|
|
32
22
|
...
|
|
33
23
|
def execute(self: object, args: ...) -> ...:
|
|
34
|
-
"""
|
|
35
|
-
执行命令
|
|
36
|
-
"""
|
|
37
24
|
...
|
|
@@ -8,23 +8,18 @@ import sys
|
|
|
8
8
|
from argparse import ArgumentParser
|
|
9
9
|
from rich.prompt import Confirm
|
|
10
10
|
|
|
11
|
-
from
|
|
12
|
-
from ...console import console
|
|
11
|
+
from ..utils import PackageManager
|
|
13
12
|
from ..base import Command
|
|
14
13
|
|
|
15
14
|
|
|
16
15
|
class UpgradeCommand(Command):
|
|
17
|
-
"""升级命令"""
|
|
18
|
-
|
|
19
16
|
name = "upgrade"
|
|
20
17
|
description = "升级组件(不指定包名则升级所有)"
|
|
21
18
|
|
|
22
19
|
def __init__(self):
|
|
23
|
-
"""初始化命令"""
|
|
24
20
|
self.package_manager = PackageManager()
|
|
25
21
|
|
|
26
22
|
def add_arguments(self, parser: ArgumentParser):
|
|
27
|
-
"""添加命令参数"""
|
|
28
23
|
parser.add_argument(
|
|
29
24
|
'package',
|
|
30
25
|
nargs='*',
|
|
@@ -42,7 +37,6 @@ class UpgradeCommand(Command):
|
|
|
42
37
|
)
|
|
43
38
|
|
|
44
39
|
def execute(self, args):
|
|
45
|
-
"""执行命令"""
|
|
46
40
|
if args.package:
|
|
47
41
|
# 升级指定包
|
|
48
42
|
success = self.package_manager.upgrade_package(
|
|
@@ -13,26 +13,13 @@ Upgrade 命令实现
|
|
|
13
13
|
import sys
|
|
14
14
|
from argparse import ArgumentParser
|
|
15
15
|
from rich.prompt import Confirm
|
|
16
|
-
from
|
|
17
|
-
from ...console import console
|
|
16
|
+
from ..utils import PackageManager
|
|
18
17
|
from ..base import Command
|
|
19
18
|
|
|
20
19
|
class UpgradeCommand(Command):
|
|
21
|
-
"""
|
|
22
|
-
升级命令
|
|
23
|
-
"""
|
|
24
20
|
def __init__(self: None) -> ...:
|
|
25
|
-
"""
|
|
26
|
-
初始化命令
|
|
27
|
-
"""
|
|
28
21
|
...
|
|
29
22
|
def add_arguments(self: object, parser: ArgumentParser) -> ...:
|
|
30
|
-
"""
|
|
31
|
-
添加命令参数
|
|
32
|
-
"""
|
|
33
23
|
...
|
|
34
24
|
def execute(self: object, args: ...) -> ...:
|
|
35
|
-
"""
|
|
36
|
-
执行命令
|
|
37
|
-
"""
|
|
38
25
|
...
|
{erispulse-2.3.4.dev0/src/ErisPulse → erispulse-2.3.4.dev114514/src/ErisPulse/CLI}/utils/__init__.py
RENAMED
|
@@ -6,12 +6,8 @@ ErisPulse SDK 工具模块
|
|
|
6
6
|
|
|
7
7
|
from .package_manager import PackageManager
|
|
8
8
|
from .reload_handler import ReloadHandler
|
|
9
|
-
from .cli import CLI
|
|
10
|
-
from .console import console
|
|
11
9
|
|
|
12
10
|
__all__ = [
|
|
13
11
|
"PackageManager",
|
|
14
|
-
"ReloadHandler"
|
|
15
|
-
"CLI",
|
|
16
|
-
"console",
|
|
12
|
+
"ReloadHandler"
|
|
17
13
|
]
|
|
@@ -17,7 +17,7 @@ from rich.panel import Panel
|
|
|
17
17
|
from rich.progress import Progress, BarColumn, TextColumn
|
|
18
18
|
from rich.prompt import Confirm
|
|
19
19
|
|
|
20
|
-
from
|
|
20
|
+
from ..console import console
|
|
21
21
|
|
|
22
22
|
class PackageManager:
|
|
23
23
|
"""
|
|
@@ -41,6 +41,8 @@ class PackageManager:
|
|
|
41
41
|
"""初始化包管理器"""
|
|
42
42
|
self._cache = {}
|
|
43
43
|
self._cache_time = {}
|
|
44
|
+
self._pypi_cache = {} # PyPI版本缓存
|
|
45
|
+
self._pypi_cache_time = {} # PyPI版本缓存时间
|
|
44
46
|
|
|
45
47
|
async def _fetch_remote_packages(self, url: str) -> Optional[dict]:
|
|
46
48
|
"""
|
|
@@ -204,27 +206,42 @@ class PackageManager:
|
|
|
204
206
|
async def _find_package_by_alias(self, alias: str) -> Optional[str]:
|
|
205
207
|
"""
|
|
206
208
|
通过别名查找实际包名(大小写不敏感)
|
|
209
|
+
支持查找已安装包和远程包
|
|
207
210
|
|
|
208
|
-
:param alias:
|
|
211
|
+
:param alias: 包别名或PyPI包名
|
|
209
212
|
:return: 实际包名,未找到返回None
|
|
210
213
|
"""
|
|
211
214
|
normalized_alias = self._normalize_name(alias)
|
|
212
215
|
remote_packages = await self.get_remote_packages()
|
|
213
216
|
|
|
217
|
+
# 首先检查是否是已安装包的PyPI包名
|
|
218
|
+
installed_package = self._find_installed_package_by_name(alias)
|
|
219
|
+
if installed_package:
|
|
220
|
+
return installed_package
|
|
221
|
+
|
|
214
222
|
# 检查模块
|
|
215
223
|
for name, info in remote_packages["modules"].items():
|
|
216
224
|
if self._normalize_name(name) == normalized_alias:
|
|
217
225
|
return info["package"]
|
|
226
|
+
# 同时检查PyPI包名
|
|
227
|
+
if self._normalize_name(info["package"]) == normalized_alias:
|
|
228
|
+
return info["package"]
|
|
218
229
|
|
|
219
230
|
# 检查适配器
|
|
220
231
|
for name, info in remote_packages["adapters"].items():
|
|
221
232
|
if self._normalize_name(name) == normalized_alias:
|
|
222
233
|
return info["package"]
|
|
234
|
+
# 同时检查PyPI包名
|
|
235
|
+
if self._normalize_name(info["package"]) == normalized_alias:
|
|
236
|
+
return info["package"]
|
|
223
237
|
|
|
224
238
|
# 检查CLI扩展
|
|
225
239
|
for name, info in remote_packages.get("cli_extensions", {}).items():
|
|
226
240
|
if self._normalize_name(name) == normalized_alias:
|
|
227
241
|
return info["package"]
|
|
242
|
+
# 同时检查PyPI包名
|
|
243
|
+
if self._normalize_name(info["package"]) == normalized_alias:
|
|
244
|
+
return info["package"]
|
|
228
245
|
|
|
229
246
|
return None
|
|
230
247
|
|
|
@@ -255,6 +272,80 @@ class PackageManager:
|
|
|
255
272
|
|
|
256
273
|
return None
|
|
257
274
|
|
|
275
|
+
async def check_package_updates(self) -> Dict[str, Tuple[str, str]]:
|
|
276
|
+
"""
|
|
277
|
+
检查包更新,对比本地版本和远程版本
|
|
278
|
+
|
|
279
|
+
:return: {包名: (当前版本, 最新版本)},仅包含有新版本的包
|
|
280
|
+
"""
|
|
281
|
+
installed = self.get_installed_packages()
|
|
282
|
+
remote_packages = await self.get_remote_packages()
|
|
283
|
+
|
|
284
|
+
updates = {}
|
|
285
|
+
|
|
286
|
+
# 构建远程包索引:PyPI包名 -> 版本
|
|
287
|
+
remote_index = {}
|
|
288
|
+
for pkg_type in ["modules", "adapters", "cli_extensions"]:
|
|
289
|
+
for name, info in remote_packages[pkg_type].items():
|
|
290
|
+
remote_index[info["package"]] = info["version"]
|
|
291
|
+
|
|
292
|
+
# 检查每个已安装包
|
|
293
|
+
for pkg_type in ["modules", "adapters", "cli_extensions"]:
|
|
294
|
+
for entry_name, pkg_info in installed[pkg_type].items():
|
|
295
|
+
current_version = pkg_info["version"]
|
|
296
|
+
package_name = pkg_info["package"]
|
|
297
|
+
|
|
298
|
+
# 检查远程是否有更新
|
|
299
|
+
if package_name in remote_index:
|
|
300
|
+
remote_version = remote_index[package_name]
|
|
301
|
+
|
|
302
|
+
# 比较版本
|
|
303
|
+
comparison = self._compare_versions(remote_version, current_version)
|
|
304
|
+
if comparison > 0: # 远程版本更新
|
|
305
|
+
updates[package_name] = (current_version, remote_version)
|
|
306
|
+
else:
|
|
307
|
+
# 如果远程找不到,尝试通过PyPI检查(使用pip show)
|
|
308
|
+
remote_version = await self._get_pypi_package_version(package_name)
|
|
309
|
+
if remote_version and self._compare_versions(remote_version, current_version) > 0:
|
|
310
|
+
updates[package_name] = (current_version, remote_version)
|
|
311
|
+
|
|
312
|
+
return updates
|
|
313
|
+
|
|
314
|
+
async def _get_pypi_package_version(self, package_name: str, force_refresh: bool = False) -> Optional[str]:
|
|
315
|
+
"""
|
|
316
|
+
从PyPI获取包的最新版本,带缓存机制
|
|
317
|
+
|
|
318
|
+
:param package_name: PyPI包名
|
|
319
|
+
:param force_refresh: 是否强制刷新缓存
|
|
320
|
+
:return: 最新版本号,失败返回None
|
|
321
|
+
"""
|
|
322
|
+
# 检查缓存
|
|
323
|
+
cache_key = package_name.lower()
|
|
324
|
+
if not force_refresh and cache_key in self._pypi_cache:
|
|
325
|
+
if time.time() - self._pypi_cache_time[cache_key] < self.CACHE_EXPIRY:
|
|
326
|
+
return self._pypi_cache[cache_key]
|
|
327
|
+
|
|
328
|
+
import aiohttp
|
|
329
|
+
from aiohttp import ClientError, ClientTimeout
|
|
330
|
+
|
|
331
|
+
timeout = ClientTimeout(total=10)
|
|
332
|
+
url = f"https://pypi.org/pypi/{package_name}/json"
|
|
333
|
+
|
|
334
|
+
try:
|
|
335
|
+
async with aiohttp.ClientSession(timeout=timeout) as session:
|
|
336
|
+
async with session.get(url) as response:
|
|
337
|
+
if response.status == 200:
|
|
338
|
+
data = await response.json()
|
|
339
|
+
version = data["info"]["version"]
|
|
340
|
+
# 更新缓存
|
|
341
|
+
self._pypi_cache[cache_key] = version
|
|
342
|
+
self._pypi_cache_time[cache_key] = time.time()
|
|
343
|
+
return version
|
|
344
|
+
except (ClientError, asyncio.TimeoutError, json.JSONDecodeError, KeyError) as e:
|
|
345
|
+
console.print(f"[warning]获取PyPI版本失败 ({package_name}): {e}[/]")
|
|
346
|
+
|
|
347
|
+
return None
|
|
348
|
+
|
|
258
349
|
def _run_pip_command_with_output(self, args: List[str], description: str) -> Tuple[bool, str, str]:
|
|
259
350
|
"""
|
|
260
351
|
执行pip命令并捕获输出
|
|
@@ -537,35 +628,42 @@ class PackageManager:
|
|
|
537
628
|
|
|
538
629
|
def upgrade_all(self) -> bool:
|
|
539
630
|
"""
|
|
540
|
-
|
|
631
|
+
升级所有有新版本的ErisPulse包
|
|
541
632
|
|
|
542
633
|
:return: 升级是否成功
|
|
543
634
|
|
|
544
635
|
:raises KeyboardInterrupt: 用户取消操作时抛出
|
|
545
636
|
"""
|
|
546
|
-
|
|
547
|
-
|
|
637
|
+
# 检查可更新的包
|
|
638
|
+
updates = asyncio.run(self.check_package_updates())
|
|
548
639
|
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
640
|
+
if not updates:
|
|
641
|
+
console.print("[success]所有ErisPulse包已是最新版本[/]")
|
|
642
|
+
return True
|
|
552
643
|
|
|
553
|
-
|
|
554
|
-
console.print("[info]没有找到可升级的ErisPulse包[/]")
|
|
555
|
-
return False
|
|
556
|
-
|
|
644
|
+
# 显示可升级的包列表
|
|
557
645
|
console.print(Panel(
|
|
558
|
-
f"找到 [bold]{len(
|
|
559
|
-
"\n".join(
|
|
646
|
+
f"找到 [bold]{len(updates)}[/] 个可升级的包:\n" +
|
|
647
|
+
"\n".join(
|
|
648
|
+
f" - [package]{pkg}[/] [dim]{current_ver}[/] → [success]{new_ver}[/]"
|
|
649
|
+
for pkg, (current_ver, new_ver) in updates.items()
|
|
650
|
+
),
|
|
560
651
|
title="升级列表"
|
|
561
652
|
))
|
|
562
653
|
|
|
563
|
-
if not Confirm.ask("
|
|
654
|
+
if not Confirm.ask("确认升级以上包吗?", default=False):
|
|
655
|
+
console.print("[info]操作已取消[/]")
|
|
564
656
|
return False
|
|
565
|
-
|
|
657
|
+
|
|
658
|
+
# 执行升级
|
|
566
659
|
results = {}
|
|
567
|
-
for pkg in sorted(
|
|
660
|
+
for pkg in sorted(updates.keys()):
|
|
661
|
+
console.print(f"\n[info]正在升级 [package]{pkg}[/]...")
|
|
568
662
|
results[pkg] = self.install_package([pkg], upgrade=True)
|
|
663
|
+
|
|
664
|
+
# 显示结果摘要
|
|
665
|
+
success_count = sum(1 for success in results.values() if success)
|
|
666
|
+
console.print(f"\n[success]升级完成: {success_count}/{len(results)} 个包成功[/]")
|
|
569
667
|
|
|
570
668
|
failed = [pkg for pkg, success in results.items() if not success]
|
|
571
669
|
if failed:
|
|
@@ -593,13 +691,41 @@ class PackageManager:
|
|
|
593
691
|
actual_package = asyncio.run(self._find_package_by_alias(package_name))
|
|
594
692
|
|
|
595
693
|
if actual_package:
|
|
596
|
-
console.print(f"[info]
|
|
694
|
+
console.print(f"[info]找到包: [package]{actual_package}[/][/]")
|
|
597
695
|
current_package_name = actual_package
|
|
598
696
|
else:
|
|
599
697
|
current_package_name = package_name
|
|
600
698
|
|
|
699
|
+
# 检查当前版本和远程版本
|
|
700
|
+
installed = self.get_installed_packages()
|
|
701
|
+
current_version = None
|
|
702
|
+
for pkg_type in ["modules", "adapters", "cli_extensions"]:
|
|
703
|
+
for pkg_info in installed[pkg_type].values():
|
|
704
|
+
if pkg_info["package"] == current_package_name:
|
|
705
|
+
current_version = pkg_info["version"]
|
|
706
|
+
break
|
|
707
|
+
if current_version:
|
|
708
|
+
break
|
|
709
|
+
|
|
710
|
+
# 获取远程版本
|
|
711
|
+
remote_version = asyncio.run(self._get_pypi_package_version(current_package_name))
|
|
712
|
+
|
|
713
|
+
# 显示版本信息
|
|
714
|
+
if current_version:
|
|
715
|
+
if remote_version:
|
|
716
|
+
comparison = self._compare_versions(remote_version, current_version)
|
|
717
|
+
if comparison <= 0:
|
|
718
|
+
console.print(f"[success]{current_package_name} 已是最新版本 ({current_version})[/]")
|
|
719
|
+
continue
|
|
720
|
+
else:
|
|
721
|
+
console.print(f"[info]{current_package_name}: {current_version} → {remote_version}[/]")
|
|
722
|
+
else:
|
|
723
|
+
console.print(f"[info]{current_package_name}: 当前版本 {current_version}[/]")
|
|
724
|
+
else:
|
|
725
|
+
console.print(f"[warning]未找到 {current_package_name} 的安装信息[/]")
|
|
726
|
+
|
|
601
727
|
# 检查SDK版本兼容性
|
|
602
|
-
package_info = asyncio.run(self._get_package_info(
|
|
728
|
+
package_info = asyncio.run(self._get_package_info(current_package_name))
|
|
603
729
|
if package_info and "min_sdk_version" in package_info:
|
|
604
730
|
is_compatible, message = self._check_sdk_compatibility(package_info["min_sdk_version"])
|
|
605
731
|
if not is_compatible:
|
|
@@ -842,4 +968,4 @@ except:
|
|
|
842
968
|
border_style="error"
|
|
843
969
|
))
|
|
844
970
|
|
|
845
|
-
return success
|
|
971
|
+
return success
|
|
@@ -21,7 +21,7 @@ from typing import List, Dict, Tuple, Optional, Any
|
|
|
21
21
|
from rich.panel import Panel
|
|
22
22
|
from rich.progress import Progress, BarColumn, TextColumn
|
|
23
23
|
from rich.prompt import Confirm
|
|
24
|
-
from
|
|
24
|
+
from ..console import console
|
|
25
25
|
|
|
26
26
|
class PackageManager:
|
|
27
27
|
"""
|
|
@@ -100,8 +100,9 @@ class PackageManager:
|
|
|
100
100
|
async def _find_package_by_alias(self: object, alias: str) -> Optional[str]:
|
|
101
101
|
"""
|
|
102
102
|
通过别名查找实际包名(大小写不敏感)
|
|
103
|
+
支持查找已安装包和远程包
|
|
103
104
|
|
|
104
|
-
:param alias:
|
|
105
|
+
:param alias: 包别名或PyPI包名
|
|
105
106
|
:return: 实际包名,未找到返回None
|
|
106
107
|
"""
|
|
107
108
|
...
|
|
@@ -113,6 +114,22 @@ class PackageManager:
|
|
|
113
114
|
:return: 实际包名,未找到返回None
|
|
114
115
|
"""
|
|
115
116
|
...
|
|
117
|
+
async def check_package_updates(self: object) -> Dict[(str, Tuple[(str, str)])]:
|
|
118
|
+
"""
|
|
119
|
+
检查包更新,对比本地版本和远程版本
|
|
120
|
+
|
|
121
|
+
:return: {包名: (当前版本, 最新版本)},仅包含有新版本的包
|
|
122
|
+
"""
|
|
123
|
+
...
|
|
124
|
+
async def _get_pypi_package_version(self: object, package_name: str, force_refresh: bool = ...) -> Optional[str]:
|
|
125
|
+
"""
|
|
126
|
+
从PyPI获取包的最新版本,带缓存机制
|
|
127
|
+
|
|
128
|
+
:param package_name: PyPI包名
|
|
129
|
+
:param force_refresh: 是否强制刷新缓存
|
|
130
|
+
:return: 最新版本号,失败返回None
|
|
131
|
+
"""
|
|
132
|
+
...
|
|
116
133
|
def _run_pip_command_with_output(self: object, args: List[str], description: str) -> Tuple[(bool, str, str)]:
|
|
117
134
|
"""
|
|
118
135
|
执行pip命令并捕获输出
|
|
@@ -167,7 +184,7 @@ class PackageManager:
|
|
|
167
184
|
...
|
|
168
185
|
def upgrade_all(self: object) -> bool:
|
|
169
186
|
"""
|
|
170
|
-
|
|
187
|
+
升级所有有新版本的ErisPulse包
|
|
171
188
|
|
|
172
189
|
:return: 升级是否成功
|
|
173
190
|
|
|
@@ -10,7 +10,7 @@ import sys
|
|
|
10
10
|
import time
|
|
11
11
|
from watchdog.events import FileSystemEventHandler
|
|
12
12
|
|
|
13
|
-
from
|
|
13
|
+
from ..console import console
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
class ReloadHandler(FileSystemEventHandler):
|
|
@@ -96,16 +96,15 @@ class ReloadHandler(FileSystemEventHandler):
|
|
|
96
96
|
:param event: 文件系统事件
|
|
97
97
|
:param reason: 重载原因
|
|
98
98
|
"""
|
|
99
|
-
from ErisPulse.Core import logger
|
|
100
99
|
|
|
101
100
|
try:
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
101
|
+
import asyncio
|
|
102
|
+
from ... import uninit
|
|
103
|
+
console.print(f"检测到文件变更 ({reason}),正在关闭适配器和模块...")
|
|
104
|
+
asyncio.run(uninit())
|
|
106
105
|
except Exception as e:
|
|
107
|
-
|
|
106
|
+
console.print(f"关闭适配器和模块时出错: {e}")
|
|
108
107
|
|
|
109
|
-
|
|
108
|
+
console.print("正在重启...")
|
|
110
109
|
self._terminate_process()
|
|
111
110
|
self.start_process()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{erispulse-2.3.4.dev0/src/ErisPulse/utils/cli → erispulse-2.3.4.dev114514/src/ErisPulse/CLI}/base.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{erispulse-2.3.4.dev0/src/ErisPulse/utils → erispulse-2.3.4.dev114514/src/ErisPulse/CLI}/console.py
RENAMED
|
File without changes
|
{erispulse-2.3.4.dev0/src/ErisPulse/utils → erispulse-2.3.4.dev114514/src/ErisPulse/CLI}/console.pyi
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|