pyectool


Namepyectool JSON
Version 0.2.0 PyPI version JSON
download
home_pageNone
SummaryPyectool provides Python bindings for interacting with the Embedded Controller (EC) on ChromeOS and Framework devices, enabling seamless integration with other applications
upload_time2025-08-03 15:00:39
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseCopyright 2010 The ChromiumOS Authors Additions copyright 2024 Dustin L. Howett Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Google LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
keywords ectool embedded controller ec pybind11 bindings
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Pyectool

**Pyectool** provides Python bindings for interacting with the Embedded Controller (EC) on ChromeOS and Framework devices.  
It is extracted from and based on [Dustin Howett's `ectool`](https://gitlab.howett.net/DHowett/ectool) and exposes EC control functions directly to Python via a native C++ extension built with `pybind11`.

Pyectool also provides a simple way to build the original `ectool` CLI tool, or to build `libectool`—a standalone C library that wrap most of ectool’s functionality, making it reusable in C/C++ projects or accessible from other languages. Both the CLI binary and the library are built automatically during installation.

## Features
- Python-native interface to low-level EC functionality via `pybind11`
- Supports fan duty control, temperature reading, AC power status, and more.
- Designed for hardware monitoring, thermal management, and fan control tooling.
- Bundles the native `ectool` CLI and `libectool` C library alongside the Python package:
  * `pyectool/bin/ectool`  (ectool CLI)
  * `pyectool/lib/libectool.a` (libectool static library)
  * `pyectool/include/libectool.h` (libectool C header)

---

## Installation

### Prerequisites

Install system dependencies:

```sh
sudo apt update
sudo apt install -y libusb-1.0-0-dev libftdi1-dev pkg-config
````
### Clone the repository

### Install the package

#### Option 1: System-wide (not recommended unless you know what you're doing)
```sh
sudo pip install .
```
Or:

```bash
sudo env "PIP_BREAK_SYSTEM_PACKAGES=1" pip install .
```
(Required on modern distros like Ubuntu 24.04 due to PEP 668.)

#### Option 2: Isolated virtual environment (recommended)
```bash
python3 -m venv ~/.venv/pyectool
source ~/.venv/pyectool/bin/activate
pip install .
```

### ⚠️ Important Note

After installation, **do not run Python from inside the `libectool/` directory**. It contains a `pyectool/` folder that may shadow the installed package.

Instead, test from a different directory:

```bash
cd ..
python -c "from pyectool import ECController; ec = ECController(); print(ec.is_on_ac())"
```

If you're using a virtual environment and want to preserve its `PATH`, use:
```bash
cd ..
sudo env "PATH=$PATH" python -c "from pyectool import ECController; ec = ECController(); print(ec.is_on_ac())"
```
This ensures the correct Python from your virtual environment is used even with `sudo`.

---

## Usage

### Create an EC controller instance

```python
from pyectool import ECController

ec = ECController()
```

### Available Methods


| Method                                                  | Description                                                               |
| ------------------------------------------------------- | ------------------------------------------------------------------------- |
| `ec.is_on_ac() -> bool`                                 | Returns `True` if the system is on AC power, else `False`.                |
| `ec.get_num_fans() -> int`                              | Returns the number of fan devices detected.                               |
| `ec.enable_fan_auto_ctrl(fan_idx: int) -> None`         | Enables automatic fan control for a specific fan.                         |
| `ec.enable_all_fans_auto_ctrl() -> None`                | Enables automatic control for all fans.                                   |
| `ec.set_fan_duty(percent: int, fan_idx: int) -> None`   | Sets fan duty (speed) as a percentage for a specific fan.                 |
| `ec.set_all_fans_duty(percent: int) -> None`            | Sets the same duty percentage for all fans.                               |
| `ec.set_fan_rpm(target_rpm: int, fan_idx: int) -> None` | Sets a specific RPM target for a specific fan.                            |
| `ec.set_all_fans_rpm(target_rpm: int) -> None`          | Sets the same RPM target for all fans.                                    |
| `ec.get_fan_rpm(fan_idx: int) -> int`                   | Returns current RPM of a specific fan.                                    |
| `ec.get_all_fans_rpm() -> list[int]`                    | Returns a list of current RPM values for all fans.                        |
| `ec.get_num_temp_sensors() -> int`                      | Returns the total number of temperature sensors detected.                 |
| `ec.get_temp(sensor_idx: int) -> int`                   | Returns the temperature (in °C) for the given sensor index.               |
| `ec.get_all_temps() -> list[int]`                       | Returns a list of all sensor temperatures (in °C).                        |
| `ec.get_max_temp() -> int`                              | Returns the highest temperature across all sensors.                       |
| `ec.get_max_non_battery_temp() -> int`                  | Returns the highest temperature excluding battery-related sensors.        |
| `ec.get_temp_info(sensor_idx: int) -> ECTempInfo`       | Returns detailed info for a sensor, including name, type, and thresholds. |

---

### `ECTempInfo`

Returned by `get_temp_info()`, acts like a `dict` with:

* `sensor_name`: str
* `sensor_type`: int
* `temp`: int
* `temp_fan_off`: int
* `temp_fan_max`: int

---

## License

BSD 3-Clause License
See the `LICENSE` file for full terms.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "pyectool",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "ectool, embedded controller, EC, pybind11, bindings",
    "author": null,
    "author_email": "Ahmed Gamea <ahmed.gamea@ejust.edu.eg>",
    "download_url": "https://files.pythonhosted.org/packages/de/dd/7bb432481a951f427336fd173164705bd38f542ddb8def952850d3415625/pyectool-0.2.0.tar.gz",
    "platform": null,
    "description": "# Pyectool\n\n**Pyectool** provides Python bindings for interacting with the Embedded Controller (EC) on ChromeOS and Framework devices.  \nIt is extracted from and based on [Dustin Howett's `ectool`](https://gitlab.howett.net/DHowett/ectool) and exposes EC control functions directly to Python via a native C++ extension built with `pybind11`.\n\nPyectool also provides a simple way to build the original `ectool` CLI tool, or to build `libectool`\u2014a standalone C library that wrap most of ectool\u2019s functionality, making it reusable in C/C++ projects or accessible from other languages. Both the CLI binary and the library are built automatically during installation.\n\n## Features\n- Python-native interface to low-level EC functionality via `pybind11`\n- Supports fan duty control, temperature reading, AC power status, and more.\n- Designed for hardware monitoring, thermal management, and fan control tooling.\n- Bundles the native `ectool` CLI and `libectool` C library alongside the Python package:\n  * `pyectool/bin/ectool`  (ectool CLI)\n  * `pyectool/lib/libectool.a` (libectool static library)\n  * `pyectool/include/libectool.h` (libectool C header)\n\n---\n\n## Installation\n\n### Prerequisites\n\nInstall system dependencies:\n\n```sh\nsudo apt update\nsudo apt install -y libusb-1.0-0-dev libftdi1-dev pkg-config\n````\n### Clone the repository\n\n### Install the package\n\n#### Option 1: System-wide (not recommended unless you know what you're doing)\n```sh\nsudo pip install .\n```\nOr:\n\n```bash\nsudo env \"PIP_BREAK_SYSTEM_PACKAGES=1\" pip install .\n```\n(Required on modern distros like Ubuntu 24.04 due to PEP 668.)\n\n#### Option 2: Isolated virtual environment (recommended)\n```bash\npython3 -m venv ~/.venv/pyectool\nsource ~/.venv/pyectool/bin/activate\npip install .\n```\n\n### \u26a0\ufe0f Important Note\n\nAfter installation, **do not run Python from inside the `libectool/` directory**. It contains a `pyectool/` folder that may shadow the installed package.\n\nInstead, test from a different directory:\n\n```bash\ncd ..\npython -c \"from pyectool import ECController; ec = ECController(); print(ec.is_on_ac())\"\n```\n\nIf you're using a virtual environment and want to preserve its `PATH`, use:\n```bash\ncd ..\nsudo env \"PATH=$PATH\" python -c \"from pyectool import ECController; ec = ECController(); print(ec.is_on_ac())\"\n```\nThis ensures the correct Python from your virtual environment is used even with `sudo`.\n\n---\n\n## Usage\n\n### Create an EC controller instance\n\n```python\nfrom pyectool import ECController\n\nec = ECController()\n```\n\n### Available Methods\n\n\n| Method                                                  | Description                                                               |\n| ------------------------------------------------------- | ------------------------------------------------------------------------- |\n| `ec.is_on_ac() -> bool`                                 | Returns `True` if the system is on AC power, else `False`.                |\n| `ec.get_num_fans() -> int`                              | Returns the number of fan devices detected.                               |\n| `ec.enable_fan_auto_ctrl(fan_idx: int) -> None`         | Enables automatic fan control for a specific fan.                         |\n| `ec.enable_all_fans_auto_ctrl() -> None`                | Enables automatic control for all fans.                                   |\n| `ec.set_fan_duty(percent: int, fan_idx: int) -> None`   | Sets fan duty (speed) as a percentage for a specific fan.                 |\n| `ec.set_all_fans_duty(percent: int) -> None`            | Sets the same duty percentage for all fans.                               |\n| `ec.set_fan_rpm(target_rpm: int, fan_idx: int) -> None` | Sets a specific RPM target for a specific fan.                            |\n| `ec.set_all_fans_rpm(target_rpm: int) -> None`          | Sets the same RPM target for all fans.                                    |\n| `ec.get_fan_rpm(fan_idx: int) -> int`                   | Returns current RPM of a specific fan.                                    |\n| `ec.get_all_fans_rpm() -> list[int]`                    | Returns a list of current RPM values for all fans.                        |\n| `ec.get_num_temp_sensors() -> int`                      | Returns the total number of temperature sensors detected.                 |\n| `ec.get_temp(sensor_idx: int) -> int`                   | Returns the temperature (in \u00b0C) for the given sensor index.               |\n| `ec.get_all_temps() -> list[int]`                       | Returns a list of all sensor temperatures (in \u00b0C).                        |\n| `ec.get_max_temp() -> int`                              | Returns the highest temperature across all sensors.                       |\n| `ec.get_max_non_battery_temp() -> int`                  | Returns the highest temperature excluding battery-related sensors.        |\n| `ec.get_temp_info(sensor_idx: int) -> ECTempInfo`       | Returns detailed info for a sensor, including name, type, and thresholds. |\n\n---\n\n### `ECTempInfo`\n\nReturned by `get_temp_info()`, acts like a `dict` with:\n\n* `sensor_name`: str\n* `sensor_type`: int\n* `temp`: int\n* `temp_fan_off`: int\n* `temp_fan_max`: int\n\n---\n\n## License\n\nBSD 3-Clause License\nSee the `LICENSE` file for full terms.\n",
    "bugtrack_url": null,
    "license": "Copyright 2010 The ChromiumOS Authors\n         Additions copyright 2024 Dustin L. Howett\n         \n         Redistribution and use in source and binary forms, with or without\n         modification, are permitted provided that the following conditions are\n         met:\n         \n            * Redistributions of source code must retain the above copyright\n         notice, this list of conditions and the following disclaimer.\n            * Redistributions in binary form must reproduce the above\n         copyright notice, this list of conditions and the following disclaimer\n         in the documentation and/or other materials provided with the\n         distribution.\n            * Neither the name of Google LLC nor the names of its\n         contributors may be used to endorse or promote products derived from\n         this software without specific prior written permission.\n         \n         THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n         \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n         LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n         A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n         OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n         SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n         LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n         DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n         THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n         (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n         OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n         ",
    "summary": "Pyectool provides Python bindings for interacting with the Embedded Controller (EC) on ChromeOS and Framework devices, enabling seamless integration with other applications",
    "version": "0.2.0",
    "project_urls": {
        "Homepage": "https://github.com/CCExtractor/libectool",
        "Issues": "https://github.com/CCExtractor/libectool/issues"
    },
    "split_keywords": [
        "ectool",
        " embedded controller",
        " ec",
        " pybind11",
        " bindings"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "dedd7bb432481a951f427336fd173164705bd38f542ddb8def952850d3415625",
                "md5": "a74a0da4b538b2023902645271fc11da",
                "sha256": "26ba1a4531a1a0dfc2236227e0db01cdb807bd049b299f3bad1820f4573238a1"
            },
            "downloads": -1,
            "filename": "pyectool-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "a74a0da4b538b2023902645271fc11da",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 314532,
            "upload_time": "2025-08-03T15:00:39",
            "upload_time_iso_8601": "2025-08-03T15:00:39.764746Z",
            "url": "https://files.pythonhosted.org/packages/de/dd/7bb432481a951f427336fd173164705bd38f542ddb8def952850d3415625/pyectool-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-03 15:00:39",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "CCExtractor",
    "github_project": "libectool",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "pyectool"
}
        
Elapsed time: 0.56471s