mirror of
https://github.com/9001/copyparty.git
synced 2025-08-17 00:52:16 -06:00
pkgres: fix multiprocessing
This commit is contained in:
parent
3ccbcf6185
commit
c398553748
|
@ -16,8 +16,6 @@ except:
|
||||||
TYPE_CHECKING = False
|
TYPE_CHECKING = False
|
||||||
|
|
||||||
if True:
|
if True:
|
||||||
from types import ModuleType
|
|
||||||
|
|
||||||
from typing import Any, Callable, Optional
|
from typing import Any, Callable, Optional
|
||||||
|
|
||||||
PY2 = sys.version_info < (3,)
|
PY2 = sys.version_info < (3,)
|
||||||
|
@ -110,7 +108,6 @@ RES = set(zs.strip().split("\n"))
|
||||||
|
|
||||||
class EnvParams(object):
|
class EnvParams(object):
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
self.pkg: Optional[ModuleType] = None
|
|
||||||
self.t0 = time.time()
|
self.t0 = time.time()
|
||||||
self.mod = ""
|
self.mod = ""
|
||||||
self.cfg = ""
|
self.cfg = ""
|
||||||
|
|
|
@ -218,8 +218,6 @@ def init_E(EE: EnvParams) -> None:
|
||||||
|
|
||||||
raise Exception("could not find a writable path for config")
|
raise Exception("could not find a writable path for config")
|
||||||
|
|
||||||
assert __package__ # !rm
|
|
||||||
E.pkg = sys.modules[__package__]
|
|
||||||
E.mod = os.path.dirname(os.path.realpath(__file__))
|
E.mod = os.path.dirname(os.path.realpath(__file__))
|
||||||
if E.mod.endswith("__init__"):
|
if E.mod.endswith("__init__"):
|
||||||
E.mod = os.path.dirname(E.mod)
|
E.mod = os.path.dirname(E.mod)
|
||||||
|
|
|
@ -3622,10 +3622,10 @@ def stat_resource(E: EnvParams, name: str):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def _find_impresource(E: EnvParams, name: str):
|
def _find_impresource(pkg: types.ModuleType, name: str):
|
||||||
assert impresources # !rm
|
assert impresources # !rm
|
||||||
try:
|
try:
|
||||||
files = impresources.files(E.pkg)
|
files = impresources.files(pkg)
|
||||||
except ImportError:
|
except ImportError:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -3635,7 +3635,7 @@ def _find_impresource(E: EnvParams, name: str):
|
||||||
_rescache_has = {}
|
_rescache_has = {}
|
||||||
|
|
||||||
|
|
||||||
def _has_resource(E: EnvParams, name: str):
|
def _has_resource(name: str):
|
||||||
try:
|
try:
|
||||||
return _rescache_has[name]
|
return _rescache_has[name]
|
||||||
except:
|
except:
|
||||||
|
@ -3644,14 +3644,17 @@ def _has_resource(E: EnvParams, name: str):
|
||||||
if len(_rescache_has) > 999:
|
if len(_rescache_has) > 999:
|
||||||
_rescache_has.clear()
|
_rescache_has.clear()
|
||||||
|
|
||||||
|
assert __package__ # !rm
|
||||||
|
pkg = sys.modules[__package__]
|
||||||
|
|
||||||
if impresources:
|
if impresources:
|
||||||
res = _find_impresource(E, name)
|
res = _find_impresource(pkg, name)
|
||||||
if res and res.is_file():
|
if res and res.is_file():
|
||||||
_rescache_has[name] = True
|
_rescache_has[name] = True
|
||||||
return True
|
return True
|
||||||
|
|
||||||
if pkg_resources:
|
if pkg_resources:
|
||||||
if _pkg_resource_exists(E.pkg.__name__, name):
|
if _pkg_resource_exists(pkg.__name__, name):
|
||||||
_rescache_has[name] = True
|
_rescache_has[name] = True
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -3660,14 +3663,15 @@ def _has_resource(E: EnvParams, name: str):
|
||||||
|
|
||||||
|
|
||||||
def has_resource(E: EnvParams, name: str):
|
def has_resource(E: EnvParams, name: str):
|
||||||
return _has_resource(E, name) or os.path.exists(os.path.join(E.mod, name))
|
return _has_resource(name) or os.path.exists(os.path.join(E.mod, name))
|
||||||
|
|
||||||
|
|
||||||
def load_resource(E: EnvParams, name: str, mode="rb") -> IO[bytes]:
|
def load_resource(E: EnvParams, name: str, mode="rb") -> IO[bytes]:
|
||||||
enc = None if "b" in mode else "utf-8"
|
enc = None if "b" in mode else "utf-8"
|
||||||
|
|
||||||
if impresources:
|
if impresources:
|
||||||
res = _find_impresource(E, name)
|
assert __package__ # !rm
|
||||||
|
res = _find_impresource(sys.modules[__package__], name)
|
||||||
if res and res.is_file():
|
if res and res.is_file():
|
||||||
if enc:
|
if enc:
|
||||||
return res.open(mode, encoding=enc)
|
return res.open(mode, encoding=enc)
|
||||||
|
@ -3676,8 +3680,10 @@ def load_resource(E: EnvParams, name: str, mode="rb") -> IO[bytes]:
|
||||||
return res.open(mode)
|
return res.open(mode)
|
||||||
|
|
||||||
if pkg_resources:
|
if pkg_resources:
|
||||||
if _pkg_resource_exists(E.pkg.__name__, name):
|
assert __package__ # !rm
|
||||||
stream = pkg_resources.resource_stream(E.pkg.__name__, name)
|
pkg = sys.modules[__package__]
|
||||||
|
if _pkg_resource_exists(pkg.__name__, name):
|
||||||
|
stream = pkg_resources.resource_stream(pkg.__name__, name)
|
||||||
if enc:
|
if enc:
|
||||||
stream = codecs.getreader(enc)(stream)
|
stream = codecs.getreader(enc)(stream)
|
||||||
return stream
|
return stream
|
||||||
|
|
|
@ -11,6 +11,15 @@ gtar=$(command -v gtar || command -v gnutar) || true
|
||||||
realpath() { grealpath "$@"; }
|
realpath() { grealpath "$@"; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tmv() {
|
||||||
|
touch -r "$1" t
|
||||||
|
mv t "$1"
|
||||||
|
}
|
||||||
|
ised() {
|
||||||
|
sed -r "$1" <"$2" >t
|
||||||
|
tmv "$2"
|
||||||
|
}
|
||||||
|
|
||||||
targs=(--owner=1000 --group=1000)
|
targs=(--owner=1000 --group=1000)
|
||||||
[ "$OSTYPE" = msys ] &&
|
[ "$OSTYPE" = msys ] &&
|
||||||
targs=()
|
targs=()
|
||||||
|
@ -35,6 +44,12 @@ cd pyz
|
||||||
cp -pR ../sfx/{copyparty,partftpy} .
|
cp -pR ../sfx/{copyparty,partftpy} .
|
||||||
cp -pR ../sfx/{ftp,j2}/* .
|
cp -pR ../sfx/{ftp,j2}/* .
|
||||||
|
|
||||||
|
true && {
|
||||||
|
rm -rf copyparty/web/mde.* copyparty/web/deps/easymde*
|
||||||
|
echo h > copyparty/web/mde.html
|
||||||
|
ised '/edit2">edit \(fancy/d' copyparty/web/md.html
|
||||||
|
}
|
||||||
|
|
||||||
ts=$(date -u +%s)
|
ts=$(date -u +%s)
|
||||||
hts=$(date -u +%Y-%m%d-%H%M%S)
|
hts=$(date -u +%Y-%m%d-%H%M%S)
|
||||||
ver="$(cat ../sfx/ver)"
|
ver="$(cat ../sfx/ver)"
|
||||||
|
|
|
@ -98,6 +98,7 @@ def tc1(vflags):
|
||||||
|
|
||||||
args = [
|
args = [
|
||||||
"-q",
|
"-q",
|
||||||
|
"-j0",
|
||||||
"-p4321",
|
"-p4321",
|
||||||
"-e2dsa",
|
"-e2dsa",
|
||||||
"-e2tsr",
|
"-e2tsr",
|
||||||
|
|
Loading…
Reference in a new issue