guanana / pikvm-lib Goto Github PK
View Code? Open in Web Editor NEWLibrary to admin/control using automation and Python on PiKVM
License: GNU General Public License v3.0
Library to admin/control using automation and Python on PiKVM
License: GNU General Public License v3.0
Hello there,
I am starting to use this library for writing a custom integration for home assistant, unfortunately I ran into an issue using some of the websocket functions that require the key map csv files. It seems the csv files are not currently present in the published pipy package.
I was able to add these lines to the end of the pyproject.toml to fix this issue, is this something you would be willing to do and publish an updated release to pipy?
[tool.setuptools.packages.find]
where = ["src"]
[tool.setuptools.package-data]
pikvm_lib = ["*.csv"]
Is your feature request related to a problem? Please describe.
clean interface for absolute mouse position
Describe the solution you'd like
some fn mouse_move_to(sx, sy) mapping screen 0..width to -i16..+i16, same for height
Describe alternatives you've considered
import ssl, time
import random
import json
import os
host = os.environ.get('HOST')
user = os.environ.get('USER', 'admin')
password = os.environ.get('PASSWORD', 'admin')
screen_width = 1920
screen_height = 1080
uri = f'wss://{host}/api/ws?stream=0'
print(f'connecting to {user}@{host} uri: {uri}')
headers = {"X-KVMD-User": user, "X-KVMD-Passwd": password}
print('headers', headers)
ws = websocket.WebSocket(sslopt={"cert_reqs": ssl.CERT_NONE})
ws.connect(uri, header=headers)
def scale_mouse_xy_to_i16(screenx, screeny, width=1920, height=1080):
# Map from (0, width) to (i16)
hid_x_i16 = int((screenx / width) * 0xffff - 0x8000)
# Map from (0, height) to (i16)
hid_y_i16 = int((screeny / height) * 0xffff - 0x8000)
return (hid_x_i16, hid_y_i16)
def mouse_jump_to(screenx, screeny, width=1920, height=1080):
print('mouse_move', screenx, screeny)
kvmx, kvmy = scale_mouse_xy_to_i16(screenx, screeny)
msg = json.dumps({
"event_type": "mouse_move",
"event": {
"to": {
"x": kvmx,
"y": kvmy
},
}
})
ws.send(msg)
while True:
for y in range(0, screen_height, 10):
for x in range(0, screen_width, 19):
mouse_jump_to(x, y)
time.sleep(0.1)
ws.close()
Additional context
using kvm for automated testing without installing software on the remote device under test
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.