Skip to main content

Dailo DevTools

在电脑上运行和调试代劳 Android 自动化脚本。提供 dailo-dev 命令行工具和异步 Python 客户端,可执行脚本、读取文字与控件、保存截图和查看日志。

  • 命令行执行 Python 文件或短代码。
  • Python API 支持连接设备、截图、观察和停止运行。
  • 自动携带脚本目录中的 Python 模块与 assets/。
  • 图文日志保存到电脑,可离线查看。

安装

需要 Python 3.11 或更新版本,以及已安装代劳 App、开启 DevTools 的 Android 设备。

python -m pip install dailo-devtools
dailo-dev install

dailo-dev install 安装后台连接所需的 Chromium 运行时,只需执行一次。

连接设备

从代劳 App 的 DevTools 入口复制连接链接,保存为 connection.json:

{
  "url": "<从代劳 App 复制的 DevTools 链接>"
}

启动连接服务:

dailo-dev serve --connection connection.json

保持服务运行,在另一个终端执行后续命令。连接文件包含访问设备的凭据,请保存在本机;链接过期或重新连接时,从 App 获取新链接。

运行脚本

执行一段代码:

dailo-dev exec --code "from dailo import text; print(text())"

执行 Python 文件并传入任务设置:

dailo-dev exec --file main.py --config settings.json

脚本可使用 dailo-sdk 的文字、控件和图片定位 API。文件模式会自动上传脚本目录中的 Python 模块和 assets/;--timeout 设置执行时限,单位为秒,默认 300。

常用命令

命令 用途
dailo-dev status 查看连接和运行状态
dailo-dev inspect 读取设备画面的文字与控件
dailo-dev screenshot screen.png 保存设备截图
dailo-dev cancel 停止当前脚本
dailo-dev reconnect 使用持久连接配置重新连接设备
dailo-dev logs <日志目录> 离线查看图文日志

运行 dailo-dev --help 或 dailo-dev exec --help 查看完整选项。

Python API

import asyncio
import json
from pathlib import Path

from dailo_devtools import Device, read_logs


async def main():
    connection = json.loads(Path("connection.json").read_text(encoding="utf-8"))

    async with Device(connection) as device:
        result = await device.execute("from dailo import text; print(text())")
        await device.screenshot("screen.png")
        print(result)
        print(read_logs(result["logDirectory"]))


asyncio.run(main())

Device 还提供 run_file(path, config=...)、inspect() 和 cancel()。使用 Python 客户端时无需启动 dailo-dev serve;异步上下文管理器负责建立和关闭连接。

许可

MIT。

Metadata

Release files for dailo-devtools 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dailo-devtools 0.1.1
File Size Uploaded
dailo_devtools-0.1.1.tar.gz 17.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dailo-devtools 0.1.1
File Interpreter ABI Platform
dailo_devtools-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 34.9 kB

Release files / dailo_devtools-0.1.1.tar.gz

Download URL dailo_devtools-0.1.1.tar.gz
Size 17.4 kB
Tags Source
SHA-256 checksum
How to use checksums
9b290489b2840aa09664b8887ef4f4f743fa270447f40236c34c65df8b5f8182
BLAKE2b-256 checksum
How to use checksums
b0e2813ee212d03bd7413c420c25e06f8819b7273534a0e0b141ac4c4e6f09d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / dailo_devtools-0.1.1-py3-none-any.whl

Download URL dailo_devtools-0.1.1-py3-none-any.whl
Size 17.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3dc76ca807dfd9d5ca7cf5eae808746e37d9710f6c6067ea5eedcf83c0977e75
BLAKE2b-256 checksum
How to use checksums
630e56eb942dda79ab56ecda8bc976c465811c70cbb89b891e28eb9d0467dff4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

0.1.2

2 release files

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page