mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-12 09:10:30 +08:00
python 3.10
This commit is contained in:
parent
aef7a5a094
commit
1e98d9bd5d
@ -20,6 +20,7 @@
|
|||||||
# ========================================================================== #
|
# ========================================================================== #
|
||||||
|
|
||||||
|
|
||||||
|
import sys
|
||||||
import asyncio
|
import asyncio
|
||||||
import threading
|
import threading
|
||||||
import dataclasses
|
import dataclasses
|
||||||
@ -146,7 +147,8 @@ class _DebouncedValue:
|
|||||||
self.__notifier = notifier
|
self.__notifier = notifier
|
||||||
self.__loop = loop
|
self.__loop = loop
|
||||||
|
|
||||||
self.__queue: "asyncio.Queue[bool]" = asyncio.Queue(loop=loop)
|
queue_kwargs = ({"loop": loop} if sys.version_info < (3, 10) else {})
|
||||||
|
self.__queue: "asyncio.Queue[bool]" = asyncio.Queue(**queue_kwargs) # type: ignore
|
||||||
self.__task = loop.create_task(self.__consumer_task_loop())
|
self.__task = loop.create_task(self.__consumer_task_loop())
|
||||||
|
|
||||||
def set(self, value: bool) -> None:
|
def set(self, value: bool) -> None:
|
||||||
|
|||||||
@ -75,6 +75,6 @@ class ExtrasInfoSubmanager(BaseInfoSubmanager):
|
|||||||
extras["port"] = 0
|
extras["port"] = 0
|
||||||
config = self.__global_config
|
config = self.__global_config
|
||||||
for item in filter(None, map(str.strip, port_path.split("/"))):
|
for item in filter(None, map(str.strip, port_path.split("/"))):
|
||||||
config = getattr(config, item, None)
|
config = getattr(config, item, None) # type: ignore
|
||||||
if isinstance(config, int):
|
if isinstance(config, int):
|
||||||
extras["port"] = config
|
extras["port"] = config
|
||||||
|
|||||||
@ -49,5 +49,7 @@ def _inner_make_text_jpeg(width: int, height: int, quality: int, text: str) -> b
|
|||||||
|
|
||||||
@functools.lru_cache()
|
@functools.lru_cache()
|
||||||
def _get_font() -> ImageFont.FreeTypeFont:
|
def _get_font() -> ImageFont.FreeTypeFont:
|
||||||
path = os.path.join(os.path.dirname(sys.modules[__name__].__file__), "fonts", "Azbuka04.ttf")
|
module_path = sys.modules[__name__].__file__
|
||||||
|
assert module_path is not None
|
||||||
|
path = os.path.join(os.path.dirname(module_path), "fonts", "Azbuka04.ttf")
|
||||||
return ImageFont.truetype(path, size=20)
|
return ImageFont.truetype(path, size=20)
|
||||||
|
|||||||
@ -20,6 +20,7 @@
|
|||||||
# ========================================================================== #
|
# ========================================================================== #
|
||||||
|
|
||||||
|
|
||||||
|
import sys
|
||||||
import os
|
import os
|
||||||
import asyncio
|
import asyncio
|
||||||
import socket
|
import socket
|
||||||
@ -458,7 +459,7 @@ class VncServer: # pylint: disable=too-many-instance-attributes
|
|||||||
sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPINTVL, keepalive_interval)
|
sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPINTVL, keepalive_interval)
|
||||||
sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPCNT, keepalive_count)
|
sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPCNT, keepalive_count)
|
||||||
timeout = (keepalive_idle + keepalive_interval * keepalive_count) * 1000 # Milliseconds
|
timeout = (keepalive_idle + keepalive_interval * keepalive_count) * 1000 # Milliseconds
|
||||||
sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_USER_TIMEOUT, timeout)
|
sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_USER_TIMEOUT, timeout) # type: ignore
|
||||||
|
|
||||||
try:
|
try:
|
||||||
async with kvmd.make_session("", "") as kvmd_session:
|
async with kvmd.make_session("", "") as kvmd_session:
|
||||||
@ -507,11 +508,12 @@ class VncServer: # pylint: disable=too-many-instance-attributes
|
|||||||
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||||
sock.bind(addr)
|
sock.bind(addr)
|
||||||
|
|
||||||
|
server_kwargs = ({"loop": loop} if sys.version_info < (3, 10) else {})
|
||||||
server = loop.run_until_complete(asyncio.start_server(
|
server = loop.run_until_complete(asyncio.start_server(
|
||||||
client_connected_cb=self.__handle_client,
|
client_connected_cb=self.__handle_client,
|
||||||
sock=sock,
|
sock=sock,
|
||||||
backlog=self.__max_clients,
|
backlog=self.__max_clients,
|
||||||
loop=loop,
|
**server_kwargs, # type: ignore
|
||||||
))
|
))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|||||||
@ -151,7 +151,7 @@ class BtServer: # pylint: disable=too-many-instance-attributes
|
|||||||
@contextlib.contextmanager
|
@contextlib.contextmanager
|
||||||
def __listen(self, role: _RoleT, addr: str, port: int) -> Generator[socket.socket, None, None]:
|
def __listen(self, role: _RoleT, addr: str, port: int) -> Generator[socket.socket, None, None]:
|
||||||
get_logger(0).info("Listening [%s]:%d for %s ...", addr, port, role)
|
get_logger(0).info("Listening [%s]:%d for %s ...", addr, port, role)
|
||||||
with socket.socket(socket.AF_BLUETOOTH, socket.SOCK_SEQPACKET, socket.BTPROTO_L2CAP) as sock:
|
with socket.socket(socket.AF_BLUETOOTH, socket.SOCK_SEQPACKET, socket.BTPROTO_L2CAP) as sock: # type: ignore
|
||||||
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||||
sock.settimeout(self.__socket_timeout)
|
sock.settimeout(self.__socket_timeout)
|
||||||
sock.bind((addr, port))
|
sock.bind((addr, port))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user