ubox-cli 0.0.1__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.
@@ -0,0 +1,35 @@
1
+ # 环境配置(包含敏感信息)
2
+ .env
3
+ .env.*
4
+ !env.example
5
+
6
+ # Python
7
+ __pycache__/
8
+ *.py[cod]
9
+ *$py.class
10
+ *.so
11
+ *.egg-info/
12
+ *.egg
13
+ dist/
14
+ build/
15
+ *.whl
16
+
17
+ # 虚拟环境
18
+ .venv/
19
+ venv/
20
+ ENV/
21
+
22
+ # IDE
23
+ .idea/
24
+ .vscode/
25
+ *.swp
26
+ *.swo
27
+ *~
28
+
29
+ # 日志
30
+ *.log
31
+ logs/
32
+
33
+ # 系统文件
34
+ .DS_Store
35
+ Thumbs.db
@@ -0,0 +1,41 @@
1
+ ## 环境
2
+
3
+ - Python 3.10+(<3.12)
4
+ - uv 包管理器
5
+
6
+ ## 安装依赖
7
+
8
+ ```bash
9
+ uv sync --index-url https://pypi.tuna.tsinghua.edu.cn/simple --extra-index-url https://mirrors.tencent.com/repository/pypi/tencent_pypi/simple
10
+ ```
11
+
12
+ ## 配置
13
+
14
+ ```bash
15
+ # 复制环境变量示例
16
+ cp env.example .env
17
+
18
+ # 编辑 .env 文件,填入Token
19
+ # UBOX_AUTH_TOKEN=your_token
20
+ ```
21
+
22
+ ## 测试
23
+
24
+ ```bash
25
+ uv run ubox-cli --help
26
+ uv run ubox-cli device-list
27
+ ```
28
+
29
+ ## 打包与分发
30
+
31
+ ```bash
32
+ # 构建 wheel 包(用于给用户安装)
33
+ uv build
34
+ # 产物:dist/ubox_cli-<version>-py3-none-any.whl
35
+ ```
36
+
37
+ ## 代码入口
38
+
39
+ - CLI入口:`src/ubox_cli/cli.py`(`main()`)
40
+ - 业务封装:`src/ubox_cli/ubox_handler.py`
41
+ - 配置管理:`src/ubox_cli/ubox_config.py`
@@ -0,0 +1,207 @@
1
+ Metadata-Version: 2.4
2
+ Name: ubox-cli
3
+ Version: 0.0.1
4
+ Summary: UBox CLI工具 - 通过命令行操作UBox设备自动化能力
5
+ Requires-Python: <3.12,>=3.10
6
+ Requires-Dist: click>=8.1.0
7
+ Requires-Dist: python-dotenv>=1.1.0
8
+ Requires-Dist: ubox-py-sdk==0.2.23.post2
9
+ Description-Content-Type: text/markdown
10
+
11
+ # UBox CLI 工具
12
+
13
+ 通过命令行操作 UBox 设备自动化能力,支持多设备管理。
14
+
15
+ ## 前置依赖
16
+
17
+ 本项目需要 Python >=3.10,<3.12,推荐使用 [uv](https://docs.astral.sh/uv/) 进行安装和管理。
18
+
19
+ ### 安装 uv
20
+
21
+ ```bash
22
+ # macOS / Linux
23
+ curl -LsSf https://astral.sh/uv/install.sh | sh
24
+
25
+ # Windows PowerShell
26
+ powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
27
+ ```
28
+
29
+ ## 安装
30
+
31
+ ```bash
32
+ # 方式1:从 wheel 文件安装
33
+ uv tool install --python 3.10.12 ubox_cli-0.2.0-py3-none-any.whl --index-url https://pypi.tuna.tsinghua.edu.cn/simple
34
+
35
+ # 方式2:从源码安装
36
+ cd ubox-cli
37
+ uv sync
38
+ ```
39
+
40
+ ## 快速上手
41
+
42
+ ### 1. 配置认证
43
+
44
+ 复制 `env.example` 为 `.env` 并填入 Token:
45
+
46
+ ```bash
47
+ cp env.example .env
48
+ ```
49
+
50
+ ```bash
51
+ UBOX_AUTH_TOKEN=your_token
52
+ ```
53
+
54
+ ### 2. 获取设备列表
55
+
56
+ ```bash
57
+ ubox-cli device list
58
+ ubox-cli device list --platform android
59
+ ubox-cli device list --platform ios --page-size 10
60
+ ```
61
+
62
+ ### 3. 连接设备
63
+
64
+ 连接设备后会按 **UDID** 自动保存连接信息到本地,后续操作无需手动传入:
65
+
66
+ > 所有设备连接信息统一保存在一个文件中:macOS `~/Library/Application Support/ubox-cli/connections.json`,Linux `~/.config/ubox-cli/connections.json`
67
+
68
+ ```bash
69
+ # 连接第一台设备
70
+ ubox-cli device connect --udid DEVICE_UDID_1 --os-type android
71
+
72
+ # 连接第二台设备(支持同时管理多台)
73
+ ubox-cli device connect --udid DEVICE_UDID_2 --os-type ios
74
+ ```
75
+
76
+ ### 4. 执行操作
77
+
78
+ 连接后直接执行命令,**默认使用最后连接的设备**:
79
+
80
+ ```bash
81
+ # 截图(使用默认设备)
82
+ ubox-cli screen screenshot
83
+
84
+ # 点击元素
85
+ ubox-cli action click --loc "//button[@text='确定']"
86
+
87
+ # 输入文本
88
+ ubox-cli action input-text --text "hello"
89
+
90
+ # 按键操作
91
+ ubox-cli action press --button HOME
92
+
93
+ # 获取UI树
94
+ ubox-cli find ui-tree
95
+ ```
96
+
97
+ **操作指定设备**(通过 `--udid` 参数):
98
+
99
+ ```bash
100
+ # 对第一台设备截图
101
+ ubox-cli screen screenshot --udid DEVICE_UDID_1
102
+
103
+ # 对第二台设备点击
104
+ ubox-cli action click --loc "//button[@text='OK']" --udid DEVICE_UDID_2
105
+ ```
106
+
107
+ 也可以手动指定连接信息(优先级最高):
108
+
109
+ ```bash
110
+ ubox-cli screen screenshot --conn-info '{"udid":"xxx","os_type":"android",...}'
111
+ ```
112
+
113
+ ### 5. 查看已连接设备
114
+
115
+ ```bash
116
+ ubox-cli device status
117
+ ```
118
+
119
+ ### 6. 断开设备
120
+
121
+ ```bash
122
+ # 断开默认设备
123
+ ubox-cli device disconnect
124
+
125
+ # 断开指定设备
126
+ ubox-cli device disconnect --udid DEVICE_UDID_1
127
+ ```
128
+
129
+ ### 7. 自动重连
130
+
131
+ 当设备连接过期时,CLI 会自动尝试使用保存的 UDID 和系统类型重新连接,并更新对应设备的本地连接信息,无需手动干预。
132
+
133
+ ## 命令结构
134
+
135
+ ```
136
+ ubox-cli
137
+ ├── device 设备管理
138
+ │ ├── list 获取可用设备列表
139
+ │ ├── connect 连接设备(按UDID保存)
140
+ │ ├── disconnect 断开设备连接
141
+ │ ├── status 查看所有已保存的连接
142
+ │ └── info 获取设备详细信息
143
+ ├── app 应用管理
144
+ │ ├── start 启动应用
145
+ │ ├── stop 停止应用
146
+ │ ├── current 获取当前运行的应用
147
+ │ ├── running 获取运行中的应用列表
148
+ │ ├── install 通过URL安装应用
149
+ │ ├── install-local 安装本地应用文件
150
+ │ └── uninstall 卸载应用
151
+ ├── action 交互操作
152
+ │ ├── click 智能点击(UI/CV/OCR/POS)
153
+ │ ├── click-pos 基于坐标点击
154
+ │ ├── long-click 长按操作
155
+ │ ├── slide 智能滑动
156
+ │ ├── slide-pos 基于坐标滑动
157
+ │ ├── input-text 输入文本
158
+ │ └── press 按键操作
159
+ ├── screen 截图录制
160
+ │ ├── screenshot 截图保存到本地
161
+ │ ├── screenshot-base64 获取Base64格式截图
162
+ │ ├── record-start 开始屏幕录制
163
+ │ └── record-stop 停止屏幕录制
164
+ ├── find UI查找
165
+ │ ├── ui UI控件查找
166
+ │ ├── ocr OCR文字查找
167
+ │ └── ui-tree 获取UI树结构
168
+ ├── clipboard 剪贴板操作
169
+ │ ├── set 设置剪贴板
170
+ │ └── get 获取剪贴板
171
+ ├── debug 调试诊断
172
+ │ ├── adb 执行ADB命令(仅Android/鸿蒙)
173
+ │ ├── logcat-start 开始Logcat采集(仅Android/鸿蒙)
174
+ │ ├── logcat-stop-all 停止所有Logcat任务(仅Android/鸿蒙)
175
+ │ ├── logcat-list 列出Logcat任务(仅Android/鸿蒙)
176
+ │ ├── perf-start 开始性能采集
177
+ │ ├── perf-stop 停止性能采集
178
+ │ ├── anr-start 开始ANR/Crash监控(仅Android/鸿蒙)
179
+ │ └── anr-stop 停止ANR/Crash监控(仅Android/鸿蒙)
180
+ └── version 获取版本信息
181
+ ```
182
+
183
+ ## 配置项
184
+
185
+ 所有配置通过 **环境变量** 或 **.env 文件** 设置:
186
+
187
+ | 配置项 | 环境变量 | 默认值 | 说明 |
188
+ |--------|---------|--------|------|
189
+ | Auth Token | `UBOX_AUTH_TOKEN` | - | Token 认证(必填) |
190
+ | 环境 | `UBOX_ENV` | `formal` | `formal` \| `test` |
191
+
192
+ ## 获取帮助
193
+
194
+ ```bash
195
+ # 查看所有命令组
196
+ ubox-cli --help
197
+
198
+ # 查看某个命令组的帮助
199
+ ubox-cli device --help
200
+ ubox-cli action --help
201
+ ubox-cli debug --help
202
+
203
+ # 查看具体子命令的帮助
204
+ ubox-cli device connect --help
205
+ ubox-cli action click --help
206
+ ubox-cli debug logcat-start --help
207
+ ```
@@ -0,0 +1,197 @@
1
+ # UBox CLI 工具
2
+
3
+ 通过命令行操作 UBox 设备自动化能力,支持多设备管理。
4
+
5
+ ## 前置依赖
6
+
7
+ 本项目需要 Python >=3.10,<3.12,推荐使用 [uv](https://docs.astral.sh/uv/) 进行安装和管理。
8
+
9
+ ### 安装 uv
10
+
11
+ ```bash
12
+ # macOS / Linux
13
+ curl -LsSf https://astral.sh/uv/install.sh | sh
14
+
15
+ # Windows PowerShell
16
+ powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
17
+ ```
18
+
19
+ ## 安装
20
+
21
+ ```bash
22
+ # 方式1:从 wheel 文件安装
23
+ uv tool install --python 3.10.12 ubox_cli-0.2.0-py3-none-any.whl --index-url https://pypi.tuna.tsinghua.edu.cn/simple
24
+
25
+ # 方式2:从源码安装
26
+ cd ubox-cli
27
+ uv sync
28
+ ```
29
+
30
+ ## 快速上手
31
+
32
+ ### 1. 配置认证
33
+
34
+ 复制 `env.example` 为 `.env` 并填入 Token:
35
+
36
+ ```bash
37
+ cp env.example .env
38
+ ```
39
+
40
+ ```bash
41
+ UBOX_AUTH_TOKEN=your_token
42
+ ```
43
+
44
+ ### 2. 获取设备列表
45
+
46
+ ```bash
47
+ ubox-cli device list
48
+ ubox-cli device list --platform android
49
+ ubox-cli device list --platform ios --page-size 10
50
+ ```
51
+
52
+ ### 3. 连接设备
53
+
54
+ 连接设备后会按 **UDID** 自动保存连接信息到本地,后续操作无需手动传入:
55
+
56
+ > 所有设备连接信息统一保存在一个文件中:macOS `~/Library/Application Support/ubox-cli/connections.json`,Linux `~/.config/ubox-cli/connections.json`
57
+
58
+ ```bash
59
+ # 连接第一台设备
60
+ ubox-cli device connect --udid DEVICE_UDID_1 --os-type android
61
+
62
+ # 连接第二台设备(支持同时管理多台)
63
+ ubox-cli device connect --udid DEVICE_UDID_2 --os-type ios
64
+ ```
65
+
66
+ ### 4. 执行操作
67
+
68
+ 连接后直接执行命令,**默认使用最后连接的设备**:
69
+
70
+ ```bash
71
+ # 截图(使用默认设备)
72
+ ubox-cli screen screenshot
73
+
74
+ # 点击元素
75
+ ubox-cli action click --loc "//button[@text='确定']"
76
+
77
+ # 输入文本
78
+ ubox-cli action input-text --text "hello"
79
+
80
+ # 按键操作
81
+ ubox-cli action press --button HOME
82
+
83
+ # 获取UI树
84
+ ubox-cli find ui-tree
85
+ ```
86
+
87
+ **操作指定设备**(通过 `--udid` 参数):
88
+
89
+ ```bash
90
+ # 对第一台设备截图
91
+ ubox-cli screen screenshot --udid DEVICE_UDID_1
92
+
93
+ # 对第二台设备点击
94
+ ubox-cli action click --loc "//button[@text='OK']" --udid DEVICE_UDID_2
95
+ ```
96
+
97
+ 也可以手动指定连接信息(优先级最高):
98
+
99
+ ```bash
100
+ ubox-cli screen screenshot --conn-info '{"udid":"xxx","os_type":"android",...}'
101
+ ```
102
+
103
+ ### 5. 查看已连接设备
104
+
105
+ ```bash
106
+ ubox-cli device status
107
+ ```
108
+
109
+ ### 6. 断开设备
110
+
111
+ ```bash
112
+ # 断开默认设备
113
+ ubox-cli device disconnect
114
+
115
+ # 断开指定设备
116
+ ubox-cli device disconnect --udid DEVICE_UDID_1
117
+ ```
118
+
119
+ ### 7. 自动重连
120
+
121
+ 当设备连接过期时,CLI 会自动尝试使用保存的 UDID 和系统类型重新连接,并更新对应设备的本地连接信息,无需手动干预。
122
+
123
+ ## 命令结构
124
+
125
+ ```
126
+ ubox-cli
127
+ ├── device 设备管理
128
+ │ ├── list 获取可用设备列表
129
+ │ ├── connect 连接设备(按UDID保存)
130
+ │ ├── disconnect 断开设备连接
131
+ │ ├── status 查看所有已保存的连接
132
+ │ └── info 获取设备详细信息
133
+ ├── app 应用管理
134
+ │ ├── start 启动应用
135
+ │ ├── stop 停止应用
136
+ │ ├── current 获取当前运行的应用
137
+ │ ├── running 获取运行中的应用列表
138
+ │ ├── install 通过URL安装应用
139
+ │ ├── install-local 安装本地应用文件
140
+ │ └── uninstall 卸载应用
141
+ ├── action 交互操作
142
+ │ ├── click 智能点击(UI/CV/OCR/POS)
143
+ │ ├── click-pos 基于坐标点击
144
+ │ ├── long-click 长按操作
145
+ │ ├── slide 智能滑动
146
+ │ ├── slide-pos 基于坐标滑动
147
+ │ ├── input-text 输入文本
148
+ │ └── press 按键操作
149
+ ├── screen 截图录制
150
+ │ ├── screenshot 截图保存到本地
151
+ │ ├── screenshot-base64 获取Base64格式截图
152
+ │ ├── record-start 开始屏幕录制
153
+ │ └── record-stop 停止屏幕录制
154
+ ├── find UI查找
155
+ │ ├── ui UI控件查找
156
+ │ ├── ocr OCR文字查找
157
+ │ └── ui-tree 获取UI树结构
158
+ ├── clipboard 剪贴板操作
159
+ │ ├── set 设置剪贴板
160
+ │ └── get 获取剪贴板
161
+ ├── debug 调试诊断
162
+ │ ├── adb 执行ADB命令(仅Android/鸿蒙)
163
+ │ ├── logcat-start 开始Logcat采集(仅Android/鸿蒙)
164
+ │ ├── logcat-stop-all 停止所有Logcat任务(仅Android/鸿蒙)
165
+ │ ├── logcat-list 列出Logcat任务(仅Android/鸿蒙)
166
+ │ ├── perf-start 开始性能采集
167
+ │ ├── perf-stop 停止性能采集
168
+ │ ├── anr-start 开始ANR/Crash监控(仅Android/鸿蒙)
169
+ │ └── anr-stop 停止ANR/Crash监控(仅Android/鸿蒙)
170
+ └── version 获取版本信息
171
+ ```
172
+
173
+ ## 配置项
174
+
175
+ 所有配置通过 **环境变量** 或 **.env 文件** 设置:
176
+
177
+ | 配置项 | 环境变量 | 默认值 | 说明 |
178
+ |--------|---------|--------|------|
179
+ | Auth Token | `UBOX_AUTH_TOKEN` | - | Token 认证(必填) |
180
+ | 环境 | `UBOX_ENV` | `formal` | `formal` \| `test` |
181
+
182
+ ## 获取帮助
183
+
184
+ ```bash
185
+ # 查看所有命令组
186
+ ubox-cli --help
187
+
188
+ # 查看某个命令组的帮助
189
+ ubox-cli device --help
190
+ ubox-cli action --help
191
+ ubox-cli debug --help
192
+
193
+ # 查看具体子命令的帮助
194
+ ubox-cli device connect --help
195
+ ubox-cli action click --help
196
+ ubox-cli debug logcat-start --help
197
+ ```