mirror of
https://github.com/9001/copyparty.git
synced 2026-02-26 21:43:08 -07:00
Update util.py
Signed-off-by: ed <s@ocv.me>
This commit is contained in:
parent
591e959283
commit
d275679c7a
|
|
@ -57,6 +57,11 @@ from .__init__ import (
|
||||||
)
|
)
|
||||||
from .__version__ import S_BUILD_DT, S_VERSION
|
from .__version__ import S_BUILD_DT, S_VERSION
|
||||||
|
|
||||||
|
|
||||||
|
def noop(*a, **ka):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from datetime import datetime, timezone
|
from datetime import datetime, timezone
|
||||||
|
|
||||||
|
|
@ -281,6 +286,9 @@ except:
|
||||||
BITNESS = struct.calcsize("P") * 8
|
BITNESS = struct.calcsize("P") * 8
|
||||||
|
|
||||||
|
|
||||||
|
CAN_SIGMASK = not (ANYWIN or PY2 or GRAAL)
|
||||||
|
|
||||||
|
|
||||||
RE_ANSI = re.compile("\033\\[[^mK]*[mK]")
|
RE_ANSI = re.compile("\033\\[[^mK]*[mK]")
|
||||||
RE_HTML_SH = re.compile(r"[<>&$?`\"';]")
|
RE_HTML_SH = re.compile(r"[<>&$?`\"';]")
|
||||||
RE_CTYPE = re.compile(r"^content-type: *([^; ]+)", re.IGNORECASE)
|
RE_CTYPE = re.compile(r"^content-type: *([^; ]+)", re.IGNORECASE)
|
||||||
|
|
@ -780,7 +788,7 @@ class Daemon(threading.Thread):
|
||||||
self.start()
|
self.start()
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
if not ANYWIN and not PY2 and not GRAAL:
|
if CAN_SIGMASK:
|
||||||
signal.pthread_sigmask(
|
signal.pthread_sigmask(
|
||||||
signal.SIG_BLOCK, [signal.SIGINT, signal.SIGTERM, signal.SIGUSR1]
|
signal.SIG_BLOCK, [signal.SIGINT, signal.SIGTERM, signal.SIGUSR1]
|
||||||
)
|
)
|
||||||
|
|
@ -1656,15 +1664,15 @@ def log_thrs(log: Callable[[str, str, int], None], ival: float, name: str) -> No
|
||||||
log(name, "\033[0m \033[33m".join(tv), 3)
|
log(name, "\033[0m \033[33m".join(tv), 3)
|
||||||
|
|
||||||
|
|
||||||
def sigblock():
|
def _sigblock():
|
||||||
if ANYWIN or PY2 or GRAAL:
|
|
||||||
return
|
|
||||||
|
|
||||||
signal.pthread_sigmask(
|
signal.pthread_sigmask(
|
||||||
signal.SIG_BLOCK, [signal.SIGINT, signal.SIGTERM, signal.SIGUSR1]
|
signal.SIG_BLOCK, [signal.SIGINT, signal.SIGTERM, signal.SIGUSR1]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
sigblock = _sigblock if CAN_SIGMASK else noop
|
||||||
|
|
||||||
|
|
||||||
def vol_san(vols: list["VFS"], txt: bytes) -> bytes:
|
def vol_san(vols: list["VFS"], txt: bytes) -> bytes:
|
||||||
txt0 = txt
|
txt0 = txt
|
||||||
for vol in vols:
|
for vol in vols:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue