Name | HardwareMonitor JSON |
Version |
1.0.0
JSON |
| download |
home_page | None |
Summary | Python import layer for the LibreHardwareMonitorLib assembly. |
upload_time | 2024-11-08 14:31:34 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.6 |
license | BSD 3-Clause License Copyright (c) 2022, Nicholas Feix All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. 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. 3. Neither the name of the copyright holder 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 HOLDER 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 |
monitoring
sensors
librehardwaremonitor
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# PyHardwareMonitor
Python Harware Monitor is a thin package layer for [`LibreHardwareMonitorLib`](https://github.com/LibreHardwareMonitor/LibreHardwareMonitor) using [`pythonnet`](https://github.com/pythonnet/pythonnet).
Libre Hardware Monitor, a fork of Open Hardware Monitor, is free software that can monitor the temperature sensors, fan speeds, voltages, load and clock speeds of your computer.
This package is mostly auto generated using the [`pythonstubs`](https://github.com/mcneel/pythonstubs) generator tool for .NET libraries.
Scripts for generating, altering and extending package resources are located in the [scripts folder](https://github.com/snip3rnick/PyHardwareMonitor/tree/main/scripts).
The purpose of this layer is the ability to provide extensive typing information and additional utilities around the LibreHardwareMonitorLib.
> **Note:** Python must have **admin privileges** for `HardwareMonitor` to be able to access all available sensors properly!
## Prerequisites
- Python 3.6+
- pythonnet
- .NET 4.7
## Installation
Install from PyPi directly
```
pip3 install HardwareMonitor
```
or install locally from source
```
git clone https://github.com/snip3rnick/PyHardwareMonitor
cd PyHardwareMonitor
pip3 install .
```
## Basic Usage
This simple example is a python adaptation of the [**C#** example of the LibreHardwareMonitor repository](https://github.com/LibreHardwareMonitor/LibreHardwareMonitor#whats-the-easiest-way-to-start).
```python
from HardwareMonitor.Hardware import * # equivalent to 'using LibreHardwareMonitor.Hardware;'
class UpdateVisitor(IVisitor):
__namespace__ = "TestHardwareMonitor" # must be unique among implementations of the IVisitor interface
def VisitComputer(self, computer: IComputer):
computer.Traverse(self);
def VisitHardware(self, hardware: IHardware):
hardware.Update()
for subHardware in hardware.SubHardware:
subHardware.Update()
def VisitParameter(self, parameter: IParameter): pass
def VisitSensor(self, sensor: ISensor): pass
computer = Computer() # settings can not be passed as constructor argument (following below)
computer.IsMotherboardEnabled = True
computer.IsControllerEnabled = True
computer.IsCpuEnabled = True
computer.IsGpuEnabled = True
computer.IsBatteryEnabled = True
computer.IsMemoryEnabled = True
computer.IsNetworkEnabled = True
computer.IsStorageEnabled = True
computer.Open()
computer.Accept(UpdateVisitor())
for hardware in computer.Hardware:
print(f"Hardware: {hardware.Name}")
for subhardware in hardware.SubHardware:
print(f"\tSubhardware: {subhardware.Name}")
for sensor in subhardware.Sensors:
print(f"\t\tSensor: {sensor.Name}, value: {sensor.Value}")
for sensor in hardware.Sensors:
print(f"\tSensor: {sensor.Name}, value: {sensor.Value}")
computer.Close()
```
---
## Utilities
Utilities are located in the `HardwareMonitor.Util` module.
### Function `OpenComputer`
The `OpenComputer` function provides a shorthand for creating the `HardwareMonitor.Hardware.Computer` instance including the settings and update visitor.
Settings are given as keyword arguments, the following example enables just the `cpu` and `motherboard` component.
```python
computer = OpenComputer(cpu=True, motherboard=True) # use 'all=True' to enable every component
# Access sensors
...
computer.Update() # Updates all sensors
...
computer.Close()
```
### Function `ToBuiltinTypes`
Instances from the `HardwareMonitor` module can be reduced to primitive python types instead of `HardwareMonitor` object instances with the `ToBuiltinTypes` function.
Objects are recursively converted to Python builtin types (`dict`, `list`, ...).
This can be useful for applications that serialized the data (e.g. with json).
```python
computer = OpenComputer(cpu=True)
data = ToBuiltinTypes(computer.Hardware)
# [{'Type': 'Hardware', 'HardwareType': 'Cpu', 'Name': 'Intel Core i5-8265U', 'Sensors': [...], 'SubHardware': [...]}]
```
### Function `GroupSensorsByType`
Sensors of an instance of `HardwareMonitor.Harware.Hardware` are held in a flat list.
The helper function `GroupSensorsByType` converts the sensor list into a list of lists grouping sensors by type.
```python
GroupSensorsByType(sensors: Iterable[ISensor]) -> List[List[ISensor]]
```
### Function `SensorValueToString`
The helper function `SensorValueToString` converts sensor values to strings appending with the appropriate unit.
```python
SensorValueToString(value: float, type: SensorType) -> str
# returns "3100.0 MHz" for value=3100.0 with type=SensorType.Clock
```
### Dictionary `HardwareTypeString` and `SensorTypeString`
These two mappings convert values for `HardwareType` (or `SensorType`) to a string.
Both the integer value for the enum or the instances of the enum value (e.g. `HardwareType.Cpu`) are present as keys.
> In some environments the type fields were set to integers in others to the corresponding type instance.
Raw data
{
"_id": null,
"home_page": null,
"name": "HardwareMonitor",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": "monitoring, sensors, LibreHardwareMonitor",
"author": null,
"author_email": "Nicholas Feix <nf@fconsoft.com>",
"download_url": "https://files.pythonhosted.org/packages/11/59/22cd1a33464db6d6c6d45bff83a57d0590517f8259311950432f4fe11bef/hardwaremonitor-1.0.0.tar.gz",
"platform": null,
"description": "# PyHardwareMonitor\n\nPython Harware Monitor is a thin package layer for [`LibreHardwareMonitorLib`](https://github.com/LibreHardwareMonitor/LibreHardwareMonitor) using [`pythonnet`](https://github.com/pythonnet/pythonnet). \nLibre Hardware Monitor, a fork of Open Hardware Monitor, is free software that can monitor the temperature sensors, fan speeds, voltages, load and clock speeds of your computer. \nThis package is mostly auto generated using the [`pythonstubs`](https://github.com/mcneel/pythonstubs) generator tool for .NET libraries.\nScripts for generating, altering and extending package resources are located in the [scripts folder](https://github.com/snip3rnick/PyHardwareMonitor/tree/main/scripts).\n\nThe purpose of this layer is the ability to provide extensive typing information and additional utilities around the LibreHardwareMonitorLib.\n\n> **Note:** Python must have **admin privileges** for `HardwareMonitor` to be able to access all available sensors properly!\n\n\n## Prerequisites\n- Python 3.6+\n - pythonnet\n - .NET 4.7\n\n\n## Installation\n\nInstall from PyPi directly\n```\npip3 install HardwareMonitor\n```\n\nor install locally from source\n\n```\ngit clone https://github.com/snip3rnick/PyHardwareMonitor\ncd PyHardwareMonitor\npip3 install .\n```\n\n\n## Basic Usage\n\nThis simple example is a python adaptation of the [**C#** example of the LibreHardwareMonitor repository](https://github.com/LibreHardwareMonitor/LibreHardwareMonitor#whats-the-easiest-way-to-start).\n\n```python\nfrom HardwareMonitor.Hardware import * # equivalent to 'using LibreHardwareMonitor.Hardware;'\n\nclass UpdateVisitor(IVisitor):\n __namespace__ = \"TestHardwareMonitor\" # must be unique among implementations of the IVisitor interface\n def VisitComputer(self, computer: IComputer):\n computer.Traverse(self);\n\n def VisitHardware(self, hardware: IHardware):\n hardware.Update()\n for subHardware in hardware.SubHardware:\n subHardware.Update()\n\n def VisitParameter(self, parameter: IParameter): pass\n\n def VisitSensor(self, sensor: ISensor): pass\n\n\ncomputer = Computer() # settings can not be passed as constructor argument (following below)\ncomputer.IsMotherboardEnabled = True\ncomputer.IsControllerEnabled = True\ncomputer.IsCpuEnabled = True\ncomputer.IsGpuEnabled = True\ncomputer.IsBatteryEnabled = True\ncomputer.IsMemoryEnabled = True\ncomputer.IsNetworkEnabled = True\ncomputer.IsStorageEnabled = True\n\ncomputer.Open()\ncomputer.Accept(UpdateVisitor())\n\nfor hardware in computer.Hardware:\n print(f\"Hardware: {hardware.Name}\")\n for subhardware in hardware.SubHardware:\n print(f\"\\tSubhardware: {subhardware.Name}\")\n for sensor in subhardware.Sensors:\n print(f\"\\t\\tSensor: {sensor.Name}, value: {sensor.Value}\")\n for sensor in hardware.Sensors:\n print(f\"\\tSensor: {sensor.Name}, value: {sensor.Value}\")\n\ncomputer.Close()\n```\n\n---\n\n## Utilities\n\nUtilities are located in the `HardwareMonitor.Util` module.\n\n### Function `OpenComputer`\n\nThe `OpenComputer` function provides a shorthand for creating the `HardwareMonitor.Hardware.Computer` instance including the settings and update visitor. \nSettings are given as keyword arguments, the following example enables just the `cpu` and `motherboard` component.\n\n```python\ncomputer = OpenComputer(cpu=True, motherboard=True) # use 'all=True' to enable every component\n# Access sensors\n...\ncomputer.Update() # Updates all sensors\n...\ncomputer.Close()\n```\n\n### Function `ToBuiltinTypes`\n\nInstances from the `HardwareMonitor` module can be reduced to primitive python types instead of `HardwareMonitor` object instances with the `ToBuiltinTypes` function. \nObjects are recursively converted to Python builtin types (`dict`, `list`, ...).\nThis can be useful for applications that serialized the data (e.g. with json).\n\n```python\ncomputer = OpenComputer(cpu=True)\n\ndata = ToBuiltinTypes(computer.Hardware)\n# [{'Type': 'Hardware', 'HardwareType': 'Cpu', 'Name': 'Intel Core i5-8265U', 'Sensors': [...], 'SubHardware': [...]}]\n```\n\n### Function `GroupSensorsByType`\n\nSensors of an instance of `HardwareMonitor.Harware.Hardware` are held in a flat list. \nThe helper function `GroupSensorsByType` converts the sensor list into a list of lists grouping sensors by type.\n\n```python\nGroupSensorsByType(sensors: Iterable[ISensor]) -> List[List[ISensor]]\n```\n\n### Function `SensorValueToString`\n\nThe helper function `SensorValueToString` converts sensor values to strings appending with the appropriate unit.\n\n```python\nSensorValueToString(value: float, type: SensorType) -> str\n# returns \"3100.0 MHz\" for value=3100.0 with type=SensorType.Clock\n```\n\n### Dictionary `HardwareTypeString` and `SensorTypeString`\n\nThese two mappings convert values for `HardwareType` (or `SensorType`) to a string. \nBoth the integer value for the enum or the instances of the enum value (e.g. `HardwareType.Cpu`) are present as keys.\n\n> In some environments the type fields were set to integers in others to the corresponding type instance.\n",
"bugtrack_url": null,
"license": "BSD 3-Clause License Copyright (c) 2022, Nicholas Feix All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. 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. 3. Neither the name of the copyright holder 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 HOLDER 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. ",
"summary": "Python import layer for the LibreHardwareMonitorLib assembly.",
"version": "1.0.0",
"project_urls": {
"Repository": "https://github.com/snip3rnick/PyHardwareMonitor"
},
"split_keywords": [
"monitoring",
" sensors",
" librehardwaremonitor"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "f86a28dedd86cd6e7c37408b41301d519d11b343a969bf8a9ecd88f5ed8e4b69",
"md5": "becd23fa944f9e6b3e162ece5be5efbe",
"sha256": "61b8d9335f411c085c0b2ff5546256586dfdf7ebc4676bc0c74be623d5a4aecd"
},
"downloads": -1,
"filename": "HardwareMonitor-1.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "becd23fa944f9e6b3e162ece5be5efbe",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 462440,
"upload_time": "2024-11-08T14:31:31",
"upload_time_iso_8601": "2024-11-08T14:31:31.920429Z",
"url": "https://files.pythonhosted.org/packages/f8/6a/28dedd86cd6e7c37408b41301d519d11b343a969bf8a9ecd88f5ed8e4b69/HardwareMonitor-1.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "115922cd1a33464db6d6c6d45bff83a57d0590517f8259311950432f4fe11bef",
"md5": "cda3fde9044f2959f754c62f0af249b5",
"sha256": "9db2de2a01d2d12342f4809bd6e0b0c2f3b2167dfb36d93243d6a49f884a75f5"
},
"downloads": -1,
"filename": "hardwaremonitor-1.0.0.tar.gz",
"has_sig": false,
"md5_digest": "cda3fde9044f2959f754c62f0af249b5",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 462274,
"upload_time": "2024-11-08T14:31:34",
"upload_time_iso_8601": "2024-11-08T14:31:34.255640Z",
"url": "https://files.pythonhosted.org/packages/11/59/22cd1a33464db6d6c6d45bff83a57d0590517f8259311950432f4fe11bef/hardwaremonitor-1.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-08 14:31:34",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "snip3rnick",
"github_project": "PyHardwareMonitor",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "hardwaremonitor"
}