mirror of
https://github.com/9001/copyparty.git
synced 2025-08-17 17:12:13 -06:00
hint at additional context in exceptions
This commit is contained in:
parent
033b50ae1b
commit
406e413594
|
@ -52,6 +52,10 @@ if TYPE_CHECKING:
|
||||||
|
|
||||||
LEELOO_DALLAS = "leeloo_dallas"
|
LEELOO_DALLAS = "leeloo_dallas"
|
||||||
|
|
||||||
|
SEE_LOG = "see log for details"
|
||||||
|
SSEELOG = " ({})".format(SEE_LOG)
|
||||||
|
BAD_CFG = "invalid config; {}".format(SEE_LOG)
|
||||||
|
SBADCFG = " ({})".format(BAD_CFG)
|
||||||
|
|
||||||
class AXS(object):
|
class AXS(object):
|
||||||
def __init__(
|
def __init__(
|
||||||
|
@ -795,7 +799,7 @@ class AuthSrv(object):
|
||||||
if dst in mount:
|
if dst in mount:
|
||||||
t = "multiple filesystem-paths mounted at [/{}]:\n [{}]\n [{}]"
|
t = "multiple filesystem-paths mounted at [/{}]:\n [{}]\n [{}]"
|
||||||
self.log(t.format(dst, mount[dst], src), c=1)
|
self.log(t.format(dst, mount[dst], src), c=1)
|
||||||
raise Exception("invalid config")
|
raise Exception(BAD_CFG)
|
||||||
|
|
||||||
if src in mount.values():
|
if src in mount.values():
|
||||||
t = "filesystem-path [{}] mounted in multiple locations:"
|
t = "filesystem-path [{}] mounted in multiple locations:"
|
||||||
|
@ -804,7 +808,7 @@ class AuthSrv(object):
|
||||||
t += "\n /{}".format(v)
|
t += "\n /{}".format(v)
|
||||||
|
|
||||||
self.log(t, c=3)
|
self.log(t, c=3)
|
||||||
raise Exception("invalid config")
|
raise Exception(BAD_CFG)
|
||||||
|
|
||||||
if not bos.path.isdir(src):
|
if not bos.path.isdir(src):
|
||||||
self.log("warning: filesystem-path does not exist: {}".format(src), 3)
|
self.log("warning: filesystem-path does not exist: {}".format(src), 3)
|
||||||
|
@ -903,7 +907,7 @@ class AuthSrv(object):
|
||||||
t = "volume-specific config (anything from --help-flags)"
|
t = "volume-specific config (anything from --help-flags)"
|
||||||
self._l(ln, 6, t)
|
self._l(ln, 6, t)
|
||||||
else:
|
else:
|
||||||
raise Exception("invalid section header")
|
raise Exception("invalid section header" + SBADCFG)
|
||||||
|
|
||||||
self.indent = " " if subsection else " "
|
self.indent = " " if subsection else " "
|
||||||
continue
|
continue
|
||||||
|
@ -926,7 +930,7 @@ class AuthSrv(object):
|
||||||
acct[u] = p
|
acct[u] = p
|
||||||
except:
|
except:
|
||||||
t = 'lines inside the [accounts] section must be "username: password"'
|
t = 'lines inside the [accounts] section must be "username: password"'
|
||||||
raise Exception(t)
|
raise Exception(t + SBADCFG)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if vp is not None and ap is None:
|
if vp is not None and ap is None:
|
||||||
|
@ -954,7 +958,7 @@ class AuthSrv(object):
|
||||||
continue
|
continue
|
||||||
except:
|
except:
|
||||||
err += "accs entries must be 'rwmdgGa: user1, user2, ...'"
|
err += "accs entries must be 'rwmdgGa: user1, user2, ...'"
|
||||||
raise Exception(err)
|
raise Exception(err + SBADCFG)
|
||||||
|
|
||||||
if cat == catf:
|
if cat == catf:
|
||||||
err = ""
|
err = ""
|
||||||
|
@ -967,7 +971,7 @@ class AuthSrv(object):
|
||||||
if bad:
|
if bad:
|
||||||
err = "bad characters [{}] in volflag name [{}]; "
|
err = "bad characters [{}] in volflag name [{}]; "
|
||||||
err = err.format(bad, sk)
|
err = err.format(bad, sk)
|
||||||
raise Exception(err)
|
raise Exception(err + SBADCFG)
|
||||||
if sv is True:
|
if sv is True:
|
||||||
fstr += "," + sk
|
fstr += "," + sk
|
||||||
else:
|
else:
|
||||||
|
@ -979,9 +983,9 @@ class AuthSrv(object):
|
||||||
continue
|
continue
|
||||||
except:
|
except:
|
||||||
err += "flags entries (volflags) must be one of the following:\n 'flag1, flag2, ...'\n 'key: value'\n 'flag1, flag2, key: value'"
|
err += "flags entries (volflags) must be one of the following:\n 'flag1, flag2, ...'\n 'key: value'\n 'flag1, flag2, key: value'"
|
||||||
raise Exception(err)
|
raise Exception(err + SBADCFG)
|
||||||
|
|
||||||
raise Exception("unprocessable line in config")
|
raise Exception("unprocessable line in config" + SBADCFG)
|
||||||
|
|
||||||
self._e()
|
self._e()
|
||||||
self.line_ctr = 0
|
self.line_ctr = 0
|
||||||
|
@ -1218,7 +1222,7 @@ class AuthSrv(object):
|
||||||
+ ", ".join(k for k in sorted(missing_users)),
|
+ ", ".join(k for k in sorted(missing_users)),
|
||||||
c=1,
|
c=1,
|
||||||
)
|
)
|
||||||
raise Exception("invalid config")
|
raise Exception(BAD_CFG)
|
||||||
|
|
||||||
if LEELOO_DALLAS in all_users:
|
if LEELOO_DALLAS in all_users:
|
||||||
raise Exception("sorry, reserved username: " + LEELOO_DALLAS)
|
raise Exception("sorry, reserved username: " + LEELOO_DALLAS)
|
||||||
|
@ -1228,7 +1232,7 @@ class AuthSrv(object):
|
||||||
if pwd in seenpwds:
|
if pwd in seenpwds:
|
||||||
t = "accounts [{}] and [{}] have the same password; this is not supported"
|
t = "accounts [{}] and [{}] have the same password; this is not supported"
|
||||||
self.log(t.format(seenpwds[pwd], usr), 1)
|
self.log(t.format(seenpwds[pwd], usr), 1)
|
||||||
raise Exception("invalid config")
|
raise Exception(BAD_CFG)
|
||||||
seenpwds[pwd] = usr
|
seenpwds[pwd] = usr
|
||||||
|
|
||||||
promote = []
|
promote = []
|
||||||
|
|
|
@ -29,7 +29,7 @@ if True: # pylint: disable=using-constant-test
|
||||||
from typing import Any, Optional, Union
|
from typing import Any, Optional, Union
|
||||||
|
|
||||||
from .__init__ import ANYWIN, EXE, MACOS, TYPE_CHECKING, EnvParams, unicode
|
from .__init__ import ANYWIN, EXE, MACOS, TYPE_CHECKING, EnvParams, unicode
|
||||||
from .authsrv import AuthSrv
|
from .authsrv import BAD_CFG, AuthSrv
|
||||||
from .cert import ensure_cert
|
from .cert import ensure_cert
|
||||||
from .mtag import HAVE_FFMPEG, HAVE_FFPROBE
|
from .mtag import HAVE_FFMPEG, HAVE_FFPROBE
|
||||||
from .tcpsrv import TcpSrv
|
from .tcpsrv import TcpSrv
|
||||||
|
@ -131,7 +131,7 @@ class SvcHub(object):
|
||||||
args.force_js = True
|
args.force_js = True
|
||||||
|
|
||||||
if not self._process_config():
|
if not self._process_config():
|
||||||
raise Exception("bad config")
|
raise Exception(BAD_CFG)
|
||||||
|
|
||||||
self.log_div = 10 ** (6 - args.log_tdec)
|
self.log_div = 10 ** (6 - args.log_tdec)
|
||||||
self.log_efmt = "%02d:%02d:%02d.%0{}d".format(args.log_tdec)
|
self.log_efmt = "%02d:%02d:%02d.%0{}d".format(args.log_tdec)
|
||||||
|
|
|
@ -22,7 +22,7 @@ from copy import deepcopy
|
||||||
from queue import Queue
|
from queue import Queue
|
||||||
|
|
||||||
from .__init__ import ANYWIN, PY2, TYPE_CHECKING, WINDOWS
|
from .__init__ import ANYWIN, PY2, TYPE_CHECKING, WINDOWS
|
||||||
from .authsrv import LEELOO_DALLAS, VFS, AuthSrv
|
from .authsrv import LEELOO_DALLAS, SSEELOG, VFS, AuthSrv
|
||||||
from .bos import bos
|
from .bos import bos
|
||||||
from .cfg import vf_bmap, vf_vmap
|
from .cfg import vf_bmap, vf_vmap
|
||||||
from .fsutil import Fstab
|
from .fsutil import Fstab
|
||||||
|
@ -2660,7 +2660,7 @@ class Up2k(object):
|
||||||
if not job:
|
if not job:
|
||||||
known = " ".join([x for x in self.registry[ptop].keys()])
|
known = " ".join([x for x in self.registry[ptop].keys()])
|
||||||
self.log("unknown wark [{}], known: {}".format(wark, known))
|
self.log("unknown wark [{}], known: {}".format(wark, known))
|
||||||
raise Pebkac(400, "unknown wark")
|
raise Pebkac(400, "unknown wark" + SSEELOG)
|
||||||
|
|
||||||
if chash not in job["need"]:
|
if chash not in job["need"]:
|
||||||
msg = "chash = {} , need:\n".format(chash)
|
msg = "chash = {} , need:\n".format(chash)
|
||||||
|
|
Loading…
Reference in a new issue