Skip to main content

Pure python hdc library for harmony hdc service.

Project description

HDC Utils

Pure python hdc library for harmony hdc service.

Support querying corresponding hdc commands and documentation via adb command.

Screenshot 2025-07-09 at 17 02 36

Requires

  • Python 3.10+
  • hdc
Install hdc without DevEco Studio
  1. Find command-line-tools in Download Center, and choose a release version to download. If the path is zh, you need to log in to your Huawei account first.
  2. Unzip the downloaded file to a directory, e.g ~/Library/Harmony/command-line-tools
  3. Set environment variable like:
export HARMONY_HOME=~/Library/Harmony
export PATH=${HARMONY_HOME}/command-line-tools/bin:${HARMONY_HOME}/command-line-tools/sdk/default/openharmony/toolchains:${PATH}
  1. Run hdc command to check if it works:
hdc checkserver
# Client version:Ver: 3.1.0e, server version:Ver: 3.1.0e

Install

pip3 install hdcutils

Usage

Search method & doc via adb command

from hdcutils import adb_mapping
result = adb_mapping.search_cmd(cmd='adb logcat -c')
print(result['example'])  # HDCClient().device().hilog.remove_buffer_log
print(result['doc'])  # https://developer.huawei.com/consumer/en/doc/harmonyos-guides/hilog#clearing-the-log-buffer

# Print full mapping
print(adb_mapping.mapping)

List all the devices and get device object

from hdcutils import HDCClient

# hdc = HDCClient(hdc='/path/to/hdc')
# If you don't set `hdc` path, it will try to find it in $PATH.
hdc = HDCClient()
for target in hdc.list_targets():
    d = hdc.device(connect_key=target)

Run shell command

from hdcutils import HDCClient
hdc = HDCClient()
# d = hdc.device(connect_key='device_connect_key')
# If you only have one device, you can use `hdc.device()` without arguments.
d = hdc.device()
out, err = d.shell(['echo', 'Hello World!'])
print(out)

License

Licensed under MIT - see LICENSE file. This is not an official Harmony product.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hdcutils-0.1.3.tar.gz (16.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hdcutils-0.1.3-py3-none-any.whl (19.1 kB view details)

Uploaded Python 3

File details

Details for the file hdcutils-0.1.3.tar.gz.

File metadata

  • Download URL: hdcutils-0.1.3.tar.gz
  • Upload date:
  • Size: 16.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.20

File hashes

Hashes for hdcutils-0.1.3.tar.gz
Algorithm Hash digest
SHA256 9bf39649e8185807553cc975927f207699a011678bae26357efcb022abaafbb1
MD5 1dab1bad3d8762ef842d26adcd4d9c19
BLAKE2b-256 0e69e921c8506a3d41a0370674d92b37592f564a401b9cbe9fb659948c314ffc

See more details on using hashes here.

File details

Details for the file hdcutils-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: hdcutils-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 19.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.20

File hashes

Hashes for hdcutils-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f31cdb898bb11002cfe4f0fc9e12ab440bfa7324e8d8a48db962936ad76737ce
MD5 38168bb78612d8ce2adfc39c81b5d6ce
BLAKE2b-256 39ffe4965380cf6c826d5d92cd40aa8320c8a87c11db61f86562a3ffb474e23a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page