pikvm-lib


Namepikvm-lib JSON
Version 0.4.2 PyPI version JSON
download
home_page
SummaryLibrary to control PiKVM with Python
upload_time2024-01-10 22:57:24
maintainer
docs_urlNone
author
requires_python>=3.9
licenseGNU v3
keywords pikvm pikvm-lib kvm
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # PiKVM-Lib: A Python library for controlling/automating PiKVM Devices

[![codecov](https://codecov.io/gh/guanana/pikvm-lib/graph/badge.svg?token=ZTJV7JLUTK)](https://codecov.io/gh/guanana/pikvm-lib)

PiKVM-Lib is a Python library that provides a simple and intuitive API for controlling PiKVM devices. 
With PiKVM-Lib, you can easily perform various actions on your PiKVM devices, such as:

* Getting system information
* Controlling ATX power
* Managing Mass Storage Device (MSD) images
* Interacting with General-Purpose Input/Output (GPIO) channels
* Taking snapshots and receive image
* Reading snapshots with OCR and receive text representation
* Send keys to the server


With PiKVM-Lib, you can automate tasks, integrate PiKVMs into your existing applications, 
and extend the capabilities of your PiKVM devices.

## Installation

To install PiKVM, simply run the following command in your terminal:

```bash
pip install pikvm-lib
```

## PiKVM device control

After installing PiKVM, you can import it into your Python script and create an instance of the `PiKVM` class. The `PiKVM` class constructor takes the following parameters:

* `hostname`: The hostname or IP address of the PiKVM device
* `username`: The username for authentication
* `password`: The password for authentication


```python
from pikvm_lib import PiKVM

pikvm_instance = PiKVM(hostname="192.168.1.10", username="admin", password="password")
```

Once you have created an instance of the `PiKVM` class, you can use it to interact with your PiKVM device. 
For example, you can get the system information of the device:

```python
system_info = pikvm_instance.get_system_info()
print(system_info)
```

You can also control the ATX power of the device:

```python
pikvm_instance.set_atx_power(action="on")
```

For more information on how to use PiKVM, 
please refer to the official documentation: [PiKVM official web](https://docs.pikvm.org/) and [PiKVM API Reference](https://docs.pikvm.org/api/)

### Usage examples

Here are some examples of how to use PiKVM to perform common tasks:

* **Getting system information:**

```python
from pikvm_lib import PiKVM

pikvm_instance = PiKVM(hostname="192.168.1.10", username="admin", password="password")
system_info = pikvm_instance.get_system_info()
print(system_info)
```

* **Turning on the ATX power:**

```python
pikvm_instance.set_atx_power(action="on")
```

* **Uploading an MSD image:**

```python
pikvm_instance.upload_msd_image(filepath="/path/to/image.iso")
```

* **Connecting the MSD:**

```python
pikvm_instance.connect_msd()
```

* **Switching a GPIO channel:**

```python
pikvm_instance.switch_gpio_channel(channel=1, state=1)
```

* **Take snapshot and receive OCR text:**

```python
pikvm_instance.get_streamer_snapshot(snapshot_path="/home/user/pikvm-snapshots",
                            filename="test.txt", ocr=True)
```
* **Take snapshot and receive image:**

```python
pikvm_instance.get_streamer_snapshot(snapshot_path="/home/user/pikvm-snapshots",
                            filename="test.jpeg", ocr=False)
```
## PiKVM websocket
The PiKVMWebsocket class is a Python class that allows you to send keyboard events to a PiKVM server over WebSocket. 

It provides methods for sending individual keys, key combinations, and text input. 

The class also handles the connection to the PiKVM server and the parsing of the WebSocket messages.

### Usage examples
```python
from pikvm_lib import PiKVMWebsocket

hostname = "192.168.1.10"  # Replace with your PiKVM server's hostname or IP address
username = "user"
password = "password"

# Create a PiKVMWebsocket object
websocket = PiKVMWebsocket(hostname, username, password)

# Send the Ctrl+Alt+Delete key combination
websocket.send_ctrl_alt_sup()

# Send the text "Hello, world!"
websocket.send_input("Hello, world!")
```

```python
from pikvm_lib import PiKVMWebsocket

hostname = "192.168.1.10"  # Replace with your PiKVM server's hostname or IP address
username = "user"
password = "password"

# Create a PiKVMWebsocket object
websocket = PiKVMWebsocket(hostname, username, password)

# Send the F2 key
websocket.send_key("<F2>")

# Send the Ctrl+B key
websocket.send_key_press("ControlLeft", "true")
websocket.send_input("b") # or websocket.send_key("KeyB")
websocket.send_key_press("ControlLeft", "false")
```

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "pikvm-lib",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": "",
    "keywords": "pikvm,pikvm-lib,kvm",
    "author": "",
    "author_email": "guanana <guanana2@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/52/45/bfe4b4377f9da2d0ea5f20d283b75794662e838cb1d96c14938acd1fb371/pikvm_lib-0.4.2.tar.gz",
    "platform": null,
    "description": "# PiKVM-Lib: A Python library for controlling/automating PiKVM Devices\n\n[![codecov](https://codecov.io/gh/guanana/pikvm-lib/graph/badge.svg?token=ZTJV7JLUTK)](https://codecov.io/gh/guanana/pikvm-lib)\n\nPiKVM-Lib is a Python library that provides a simple and intuitive API for controlling PiKVM devices. \nWith PiKVM-Lib, you can easily perform various actions on your PiKVM devices, such as:\n\n* Getting system information\n* Controlling ATX power\n* Managing Mass Storage Device (MSD) images\n* Interacting with General-Purpose Input/Output (GPIO) channels\n* Taking snapshots and receive image\n* Reading snapshots with OCR and receive text representation\n* Send keys to the server\n\n\nWith PiKVM-Lib, you can automate tasks, integrate PiKVMs into your existing applications, \nand extend the capabilities of your PiKVM devices.\n\n## Installation\n\nTo install PiKVM, simply run the following command in your terminal:\n\n```bash\npip install pikvm-lib\n```\n\n## PiKVM device control\n\nAfter installing PiKVM, you can import it into your Python script and create an instance of the `PiKVM` class. The `PiKVM` class constructor takes the following parameters:\n\n* `hostname`: The hostname or IP address of the PiKVM device\n* `username`: The username for authentication\n* `password`: The password for authentication\n\n\n```python\nfrom pikvm_lib import PiKVM\n\npikvm_instance = PiKVM(hostname=\"192.168.1.10\", username=\"admin\", password=\"password\")\n```\n\nOnce you have created an instance of the `PiKVM` class, you can use it to interact with your PiKVM device. \nFor example, you can get the system information of the device:\n\n```python\nsystem_info = pikvm_instance.get_system_info()\nprint(system_info)\n```\n\nYou can also control the ATX power of the device:\n\n```python\npikvm_instance.set_atx_power(action=\"on\")\n```\n\nFor more information on how to use PiKVM, \nplease refer to the official documentation: [PiKVM official web](https://docs.pikvm.org/) and [PiKVM API Reference](https://docs.pikvm.org/api/)\n\n### Usage examples\n\nHere are some examples of how to use PiKVM to perform common tasks:\n\n* **Getting system information:**\n\n```python\nfrom pikvm_lib import PiKVM\n\npikvm_instance = PiKVM(hostname=\"192.168.1.10\", username=\"admin\", password=\"password\")\nsystem_info = pikvm_instance.get_system_info()\nprint(system_info)\n```\n\n* **Turning on the ATX power:**\n\n```python\npikvm_instance.set_atx_power(action=\"on\")\n```\n\n* **Uploading an MSD image:**\n\n```python\npikvm_instance.upload_msd_image(filepath=\"/path/to/image.iso\")\n```\n\n* **Connecting the MSD:**\n\n```python\npikvm_instance.connect_msd()\n```\n\n* **Switching a GPIO channel:**\n\n```python\npikvm_instance.switch_gpio_channel(channel=1, state=1)\n```\n\n* **Take snapshot and receive OCR text:**\n\n```python\npikvm_instance.get_streamer_snapshot(snapshot_path=\"/home/user/pikvm-snapshots\",\n                            filename=\"test.txt\", ocr=True)\n```\n* **Take snapshot and receive image:**\n\n```python\npikvm_instance.get_streamer_snapshot(snapshot_path=\"/home/user/pikvm-snapshots\",\n                            filename=\"test.jpeg\", ocr=False)\n```\n## PiKVM websocket\nThe PiKVMWebsocket class is a Python class that allows you to send keyboard events to a PiKVM server over WebSocket. \n\nIt provides methods for sending individual keys, key combinations, and text input. \n\nThe class also handles the connection to the PiKVM server and the parsing of the WebSocket messages.\n\n### Usage examples\n```python\nfrom pikvm_lib import PiKVMWebsocket\n\nhostname = \"192.168.1.10\"  # Replace with your PiKVM server's hostname or IP address\nusername = \"user\"\npassword = \"password\"\n\n# Create a PiKVMWebsocket object\nwebsocket = PiKVMWebsocket(hostname, username, password)\n\n# Send the Ctrl+Alt+Delete key combination\nwebsocket.send_ctrl_alt_sup()\n\n# Send the text \"Hello, world!\"\nwebsocket.send_input(\"Hello, world!\")\n```\n\n```python\nfrom pikvm_lib import PiKVMWebsocket\n\nhostname = \"192.168.1.10\"  # Replace with your PiKVM server's hostname or IP address\nusername = \"user\"\npassword = \"password\"\n\n# Create a PiKVMWebsocket object\nwebsocket = PiKVMWebsocket(hostname, username, password)\n\n# Send the F2 key\nwebsocket.send_key(\"<F2>\")\n\n# Send the Ctrl+B key\nwebsocket.send_key_press(\"ControlLeft\", \"true\")\nwebsocket.send_input(\"b\") # or websocket.send_key(\"KeyB\")\nwebsocket.send_key_press(\"ControlLeft\", \"false\")\n```\n",
    "bugtrack_url": null,
    "license": "GNU v3",
    "summary": "Library to control PiKVM with Python",
    "version": "0.4.2",
    "project_urls": {
        "Homepage": "https://github.com/guanana/pikvm-lib",
        "Issues": "https://github.com/guanana/pikvm-lib/issues"
    },
    "split_keywords": [
        "pikvm",
        "pikvm-lib",
        "kvm"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "57b6dab9e274faeb6dbf53c599d022e72bc509c213df6e6a8fd3539dc80a49c0",
                "md5": "5718de61571bbfbffa909d63be56cb56",
                "sha256": "fdbb36e652e7e35a31c8d3d50634516fa43f431b7f4b24902ff79dd12cd87b29"
            },
            "downloads": -1,
            "filename": "pikvm_lib-0.4.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "5718de61571bbfbffa909d63be56cb56",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 25510,
            "upload_time": "2024-01-10T22:57:22",
            "upload_time_iso_8601": "2024-01-10T22:57:22.344218Z",
            "url": "https://files.pythonhosted.org/packages/57/b6/dab9e274faeb6dbf53c599d022e72bc509c213df6e6a8fd3539dc80a49c0/pikvm_lib-0.4.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5245bfe4b4377f9da2d0ea5f20d283b75794662e838cb1d96c14938acd1fb371",
                "md5": "f36f2ad38adf7885fe7daae0ef30b857",
                "sha256": "20599f856272066d78a4926ff279e7635710a6a392c902b3f21573d000aa2c85"
            },
            "downloads": -1,
            "filename": "pikvm_lib-0.4.2.tar.gz",
            "has_sig": false,
            "md5_digest": "f36f2ad38adf7885fe7daae0ef30b857",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 27209,
            "upload_time": "2024-01-10T22:57:24",
            "upload_time_iso_8601": "2024-01-10T22:57:24.101098Z",
            "url": "https://files.pythonhosted.org/packages/52/45/bfe4b4377f9da2d0ea5f20d283b75794662e838cb1d96c14938acd1fb371/pikvm_lib-0.4.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-10 22:57:24",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "guanana",
    "github_project": "pikvm-lib",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "pikvm-lib"
}
        
Elapsed time: 0.16838s