fix server

This commit is contained in:
brontomark committed 2026-11-13 19:32:31 +01:00
1 parent dbd53c17e7
commit bda61b07b8
3 files changed
+80 -2

No files matched your search

+53
View File
@@ -29,10 +29,61 @@ HIDDEN_IMPORTS = [
"qrcode", "qrcode",
"aiohttp", "aiohttp",
"pynput", "pynput",
"pynput._info",
"pynput._util",
"pynput.keyboard",
"pynput.keyboard._base",
"pynput.mouse",
"pynput.mouse._base",
"pyperclip", "pyperclip",
"certifi", "certifi",
] ]
PLATFORM_HIDDEN_IMPORTS = {
"Linux": [
"pynput.keyboard._xorg",
"pynput.mouse._xorg",
"pynput._util.xorg",
"pynput._util.xorg_keysyms",
"pynput._util.uinput",
"pynput.keyboard._uinput",
"pynput.keyboard._dummy",
"pynput.mouse._dummy",
"Xlib",
"Xlib.display",
"Xlib.ext",
"Xlib.ext.xtest",
"Xlib.XK",
"Xlib.X",
"Xlib.protocol",
"Xlib.protocol.display",
"Xlib.protocol.event",
"Xlib.protocol.request",
"Xlib.protocol.rq",
"Xlib.protocol.structs",
"Xlib.keysymdef",
"Xlib.keysymdef.xkb",
"Xlib.keysymdef.latin1",
"Xlib.keysymdef.miscellany",
],
"Windows": [
"pynput.keyboard._win32",
"pynput.mouse._win32",
"pynput._util.win32",
"pynput._util.win32_vks",
"pynput.keyboard._dummy",
"pynput.mouse._dummy",
],
"Darwin": [
"pynput.keyboard._darwin",
"pynput.mouse._darwin",
"pynput._util.darwin",
"pynput._util.darwin_vks",
"pynput.keyboard._dummy",
"pynput.mouse._dummy",
],
}
EXCLUDED_MODULES = [ EXCLUDED_MODULES = [
"tkinter", "tkinter",
"_tkinter", "_tkinter",
@@ -232,6 +283,8 @@ def build(
for hidden_import in HIDDEN_IMPORTS: for hidden_import in HIDDEN_IMPORTS:
cmd.append(f"--hidden-import={hidden_import}") cmd.append(f"--hidden-import={hidden_import}")
for platform_hidden in PLATFORM_HIDDEN_IMPORTS.get(system, []):
cmd.append(f"--hidden-import={platform_hidden}")
for excluded in EXCLUDED_MODULES: for excluded in EXCLUDED_MODULES:
cmd.append(f"--exclude-module={excluded}") cmd.append(f"--exclude-module={excluded}")
+26 -1
View File
@@ -331,13 +331,35 @@ class KeyboardSimulator:
loop = asyncio.get_running_loop() loop = asyncio.get_running_loop()
return await loop.run_in_executor(None, self._sync_type, full_text, active_suffix, active_mode) return await loop.run_in_executor(None, self._sync_type, full_text, active_suffix, active_mode)
def _ensure_controller(self) -> bool:
if self.controller is not None:
return True
global _controller, Controller, Key, KeyCode
try:
from pynput.keyboard import Controller as _C, Key as _K, KeyCode as _KC
Controller = _C
Key = _K
KeyCode = _KC
self.controller = Controller()
_controller = self.controller
self._linux_xtest, self._win32_helper = _init_platform_helpers(self.controller)
print("[+] Controller tastiera pynput inizializzato con successo.")
return True
except Exception as e:
print(f"Errore inizializzazione controller tastiera: {e}")
return False
def _tap_special(self, x11_name: str, pynput_key) -> None: def _tap_special(self, x11_name: str, pynput_key) -> None:
if not self._ensure_controller():
return
if self._linux_xtest is not None: if self._linux_xtest is not None:
if self._linux_xtest.tap_named(x11_name): if self._linux_xtest.tap_named(x11_name):
return return
self.controller.tap(pynput_key) self.controller.tap(pynput_key)
def _type_single_char(self, char: str) -> None: def _type_single_char(self, char: str) -> None:
if not self._ensure_controller():
return
if self._linux_xtest is not None: if self._linux_xtest is not None:
if self._linux_xtest.type_char(char): if self._linux_xtest.type_char(char):
return return
@@ -380,6 +402,9 @@ class KeyboardSimulator:
time.sleep(0.04) time.sleep(0.04)
return True return True
if not self._ensure_controller():
return False
modifier = Key.cmd if self.is_mac else Key.ctrl modifier = Key.cmd if self.is_mac else Key.ctrl
paste_key = KeyCode.from_vk(0x56) if (self.is_windows and KeyCode is not None) else "v" paste_key = KeyCode.from_vk(0x56) if (self.is_windows and KeyCode is not None) else "v"
with self.controller.pressed(modifier): with self.controller.pressed(modifier):
@@ -388,7 +413,7 @@ class KeyboardSimulator:
return True return True
def _sync_type(self, full_text: str, suffix: str, mode: str) -> bool: def _sync_type(self, full_text: str, suffix: str, mode: str) -> bool:
if not self.controller: if not self._ensure_controller():
print("Errore: controller tastiera non disponibile!") print("Errore: controller tastiera non disponibile!")
return False return False
+1 -1
View File
@@ -7,7 +7,7 @@ APP_NAME = "Barcode Reader Server"
APP_BINARY_NAME = "BarcodeServer" APP_BINARY_NAME = "BarcodeServer"
APP_ID = "com.catellisrl.barcodereader" APP_ID = "com.catellisrl.barcodereader"
APP_PUBLISHER = "Catelli Srl" APP_PUBLISHER = "Catelli Srl"
APP_VERSION = "1.0.1" APP_VERSION = "1.0.2"
GITEA_BASE_URL = "https://gitea.catelli.it" GITEA_BASE_URL = "https://gitea.catelli.it"
GITEA_REPO = "brontomark/barcode_reader_pc" GITEA_REPO = "brontomark/barcode_reader_pc"