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.2

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.2
File Size Uploaded
dailo_devtools-0.1.2.tar.gz 17.5 kB Details

Built distribution (wheel)

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

Total release size: 35.0 kB

Release files / dailo_devtools-0.1.2.tar.gz

Download URL dailo_devtools-0.1.2.tar.gz
Size 17.5 kB
Tags Source
SHA-256 checksum
How to use checksums
caf8a31d0d35c110cece814760db7ed3a20c2f69c7071d2cd4685681155952cd
BLAKE2b-256 checksum
How to use checksums
7a8dedda4f850736d9ce64d69f374fdc9119eddec33af549d97229e462e2464f
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.2-py3-none-any.whl

Download URL dailo_devtools-0.1.2-py3-none-any.whl
Size 17.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
56402d922a6d3c10d71e5629934a37fa372cfb551bbddc6f263fd193e3acd095
BLAKE2b-256 checksum
How to use checksums
ee8061657d9d2fa10061ce36153e4758db13562d8c307dca5554c054f5c786f1
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

This release

0.1.2 This release

2 release files

0.1.1

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