autodlctl 0.1.0__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.
- autodlctl-0.1.0/.gitignore +22 -0
- autodlctl-0.1.0/LICENSE +21 -0
- autodlctl-0.1.0/PKG-INFO +250 -0
- autodlctl-0.1.0/README.md +197 -0
- autodlctl-0.1.0/pyproject.toml +65 -0
- autodlctl-0.1.0/src/autodlctl/__init__.py +5 -0
- autodlctl-0.1.0/src/autodlctl/__main__.py +5 -0
- autodlctl-0.1.0/src/autodlctl/cli.py +247 -0
- autodlctl-0.1.0/src/autodlctl/commands/__init__.py +1 -0
- autodlctl-0.1.0/src/autodlctl/commands/account.py +69 -0
- autodlctl-0.1.0/src/autodlctl/commands/generic.py +140 -0
- autodlctl-0.1.0/src/autodlctl/commands/instances.py +305 -0
- autodlctl-0.1.0/src/autodlctl/constants.py +98 -0
- autodlctl-0.1.0/src/autodlctl/models.py +11 -0
- autodlctl-0.1.0/src/autodlctl/page_ops.py +631 -0
- autodlctl-0.1.0/src/autodlctl/parsing.py +624 -0
- autodlctl-0.1.0/src/autodlctl/runtime.py +93 -0
- autodlctl-0.1.0/tests/conftest.py +10 -0
- autodlctl-0.1.0/tests/test_cli.py +82 -0
- autodlctl-0.1.0/tests/test_parsing.py +162 -0
- autodlctl-0.1.0/tools/autodl_console.py +19 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
.DS_Store
|
|
2
|
+
.idea/
|
|
3
|
+
.vscode/
|
|
4
|
+
|
|
5
|
+
.venv/
|
|
6
|
+
.pytest_cache/
|
|
7
|
+
.mypy_cache/
|
|
8
|
+
__pycache__/
|
|
9
|
+
*.pyc
|
|
10
|
+
|
|
11
|
+
build/
|
|
12
|
+
dist/
|
|
13
|
+
*.egg-info/
|
|
14
|
+
|
|
15
|
+
.autodl/
|
|
16
|
+
screenshots/
|
|
17
|
+
browser-shot.png
|
|
18
|
+
browser-shot*.png
|
|
19
|
+
storage_state.json
|
|
20
|
+
storage-state.json
|
|
21
|
+
*.storage_state.json
|
|
22
|
+
*.storage-state.json
|
autodlctl-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 LINGHAO ZHANG
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
autodlctl-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: autodlctl
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: CLI-first AutoDL console automation powered by Playwright.
|
|
5
|
+
Project-URL: Homepage, https://github.com/zlh123123/autodlctl
|
|
6
|
+
Project-URL: Repository, https://github.com/zlh123123/autodlctl
|
|
7
|
+
Project-URL: Issues, https://github.com/zlh123123/autodlctl/issues
|
|
8
|
+
Author: zlh123123
|
|
9
|
+
License: MIT License
|
|
10
|
+
|
|
11
|
+
Copyright (c) 2026 LINGHAO ZHANG
|
|
12
|
+
|
|
13
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
14
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
15
|
+
in the Software without restriction, including without limitation the rights
|
|
16
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
17
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
18
|
+
furnished to do so, subject to the following conditions:
|
|
19
|
+
|
|
20
|
+
The above copyright notice and this permission notice shall be included in all
|
|
21
|
+
copies or substantial portions of the Software.
|
|
22
|
+
|
|
23
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
24
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
25
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
26
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
27
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
28
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
29
|
+
SOFTWARE.
|
|
30
|
+
License-File: LICENSE
|
|
31
|
+
Keywords: autodl,automation,cli,playwright
|
|
32
|
+
Classifier: Development Status :: 3 - Alpha
|
|
33
|
+
Classifier: Environment :: Console
|
|
34
|
+
Classifier: Intended Audience :: Developers
|
|
35
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
36
|
+
Classifier: Operating System :: OS Independent
|
|
37
|
+
Classifier: Programming Language :: Python :: 3
|
|
38
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
39
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
40
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
41
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
42
|
+
Classifier: Topic :: Internet
|
|
43
|
+
Classifier: Topic :: System :: Systems Administration
|
|
44
|
+
Classifier: Topic :: Utilities
|
|
45
|
+
Requires-Python: >=3.10
|
|
46
|
+
Requires-Dist: playwright>=1.40
|
|
47
|
+
Provides-Extra: dev
|
|
48
|
+
Requires-Dist: build>=1.2.2; extra == 'dev'
|
|
49
|
+
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
|
|
50
|
+
Requires-Dist: pytest>=8.2; extra == 'dev'
|
|
51
|
+
Requires-Dist: twine>=5.1; extra == 'dev'
|
|
52
|
+
Description-Content-Type: text/markdown
|
|
53
|
+
|
|
54
|
+
# autodlctl
|
|
55
|
+
|
|
56
|
+
`autodlctl` 是一个基于 Playwright 的 AutoDL 控制台 CLI 工具,目标是把实例查询、开关机、详情读取、余额查询和登录状态保存做成可脚本化的命令行流程。
|
|
57
|
+
|
|
58
|
+
当前版本以 CLI 为主,适合:
|
|
59
|
+
|
|
60
|
+
- 在没有企业认证 API 的前提下,用浏览器自动化管理 AutoDL 实例
|
|
61
|
+
- 把登录态、实例选择、筛选和 SSH 信息提取接到脚本里
|
|
62
|
+
- 后续继续扩展成更完整的 AutoDL 自动化工具链
|
|
63
|
+
|
|
64
|
+
## 功能
|
|
65
|
+
|
|
66
|
+
- `auth`: 打开浏览器,等待手动登录并保存 Playwright storage state
|
|
67
|
+
- `list`: 列出实例并支持筛选、排序、限制条数
|
|
68
|
+
- `detail`: 读取实例详情面板和宿主机悬浮信息
|
|
69
|
+
- `start`: 启动实例,并在运行后复制 SSH 命令和密码
|
|
70
|
+
- `stop`: 关闭实例
|
|
71
|
+
- `inspect` / `status`: 输出当前页面可见控件和页面快照
|
|
72
|
+
- `balance`: 查询账户余额页中的当前余额
|
|
73
|
+
- `run`: 运行一组通用浏览器步骤,便于调试和扩展
|
|
74
|
+
|
|
75
|
+
## 安装
|
|
76
|
+
|
|
77
|
+
### 从 PyPI 安装
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
pip install autodlctl
|
|
81
|
+
playwright install chromium
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
说明:
|
|
85
|
+
|
|
86
|
+
- `pip install autodlctl` 只安装 Python 包,不会自动下载浏览器
|
|
87
|
+
- 首次运行时如果检测到 Chromium 缺失,CLI 会尝试自动执行 `playwright install chromium`
|
|
88
|
+
- 更稳妥的方式仍然是先手动执行一次 `playwright install chromium`
|
|
89
|
+
|
|
90
|
+
### 本地开发安装
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
python3 -m venv .venv
|
|
94
|
+
source .venv/bin/activate
|
|
95
|
+
python -m pip install --upgrade pip
|
|
96
|
+
python -m pip install -e .[dev]
|
|
97
|
+
playwright install chromium
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## 快速开始
|
|
101
|
+
|
|
102
|
+
### 1. 登录并保存状态
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
autodlctl auth \
|
|
106
|
+
--headless false \
|
|
107
|
+
--pause-seconds 180 \
|
|
108
|
+
--save-storage-state .autodl/storage_state.json
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
这条命令会打开 AutoDL 控制台,给你一段时间手动登录。命令结束后会把登录态保存到 `.autodl/storage_state.json`。
|
|
112
|
+
|
|
113
|
+
### 2. 查询实例
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
autodlctl list \
|
|
117
|
+
--storage-state .autodl/storage_state.json
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
按条件筛选:
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
autodlctl list \
|
|
124
|
+
--storage-state .autodl/storage_state.json \
|
|
125
|
+
--gpu-model 4090 \
|
|
126
|
+
--min-gpu-free 1 \
|
|
127
|
+
--sort-by rentable_until
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### 3. 查看详情
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
autodlctl detail \
|
|
134
|
+
--storage-state .autodl/storage_state.json \
|
|
135
|
+
--instance "你的实例名称或实例 ID"
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### 4. 开机 / 关机
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
autodlctl start \
|
|
142
|
+
--storage-state .autodl/storage_state.json \
|
|
143
|
+
--instance "你的实例名称或实例 ID"
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
autodlctl stop \
|
|
148
|
+
--storage-state .autodl/storage_state.json \
|
|
149
|
+
--instance "你的实例名称或实例 ID"
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
无卡模式开机:
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
autodlctl start \
|
|
156
|
+
--storage-state .autodl/storage_state.json \
|
|
157
|
+
--instance "你的实例名称或实例 ID" \
|
|
158
|
+
--mode nocard
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### 5. 查询余额
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
autodlctl balance \
|
|
165
|
+
--storage-state .autodl/storage_state.json
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## 通用步骤模式
|
|
169
|
+
|
|
170
|
+
如果你想调试页面元素或临时跑一串 Playwright 操作,可以用 `run`:
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
autodlctl run \
|
|
174
|
+
--storage-state .autodl/storage_state.json \
|
|
175
|
+
--steps '[{"op":"wait_for","selector":"body"},{"op":"title"}]'
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
也支持兼容旧脚本入口:
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
python3 tools/autodl_console.py list --storage-state .autodl/storage_state.json
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## 命令输出
|
|
185
|
+
|
|
186
|
+
CLI 统一输出 JSON,便于在 shell、Python 或其他脚本中消费。`0.x` 阶段会尽量保持这些顶层键稳定:
|
|
187
|
+
|
|
188
|
+
- `success`
|
|
189
|
+
- `reason`
|
|
190
|
+
- `container_id`
|
|
191
|
+
- `access`
|
|
192
|
+
- `detail`
|
|
193
|
+
- `instances`
|
|
194
|
+
- `filter`
|
|
195
|
+
- `sort`
|
|
196
|
+
|
|
197
|
+
## 项目结构
|
|
198
|
+
|
|
199
|
+
```text
|
|
200
|
+
src/autodlctl/
|
|
201
|
+
cli.py # argparse 入口与命令分发
|
|
202
|
+
runtime.py # 浏览器启动、storage state、资源关闭
|
|
203
|
+
parsing.py # 文本规范化、cookie 检查、列表过滤排序
|
|
204
|
+
page_ops.py # 页面交互与详情/tooltip 抓取
|
|
205
|
+
commands/
|
|
206
|
+
generic.py # run / inspect / status
|
|
207
|
+
instances.py # start / stop / detail / list / auth
|
|
208
|
+
account.py # balance
|
|
209
|
+
tools/autodl_console.py # 旧入口兼容包装
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
## 开发与测试
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
pytest
|
|
216
|
+
python -m build
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
如果只想验证 CLI 入口:
|
|
220
|
+
|
|
221
|
+
```bash
|
|
222
|
+
python -m autodlctl --help
|
|
223
|
+
autodlctl --help
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
## 发布到 PyPI
|
|
227
|
+
|
|
228
|
+
项目使用 GitHub Actions + Trusted Publisher。
|
|
229
|
+
|
|
230
|
+
建议发布流程:
|
|
231
|
+
|
|
232
|
+
1. 先在 TestPyPI 配置 trusted publisher
|
|
233
|
+
2. 在 GitHub Actions 手动触发 `release.yml`,选择 `testpypi`
|
|
234
|
+
3. 验证安装与命令入口
|
|
235
|
+
4. 在正式 PyPI 配置 trusted publisher
|
|
236
|
+
5. 更新版本号
|
|
237
|
+
6. 推送 `vX.Y.Z` tag 触发正式发布
|
|
238
|
+
|
|
239
|
+
本地构建命令:
|
|
240
|
+
|
|
241
|
+
```bash
|
|
242
|
+
python -m build
|
|
243
|
+
twine check dist/*
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
## 注意事项
|
|
247
|
+
|
|
248
|
+
- 这个项目依赖 AutoDL 当前网页结构,页面 DOM 变动后可能需要调整选择器
|
|
249
|
+
- storage state 实际上就是浏览器登录态,建议只保存在本地可信环境
|
|
250
|
+
- 某些操作会弹出确认框或宿主机悬浮层,CI 无法完全替代真实人工验证
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
# autodlctl
|
|
2
|
+
|
|
3
|
+
`autodlctl` 是一个基于 Playwright 的 AutoDL 控制台 CLI 工具,目标是把实例查询、开关机、详情读取、余额查询和登录状态保存做成可脚本化的命令行流程。
|
|
4
|
+
|
|
5
|
+
当前版本以 CLI 为主,适合:
|
|
6
|
+
|
|
7
|
+
- 在没有企业认证 API 的前提下,用浏览器自动化管理 AutoDL 实例
|
|
8
|
+
- 把登录态、实例选择、筛选和 SSH 信息提取接到脚本里
|
|
9
|
+
- 后续继续扩展成更完整的 AutoDL 自动化工具链
|
|
10
|
+
|
|
11
|
+
## 功能
|
|
12
|
+
|
|
13
|
+
- `auth`: 打开浏览器,等待手动登录并保存 Playwright storage state
|
|
14
|
+
- `list`: 列出实例并支持筛选、排序、限制条数
|
|
15
|
+
- `detail`: 读取实例详情面板和宿主机悬浮信息
|
|
16
|
+
- `start`: 启动实例,并在运行后复制 SSH 命令和密码
|
|
17
|
+
- `stop`: 关闭实例
|
|
18
|
+
- `inspect` / `status`: 输出当前页面可见控件和页面快照
|
|
19
|
+
- `balance`: 查询账户余额页中的当前余额
|
|
20
|
+
- `run`: 运行一组通用浏览器步骤,便于调试和扩展
|
|
21
|
+
|
|
22
|
+
## 安装
|
|
23
|
+
|
|
24
|
+
### 从 PyPI 安装
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
pip install autodlctl
|
|
28
|
+
playwright install chromium
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
说明:
|
|
32
|
+
|
|
33
|
+
- `pip install autodlctl` 只安装 Python 包,不会自动下载浏览器
|
|
34
|
+
- 首次运行时如果检测到 Chromium 缺失,CLI 会尝试自动执行 `playwright install chromium`
|
|
35
|
+
- 更稳妥的方式仍然是先手动执行一次 `playwright install chromium`
|
|
36
|
+
|
|
37
|
+
### 本地开发安装
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
python3 -m venv .venv
|
|
41
|
+
source .venv/bin/activate
|
|
42
|
+
python -m pip install --upgrade pip
|
|
43
|
+
python -m pip install -e .[dev]
|
|
44
|
+
playwright install chromium
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## 快速开始
|
|
48
|
+
|
|
49
|
+
### 1. 登录并保存状态
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
autodlctl auth \
|
|
53
|
+
--headless false \
|
|
54
|
+
--pause-seconds 180 \
|
|
55
|
+
--save-storage-state .autodl/storage_state.json
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
这条命令会打开 AutoDL 控制台,给你一段时间手动登录。命令结束后会把登录态保存到 `.autodl/storage_state.json`。
|
|
59
|
+
|
|
60
|
+
### 2. 查询实例
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
autodlctl list \
|
|
64
|
+
--storage-state .autodl/storage_state.json
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
按条件筛选:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
autodlctl list \
|
|
71
|
+
--storage-state .autodl/storage_state.json \
|
|
72
|
+
--gpu-model 4090 \
|
|
73
|
+
--min-gpu-free 1 \
|
|
74
|
+
--sort-by rentable_until
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### 3. 查看详情
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
autodlctl detail \
|
|
81
|
+
--storage-state .autodl/storage_state.json \
|
|
82
|
+
--instance "你的实例名称或实例 ID"
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### 4. 开机 / 关机
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
autodlctl start \
|
|
89
|
+
--storage-state .autodl/storage_state.json \
|
|
90
|
+
--instance "你的实例名称或实例 ID"
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
autodlctl stop \
|
|
95
|
+
--storage-state .autodl/storage_state.json \
|
|
96
|
+
--instance "你的实例名称或实例 ID"
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
无卡模式开机:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
autodlctl start \
|
|
103
|
+
--storage-state .autodl/storage_state.json \
|
|
104
|
+
--instance "你的实例名称或实例 ID" \
|
|
105
|
+
--mode nocard
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### 5. 查询余额
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
autodlctl balance \
|
|
112
|
+
--storage-state .autodl/storage_state.json
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## 通用步骤模式
|
|
116
|
+
|
|
117
|
+
如果你想调试页面元素或临时跑一串 Playwright 操作,可以用 `run`:
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
autodlctl run \
|
|
121
|
+
--storage-state .autodl/storage_state.json \
|
|
122
|
+
--steps '[{"op":"wait_for","selector":"body"},{"op":"title"}]'
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
也支持兼容旧脚本入口:
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
python3 tools/autodl_console.py list --storage-state .autodl/storage_state.json
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## 命令输出
|
|
132
|
+
|
|
133
|
+
CLI 统一输出 JSON,便于在 shell、Python 或其他脚本中消费。`0.x` 阶段会尽量保持这些顶层键稳定:
|
|
134
|
+
|
|
135
|
+
- `success`
|
|
136
|
+
- `reason`
|
|
137
|
+
- `container_id`
|
|
138
|
+
- `access`
|
|
139
|
+
- `detail`
|
|
140
|
+
- `instances`
|
|
141
|
+
- `filter`
|
|
142
|
+
- `sort`
|
|
143
|
+
|
|
144
|
+
## 项目结构
|
|
145
|
+
|
|
146
|
+
```text
|
|
147
|
+
src/autodlctl/
|
|
148
|
+
cli.py # argparse 入口与命令分发
|
|
149
|
+
runtime.py # 浏览器启动、storage state、资源关闭
|
|
150
|
+
parsing.py # 文本规范化、cookie 检查、列表过滤排序
|
|
151
|
+
page_ops.py # 页面交互与详情/tooltip 抓取
|
|
152
|
+
commands/
|
|
153
|
+
generic.py # run / inspect / status
|
|
154
|
+
instances.py # start / stop / detail / list / auth
|
|
155
|
+
account.py # balance
|
|
156
|
+
tools/autodl_console.py # 旧入口兼容包装
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## 开发与测试
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
pytest
|
|
163
|
+
python -m build
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
如果只想验证 CLI 入口:
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
python -m autodlctl --help
|
|
170
|
+
autodlctl --help
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
## 发布到 PyPI
|
|
174
|
+
|
|
175
|
+
项目使用 GitHub Actions + Trusted Publisher。
|
|
176
|
+
|
|
177
|
+
建议发布流程:
|
|
178
|
+
|
|
179
|
+
1. 先在 TestPyPI 配置 trusted publisher
|
|
180
|
+
2. 在 GitHub Actions 手动触发 `release.yml`,选择 `testpypi`
|
|
181
|
+
3. 验证安装与命令入口
|
|
182
|
+
4. 在正式 PyPI 配置 trusted publisher
|
|
183
|
+
5. 更新版本号
|
|
184
|
+
6. 推送 `vX.Y.Z` tag 触发正式发布
|
|
185
|
+
|
|
186
|
+
本地构建命令:
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
python -m build
|
|
190
|
+
twine check dist/*
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
## 注意事项
|
|
194
|
+
|
|
195
|
+
- 这个项目依赖 AutoDL 当前网页结构,页面 DOM 变动后可能需要调整选择器
|
|
196
|
+
- storage state 实际上就是浏览器登录态,建议只保存在本地可信环境
|
|
197
|
+
- 某些操作会弹出确认框或宿主机悬浮层,CI 无法完全替代真实人工验证
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling>=1.27"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "autodlctl"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "CLI-first AutoDL console automation powered by Playwright."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = { file = "LICENSE" }
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "zlh123123" }
|
|
14
|
+
]
|
|
15
|
+
keywords = ["autodl", "automation", "cli", "playwright"]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 3 - Alpha",
|
|
18
|
+
"Environment :: Console",
|
|
19
|
+
"Intended Audience :: Developers",
|
|
20
|
+
"License :: OSI Approved :: MIT License",
|
|
21
|
+
"Operating System :: OS Independent",
|
|
22
|
+
"Programming Language :: Python :: 3",
|
|
23
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
24
|
+
"Programming Language :: Python :: 3.10",
|
|
25
|
+
"Programming Language :: Python :: 3.11",
|
|
26
|
+
"Programming Language :: Python :: 3.12",
|
|
27
|
+
"Topic :: Internet",
|
|
28
|
+
"Topic :: System :: Systems Administration",
|
|
29
|
+
"Topic :: Utilities",
|
|
30
|
+
]
|
|
31
|
+
dependencies = [
|
|
32
|
+
"playwright>=1.40",
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
[project.optional-dependencies]
|
|
36
|
+
dev = [
|
|
37
|
+
"build>=1.2.2",
|
|
38
|
+
"pytest>=8.2",
|
|
39
|
+
"pytest-asyncio>=0.23",
|
|
40
|
+
"twine>=5.1",
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
[project.urls]
|
|
44
|
+
Homepage = "https://github.com/zlh123123/autodlctl"
|
|
45
|
+
Repository = "https://github.com/zlh123123/autodlctl"
|
|
46
|
+
Issues = "https://github.com/zlh123123/autodlctl/issues"
|
|
47
|
+
|
|
48
|
+
[project.scripts]
|
|
49
|
+
autodlctl = "autodlctl.cli:main"
|
|
50
|
+
|
|
51
|
+
[tool.hatch.build.targets.wheel]
|
|
52
|
+
packages = ["src/autodlctl"]
|
|
53
|
+
|
|
54
|
+
[tool.hatch.build.targets.sdist]
|
|
55
|
+
include = [
|
|
56
|
+
"/src",
|
|
57
|
+
"/tests",
|
|
58
|
+
"/tools",
|
|
59
|
+
"/README.md",
|
|
60
|
+
"/LICENSE",
|
|
61
|
+
"/pyproject.toml",
|
|
62
|
+
]
|
|
63
|
+
|
|
64
|
+
[tool.pytest.ini_options]
|
|
65
|
+
testpaths = ["tests"]
|