mirror of
https://github.com/9001/copyparty.git
synced 2025-08-17 09:02:15 -06:00
include version info on startup and in crash dumps
This commit is contained in:
parent
8b4cf022f2
commit
e31248f018
|
@ -24,7 +24,18 @@ from .__init__ import ANYWIN, PY2, VT100, WINDOWS, E, unicode
|
|||
from .__version__ import CODENAME, S_BUILD_DT, S_VERSION
|
||||
from .authsrv import re_vol
|
||||
from .svchub import SvcHub
|
||||
from .util import IMPLICATIONS, align_tab, ansi_re, min_ex, py_desc, termsize, wrap
|
||||
from .util import (
|
||||
IMPLICATIONS,
|
||||
JINJA_VER,
|
||||
PYFTPD_VER,
|
||||
SQLITE_VER,
|
||||
align_tab,
|
||||
ansi_re,
|
||||
min_ex,
|
||||
py_desc,
|
||||
termsize,
|
||||
wrap,
|
||||
)
|
||||
|
||||
try:
|
||||
from types import FrameType
|
||||
|
@ -664,10 +675,17 @@ def main(argv: Optional[list[str]] = None) -> None:
|
|||
if argv is None:
|
||||
argv = sys.argv
|
||||
|
||||
desc = py_desc().replace("[", "\033[1;30m[")
|
||||
|
||||
f = '\033[36mcopyparty v{} "\033[35m{}\033[36m" ({})\n{}\033[0m\n'
|
||||
lprint(f.format(S_VERSION, CODENAME, S_BUILD_DT, desc))
|
||||
f = '\033[36mcopyparty v{} "\033[35m{}\033[36m" ({})\n{}\033[0;36m\n sqlite v{} | jinja2 v{} | pyftpd v{}\n\033[0m\n'
|
||||
f = f.format(
|
||||
S_VERSION,
|
||||
CODENAME,
|
||||
S_BUILD_DT,
|
||||
py_desc().replace("[", "\033[1;30m["),
|
||||
SQLITE_VER,
|
||||
JINJA_VER,
|
||||
PYFTPD_VER,
|
||||
)
|
||||
lprint(f)
|
||||
|
||||
ensure_locale()
|
||||
if HAVE_SSL:
|
||||
|
|
|
@ -30,7 +30,15 @@ from .mtag import HAVE_FFMPEG, HAVE_FFPROBE
|
|||
from .tcpsrv import TcpSrv
|
||||
from .th_srv import HAVE_PIL, HAVE_VIPS, HAVE_WEBP, ThumbSrv
|
||||
from .up2k import Up2k
|
||||
from .util import ansi_re, min_ex, mp, start_log_thrs, start_stackmon, alltrace
|
||||
from .util import (
|
||||
VERSIONS,
|
||||
alltrace,
|
||||
ansi_re,
|
||||
min_ex,
|
||||
mp,
|
||||
start_log_thrs,
|
||||
start_stackmon,
|
||||
)
|
||||
|
||||
|
||||
class SvcHub(object):
|
||||
|
@ -535,7 +543,8 @@ class SvcHub(object):
|
|||
return
|
||||
|
||||
self.tstack = time.time()
|
||||
zb = alltrace().encode("utf-8", "replace")
|
||||
zs = "{}\n{}".format(VERSIONS, alltrace())
|
||||
zb = zs.encode("utf-8", "replace")
|
||||
zb = gzip.compress(zb)
|
||||
zs = base64.b64encode(zb).decode("ascii")
|
||||
self.log("stacks", zs)
|
||||
|
|
|
@ -715,9 +715,10 @@ class Up2k(object):
|
|||
)
|
||||
n_rm = self._drop_lost(db.c, top, excl)
|
||||
except Exception as ex:
|
||||
db_ex_chk(self.log, ex, db_path)
|
||||
t = "failed to index volume [{}]:\n{}"
|
||||
self.log(t.format(top, min_ex()), c=1)
|
||||
if db_ex_chk(self.log, ex, db_path):
|
||||
self.hub.log_stacks()
|
||||
|
||||
if db.n:
|
||||
self.log("commit {} new files".format(db.n))
|
||||
|
|
|
@ -22,6 +22,7 @@ from collections import Counter
|
|||
from datetime import datetime
|
||||
|
||||
from .__init__ import ANYWIN, PY2, TYPE_CHECKING, VT100, WINDOWS
|
||||
from .__version__ import S_BUILD_DT, S_VERSION
|
||||
from .stolen import surrogateescape
|
||||
|
||||
try:
|
||||
|
@ -213,6 +214,50 @@ REKOBO_KEY = {
|
|||
REKOBO_LKEY = {k.lower(): v for k, v in REKOBO_KEY.items()}
|
||||
|
||||
|
||||
def py_desc() -> str:
|
||||
interp = platform.python_implementation()
|
||||
py_ver = ".".join([str(x) for x in sys.version_info])
|
||||
ofs = py_ver.find(".final.")
|
||||
if ofs > 0:
|
||||
py_ver = py_ver[:ofs]
|
||||
|
||||
try:
|
||||
bitness = struct.calcsize(b"P") * 8
|
||||
except:
|
||||
bitness = struct.calcsize("P") * 8
|
||||
|
||||
host_os = platform.system()
|
||||
compiler = platform.python_compiler()
|
||||
|
||||
m = re.search(r"([0-9]+\.[0-9\.]+)", platform.version())
|
||||
os_ver = m.group(1) if m else ""
|
||||
|
||||
return "{:>9} v{} on {}{} {} [{}]".format(
|
||||
interp, py_ver, host_os, bitness, os_ver, compiler
|
||||
)
|
||||
|
||||
|
||||
try:
|
||||
from sqlite3 import sqlite_version as SQLITE_VER
|
||||
except:
|
||||
SQLITE_VER = "(None)"
|
||||
|
||||
try:
|
||||
from jinja2 import __version__ as JINJA_VER
|
||||
except:
|
||||
JINJA_VER = "(None)"
|
||||
|
||||
try:
|
||||
from pyftpdlib.__init__ import __ver__ as PYFTPD_VER
|
||||
except:
|
||||
PYFTPD_VER = "(None)"
|
||||
|
||||
|
||||
VERSIONS = "copyparty v{} ({})\n{}\n sqlite v{} | jinja v{} | pyftpd v{}".format(
|
||||
S_VERSION, S_BUILD_DT, py_desc(), SQLITE_VER, JINJA_VER, PYFTPD_VER
|
||||
)
|
||||
|
||||
|
||||
class Cooldown(object):
|
||||
def __init__(self, maxage: float) -> None:
|
||||
self.maxage = maxage
|
||||
|
@ -1759,29 +1804,6 @@ def gzip_orig_sz(fn: str) -> int:
|
|||
return sunpack(b"I", rv)[0] # type: ignore
|
||||
|
||||
|
||||
def py_desc() -> str:
|
||||
interp = platform.python_implementation()
|
||||
py_ver = ".".join([str(x) for x in sys.version_info])
|
||||
ofs = py_ver.find(".final.")
|
||||
if ofs > 0:
|
||||
py_ver = py_ver[:ofs]
|
||||
|
||||
try:
|
||||
bitness = struct.calcsize(b"P") * 8
|
||||
except:
|
||||
bitness = struct.calcsize("P") * 8
|
||||
|
||||
host_os = platform.system()
|
||||
compiler = platform.python_compiler()
|
||||
|
||||
m = re.search(r"([0-9]+\.[0-9\.]+)", platform.version())
|
||||
os_ver = m.group(1) if m else ""
|
||||
|
||||
return "{:>9} v{} on {}{} {} [{}]".format(
|
||||
interp, py_ver, host_os, bitness, os_ver, compiler
|
||||
)
|
||||
|
||||
|
||||
def align_tab(lines: list[str]) -> list[str]:
|
||||
rows = []
|
||||
ncols = 0
|
||||
|
|
Loading…
Reference in a new issue