mirror of
https://github.com/9001/copyparty.git
synced 2025-08-17 09:02:15 -06:00
py2: reduce ram usage
This commit is contained in:
parent
72361c99e1
commit
ebb1981803
|
@ -67,6 +67,9 @@ if True: # pylint: disable=using-constant-test
|
|||
|
||||
from typing import Any, Optional
|
||||
|
||||
if PY2:
|
||||
range = xrange
|
||||
|
||||
try:
|
||||
if os.environ.get("PRTY_NO_TLS"):
|
||||
raise Exception()
|
||||
|
|
|
@ -12,7 +12,7 @@ import threading
|
|||
import time
|
||||
from datetime import datetime
|
||||
|
||||
from .__init__ import ANYWIN, TYPE_CHECKING, WINDOWS, E
|
||||
from .__init__ import ANYWIN, PY2, TYPE_CHECKING, WINDOWS, E
|
||||
from .bos import bos
|
||||
from .cfg import flagdescs, permdescs, vf_bmap, vf_cmap, vf_vmap
|
||||
from .pwhash import PWHash
|
||||
|
@ -56,6 +56,9 @@ if TYPE_CHECKING:
|
|||
# Vflags: TypeAlias = dict[str, Any]
|
||||
# Mflags: TypeAlias = dict[str, Vflags]
|
||||
|
||||
if PY2:
|
||||
range = xrange
|
||||
|
||||
|
||||
LEELOO_DALLAS = "leeloo_dallas"
|
||||
|
||||
|
|
|
@ -41,6 +41,9 @@ if True: # pylint: disable=using-constant-test
|
|||
import typing
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
if PY2:
|
||||
range = xrange
|
||||
|
||||
|
||||
class FSE(FilesystemError):
|
||||
def __init__(self, msg: str, severity: int = 0) -> None:
|
||||
|
|
|
@ -12,7 +12,7 @@ import time
|
|||
|
||||
import queue
|
||||
|
||||
from .__init__ import ANYWIN, CORES, EXE, MACOS, TYPE_CHECKING, EnvParams, unicode
|
||||
from .__init__ import ANYWIN, CORES, EXE, MACOS, PY2, TYPE_CHECKING, EnvParams, unicode
|
||||
|
||||
try:
|
||||
MNFE = ModuleNotFoundError
|
||||
|
@ -84,6 +84,9 @@ if TYPE_CHECKING:
|
|||
if True: # pylint: disable=using-constant-test
|
||||
from typing import Any, Optional
|
||||
|
||||
if PY2:
|
||||
range = xrange
|
||||
|
||||
|
||||
class HttpSrv(object):
|
||||
"""
|
||||
|
|
|
@ -12,6 +12,12 @@ from .label import DNSBuffer, DNSLabel
|
|||
from .ranges import IP4, IP6, H, I, check_bytes
|
||||
|
||||
|
||||
try:
|
||||
range = xrange
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
class DNSError(Exception):
|
||||
pass
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ if not PY2:
|
|||
U: Callable[[str], str] = str
|
||||
else:
|
||||
U = unicode # noqa: F821 # pylint: disable=undefined-variable,self-assigning-variable
|
||||
range = xrange # noqa: F821 # pylint: disable=undefined-variable,self-assigning-variable
|
||||
|
||||
|
||||
class Adapter(object):
|
||||
|
|
|
@ -16,6 +16,11 @@ if True: # pylint: disable=using-constant-test
|
|||
|
||||
from typing import Callable, List, Optional, Tuple, Union
|
||||
|
||||
try:
|
||||
range = xrange
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
def num_char_count_bits(ver: int) -> int:
|
||||
return 16 if (ver + 7) // 17 else 8
|
||||
|
|
|
@ -28,7 +28,7 @@ if True: # pylint: disable=using-constant-test
|
|||
import typing
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
from .__init__ import ANYWIN, EXE, MACOS, TYPE_CHECKING, E, EnvParams, unicode
|
||||
from .__init__ import ANYWIN, EXE, MACOS, PY2, TYPE_CHECKING, E, EnvParams, unicode
|
||||
from .authsrv import BAD_CFG, AuthSrv
|
||||
from .cert import ensure_cert
|
||||
from .mtag import HAVE_FFMPEG, HAVE_FFPROBE
|
||||
|
@ -65,6 +65,9 @@ if TYPE_CHECKING:
|
|||
except:
|
||||
pass
|
||||
|
||||
if PY2:
|
||||
range = xrange
|
||||
|
||||
|
||||
class SvcHub(object):
|
||||
"""
|
||||
|
|
|
@ -44,6 +44,9 @@ if True: # pylint: disable=using-constant-test
|
|||
if TYPE_CHECKING:
|
||||
from .svchub import SvcHub
|
||||
|
||||
if PY2:
|
||||
range = xrange
|
||||
|
||||
|
||||
lg = logging.getLogger("tftp")
|
||||
debug, info, warning, error = (lg.debug, lg.info, lg.warning, lg.error)
|
||||
|
|
|
@ -12,7 +12,7 @@ import time
|
|||
|
||||
from queue import Queue
|
||||
|
||||
from .__init__ import ANYWIN, TYPE_CHECKING
|
||||
from .__init__ import ANYWIN, PY2, TYPE_CHECKING
|
||||
from .authsrv import VFS
|
||||
from .bos import bos
|
||||
from .mtag import HAVE_FFMPEG, HAVE_FFPROBE, au_unpk, ffprobe
|
||||
|
@ -38,6 +38,9 @@ if True: # pylint: disable=using-constant-test
|
|||
if TYPE_CHECKING:
|
||||
from .svchub import SvcHub
|
||||
|
||||
if PY2:
|
||||
range = xrange
|
||||
|
||||
HAVE_PIL = False
|
||||
HAVE_PILF = False
|
||||
HAVE_HEIF = False
|
||||
|
|
|
@ -8,7 +8,7 @@ import threading
|
|||
import time
|
||||
from operator import itemgetter
|
||||
|
||||
from .__init__ import ANYWIN, TYPE_CHECKING, unicode
|
||||
from .__init__ import ANYWIN, PY2, TYPE_CHECKING, unicode
|
||||
from .authsrv import LEELOO_DALLAS, VFS
|
||||
from .bos import bos
|
||||
from .up2k import up2k_wark_from_hashlist
|
||||
|
@ -38,6 +38,9 @@ if True: # pylint: disable=using-constant-test
|
|||
if TYPE_CHECKING:
|
||||
from .httpsrv import HttpSrv
|
||||
|
||||
if PY2:
|
||||
range = xrange
|
||||
|
||||
|
||||
class U2idx(object):
|
||||
def __init__(self, hsrv: "HttpSrv") -> None:
|
||||
|
|
|
@ -59,6 +59,10 @@ except:
|
|||
UTC = _UTC()
|
||||
|
||||
|
||||
if PY2:
|
||||
range = xrange
|
||||
|
||||
|
||||
if sys.version_info >= (3, 7) or (
|
||||
sys.version_info >= (3, 6) and platform.python_implementation() == "CPython"
|
||||
):
|
||||
|
|
Loading…
Reference in a new issue