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.11+
  • 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.2.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.2-py3-none-any.whl (19.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: hdcutils-0.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 b18bb4c152f7d347044481db513ac8994b378b33533970138a74d0621ee6fef2
MD5 79ce29784392fa3767d54a03d14fc422
BLAKE2b-256 1a610b56a27a593d446d9b701baf55a7fbd23c33a8788cac1cba10f0e6cec2d8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: hdcutils-0.1.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8850bda3251ae89f9f2ceefe72f710d688bcd6186030ed862584f0b59f9f9534
MD5 0292b5815a0408847557f32f7b66c3b6
BLAKE2b-256 b43357f2d6faafc5a31d71a909df67d200efb0d899430459d9718d70aac968d3

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