Pure python hdc library for harmony hdc service.
Support querying corresponding hdc commands and documentation via adb command.
- Python 3.10+
- hdc
Install hdc without DevEco Studio
- Find
command-line-toolsin Download Center, and choose a release version to download. If the path is zh, you need to log in to your Huawei account first. - Unzip the downloaded file to a directory, e.g
~/Library/Harmony/command-line-tools - 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}- Run
hdccommand to check if it works:
hdc checkserver
# Client version:Ver: 3.1.0e, server version:Ver: 3.1.0epip3 install hdcutilsfrom 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)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)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)from hdcutils import HDCClient
d = HDCClient().device()
d.boot()
d.wait()
d.param.wait('bootevent.boot.completed', 'true')Licensed under MIT - see LICENSE file. This is not an official Harmony product.