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.
Requires
- 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.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)
Restart and wait for the reboot to complete
from hdcutils import HDCClient
d = HDCClient().device()
d.boot()
d.wait()
d.param.wait('bootevent.boot.completed', 'true')
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.4.tar.gz
(18.0 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
hdcutils-0.1.4-py3-none-any.whl
(21.8 kB
view details)
File details
Details for the file hdcutils-0.1.4.tar.gz.
File metadata
- Download URL: hdcutils-0.1.4.tar.gz
- Upload date:
- Size: 18.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.21
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d381d7f4bf698375b6ca990568f3d96c6ab6a3039865e9357122780dd31885aa
|
|
| MD5 |
6c001fc245f1cb564375b23ba37df7d8
|
|
| BLAKE2b-256 |
1c190a209a83b1c4f7b86b98f2efee6c87432da11d1e8c0f79ba39264f2d2562
|
File details
Details for the file hdcutils-0.1.4-py3-none-any.whl.
File metadata
- Download URL: hdcutils-0.1.4-py3-none-any.whl
- Upload date:
- Size: 21.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.21
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c0f325f660e68ebfaca88e0872b61bd17811bdf16c93ebf91cb0ef6df7382527
|
|
| MD5 |
7ac1a0b890f54bae66f58b80ef3cd9e5
|
|
| BLAKE2b-256 |
2a47ba368bf95474f37c5cb83b6397c3da26433b0492b22d056088300fb3e7b3
|