mirror of
https://github.com/9001/copyparty.git
synced 2026-02-21 01:40:39 +10:00
@@ -44,6 +44,8 @@ ANYWIN = WINDOWS or sys.platform in ["msys", "cygwin"]
|
||||
|
||||
MACOS = platform.system() == "Darwin"
|
||||
|
||||
GRAAL = platform.python_implementation() == "GraalVM"
|
||||
|
||||
EXE = bool(getattr(sys, "frozen", False))
|
||||
|
||||
try:
|
||||
|
||||
@@ -8,6 +8,7 @@ https://github.com/pydron/ifaddr/tree/0.2.0
|
||||
"""
|
||||
|
||||
import os
|
||||
import platform
|
||||
|
||||
from ._shared import IP, Adapter
|
||||
|
||||
@@ -16,20 +17,28 @@ def nope(include_unconfigured=False):
|
||||
return []
|
||||
|
||||
|
||||
try:
|
||||
S390X = os.uname().machine == "s390x"
|
||||
except:
|
||||
S390X = False
|
||||
host_os = platform.system()
|
||||
machine = platform.machine()
|
||||
py_impl = platform.python_implementation()
|
||||
|
||||
|
||||
if os.environ.get("PRTY_NO_IFADDR") or S390X:
|
||||
if os.environ.get("PRTY_NO_IFADDR"):
|
||||
get_adapters = nope
|
||||
elif machine in ("s390x",) or host_os in ("IRIX32",):
|
||||
# s390x deadlocks at libc.getifaddrs
|
||||
# irix libc does not have getifaddrs at all
|
||||
print("ifaddr unavailable; can't determine LAN IP: unsupported OS")
|
||||
get_adapters = nope
|
||||
elif py_impl in ("GraalVM",):
|
||||
print("ifaddr unavailable; can't determine LAN IP: unsupported interpreter")
|
||||
get_adapters = nope
|
||||
elif os.name == "nt":
|
||||
from ._win32 import get_adapters
|
||||
elif os.name == "posix":
|
||||
from ._posix import get_adapters
|
||||
else:
|
||||
raise RuntimeError("Unsupported Operating System: %s" % os.name)
|
||||
print("ifaddr unavailable; can't determine LAN IP: unsupported OS")
|
||||
get_adapters = nope
|
||||
|
||||
|
||||
__all__ = ["Adapter", "IP", "get_adapters"]
|
||||
|
||||
@@ -45,6 +45,7 @@ except:
|
||||
from .__init__ import (
|
||||
ANYWIN,
|
||||
EXE,
|
||||
GRAAL,
|
||||
MACOS,
|
||||
PY2,
|
||||
PY36,
|
||||
@@ -56,6 +57,11 @@ from .__init__ import (
|
||||
)
|
||||
from .__version__ import S_BUILD_DT, S_VERSION
|
||||
|
||||
|
||||
def noop(*a, **ka):
|
||||
pass
|
||||
|
||||
|
||||
try:
|
||||
from datetime import datetime, timezone
|
||||
|
||||
@@ -280,6 +286,9 @@ except:
|
||||
BITNESS = struct.calcsize("P") * 8
|
||||
|
||||
|
||||
CAN_SIGMASK = not (ANYWIN or PY2 or GRAAL)
|
||||
|
||||
|
||||
RE_ANSI = re.compile("\033\\[[^mK]*[mK]")
|
||||
RE_HTML_SH = re.compile(r"[<>&$?`\"';]")
|
||||
RE_CTYPE = re.compile(r"^content-type: *([^; ]+)", re.IGNORECASE)
|
||||
@@ -779,7 +788,7 @@ class Daemon(threading.Thread):
|
||||
self.start()
|
||||
|
||||
def run(self):
|
||||
if not ANYWIN and not PY2:
|
||||
if CAN_SIGMASK:
|
||||
signal.pthread_sigmask(
|
||||
signal.SIG_BLOCK, [signal.SIGINT, signal.SIGTERM, signal.SIGUSR1]
|
||||
)
|
||||
@@ -1655,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)
|
||||
|
||||
|
||||
def sigblock():
|
||||
if ANYWIN or PY2:
|
||||
return
|
||||
|
||||
def _sigblock():
|
||||
signal.pthread_sigmask(
|
||||
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:
|
||||
txt0 = txt
|
||||
for vol in vols:
|
||||
|
||||
Reference in New Issue
Block a user