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.1.tar.gz (15.8 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.1-py3-none-any.whl (18.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for hdcutils-0.1.1.tar.gz
Algorithm Hash digest
SHA256 9cdcad9412444b93279283fb9743097ce00272ddf281e5a22c2f3eed9178409d
MD5 7614ee2823dca4eafcda0b127cfc98d9
BLAKE2b-256 3a0e5e464ac5d920429a6780ca546c0404cd8380d9a4d2bb1050d963aa362697

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for hdcutils-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9c314387dcba9484b2254b9b3e717fb0bc26e23d7f07407a9bc6242b6e8b7b86
MD5 751110099761c513e47eb6c5c2c4013c
BLAKE2b-256 608a85b782d586a5658085ac216125ec1d798f08754f0a67fcae4c61a54f0a73

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