mirror of
https://github.com/9001/copyparty.git
synced 2026-02-21 09:50:40 +10:00
@@ -44,6 +44,8 @@ ANYWIN = WINDOWS or sys.platform in ["msys", "cygwin"]
|
|||||||
|
|
||||||
MACOS = platform.system() == "Darwin"
|
MACOS = platform.system() == "Darwin"
|
||||||
|
|
||||||
|
GRAAL = platform.python_implementation() == "GraalVM"
|
||||||
|
|
||||||
EXE = bool(getattr(sys, "frozen", False))
|
EXE = bool(getattr(sys, "frozen", False))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ https://github.com/pydron/ifaddr/tree/0.2.0
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import platform
|
||||||
|
|
||||||
from ._shared import IP, Adapter
|
from ._shared import IP, Adapter
|
||||||
|
|
||||||
@@ -16,20 +17,28 @@ def nope(include_unconfigured=False):
|
|||||||
return []
|
return []
|
||||||
|
|
||||||
|
|
||||||
try:
|
host_os = platform.system()
|
||||||
S390X = os.uname().machine == "s390x"
|
machine = platform.machine()
|
||||||
except:
|
py_impl = platform.python_implementation()
|
||||||
S390X = False
|
|
||||||
|
|
||||||
|
|
||||||
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
|
# 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
|
get_adapters = nope
|
||||||
elif os.name == "nt":
|
elif os.name == "nt":
|
||||||
from ._win32 import get_adapters
|
from ._win32 import get_adapters
|
||||||
elif os.name == "posix":
|
elif os.name == "posix":
|
||||||
from ._posix import get_adapters
|
from ._posix import get_adapters
|
||||||
else:
|
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"]
|
__all__ = ["Adapter", "IP", "get_adapters"]
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ except:
|
|||||||
from .__init__ import (
|
from .__init__ import (
|
||||||
ANYWIN,
|
ANYWIN,
|
||||||
EXE,
|
EXE,
|
||||||
|
GRAAL,
|
||||||
MACOS,
|
MACOS,
|
||||||
PY2,
|
PY2,
|
||||||
PY36,
|
PY36,
|
||||||
@@ -56,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
|
||||||
|
|
||||||
@@ -280,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)
|
||||||
@@ -779,7 +788,7 @@ class Daemon(threading.Thread):
|
|||||||
self.start()
|
self.start()
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
if not ANYWIN and not PY2:
|
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]
|
||||||
)
|
)
|
||||||
@@ -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)
|
log(name, "\033[0m \033[33m".join(tv), 3)
|
||||||
|
|
||||||
|
|
||||||
def sigblock():
|
def _sigblock():
|
||||||
if ANYWIN or PY2:
|
|
||||||
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:
|
||||||
|
|||||||
Reference in New Issue
Block a user