-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from guanana/extra_endpoints
Extra endpoints
- Loading branch information
Showing
12 changed files
with
700 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[project] | ||
name = "pikvm_lib" | ||
version = "0.2.0" | ||
version = "0.3.0" | ||
authors = [ | ||
{ name="guanana", email="[email protected]" }, | ||
] | ||
|
@@ -12,6 +12,7 @@ requires-python = ">=3.9" | |
dependencies = [ | ||
"requests>=2.31.0", | ||
"pyotp<=2.9.0", | ||
"websocket-client>=1.7.0" | ||
] | ||
|
||
|
||
|
@@ -33,7 +34,7 @@ Homepage = "https://github.com/guanana/pikvm-lib" | |
Issues = "https://github.com/guanana/pikvm-lib/issues" | ||
|
||
[tool.bumpver] | ||
current_version = "0.2.0" | ||
current_version = "0.3.0" | ||
version_pattern = "MAJOR.MINOR.PATCH" | ||
commit_message = "Bump version {old_version} -> {new_version}" | ||
tag_message = "{new_version}" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import logging | ||
from .pikvm import PiKVM | ||
from .pikvm_websocket import PiKVMWebsocket | ||
|
||
|
||
# Create a logger | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import os | ||
|
||
|
||
def get_streamer_state(self, path="/api/streamer"): | ||
""" | ||
Gets the state of the streamer subsystem. | ||
Parameters: | ||
- path: The Streamer state endpoint path (default is "/api/streamer"). | ||
Returns: | ||
- dict: Streamer subsystem state information. | ||
""" | ||
return self._get_infos(path) | ||
|
||
|
||
def get_streamer_snapshot(self, path="/api/streamer/snapshot", snapshot_path=os.getcwd(), filename="snapshot.jpeg", | ||
ocr=False): | ||
""" | ||
Gets screen snapshot | ||
Parameters: | ||
- path: The Streamer state endpoint path (default is "/api/streamer"). | ||
- snapshot_path: Folder to download the snapshot to (default is _current path_) | ||
- filename: Name of the snapshot or text file name if ocr is enabled (default is "snapshot.jpeg") | ||
- ocr: Enable OCR recognition and creates a text file instead | ||
Returns: | ||
- file: Path to the file. | ||
""" | ||
options = "allow_offline=1" | ||
if ocr: | ||
if filename.endswith(".jpeg"): | ||
self.logger.warning("Detected OCR but jpeg extension found, changing to txt") | ||
filename = f"{filename.strip('.jpeg')}.txt" | ||
options = "ocr=1&allow_offline=1" | ||
else: | ||
if filename.endswith(".txt"): | ||
self.logger.warning("OCR off but txt extension found, changing to jpeg") | ||
filename = f"{filename.strip('.txt')}.jpeg" | ||
|
||
file = os.path.join(snapshot_path, filename) | ||
f = open(file, 'wb') | ||
f.write(self._get(path, options).content) | ||
f.close() | ||
self.logger.info(f"Writing snapshot to: {file}") | ||
return file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
characters,web_name | ||
\n,Enter | ||
\b,Backspace | ||
\t,Tab | ||
\s,Space | ||
-,Minus | ||
=,Equal | ||
[,BracketLeft | ||
],BracketRight | ||
\,Backslash | ||
;,Semicolon | ||
',Quote | ||
`,Backquote | ||
",",Comma | ||
.,Period | ||
/,Slash | ||
<Esc>,Escape | ||
<Enter>,Enter | ||
<CapsLock>,CapsLock | ||
<F1>,F1 | ||
<F2>,F2 | ||
<F3>,F3 | ||
<F4>,F4 | ||
<F5>,F5 | ||
<F6>,F6 | ||
<F7>,F7 | ||
<F8>,F8 | ||
<F9>,F9 | ||
<F10>,F10 | ||
<F11>,F11 | ||
<F12>,F12 | ||
<PrintScreen>,PrintScreen | ||
<Insert>,Insert | ||
<Home>,Home | ||
<PageUp>,PageUp | ||
<Delete>,Delete | ||
<End>,End | ||
<PageDown>,PageDown | ||
<ArrowRight>,ArrowRight | ||
<ArrowLeft>,ArrowLeft | ||
<ArrowDown>,ArrowDown | ||
<ArrowUp>,ArrowUp | ||
<ControlLeft>,ControlLeft | ||
<ShiftLeft>,ShiftLeft | ||
<AltLeft>,AltLeft | ||
<MetaLeft>,MetaLeft | ||
<ControlRight>,ControlRight | ||
<ShiftRight>,ShiftRight | ||
<AltRight>,AltRight | ||
<MetaRight>,MetaRight | ||
<Pause>,Pause | ||
<Power>,Power |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
characters,web_name | ||
_,Minus | ||
+,Equal | ||
{,BracketLeft | ||
},BracketRight | ||
|,Backslash | ||
:,Semicolon | ||
\",Quote | ||
~,Backquote | ||
<,Comma | ||
>,Period | ||
?,Slash | ||
!,Digit1 | ||
@,Digit2 | ||
#,Digit3 | ||
$,Digit4 | ||
%,Digit5 | ||
^,Digit6 | ||
&,Digit7 | ||
*,Digit8 | ||
(,Digit9 | ||
),Digit0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.