diff --git a/copyparty/authsrv.py b/copyparty/authsrv.py
index 47bb179c..eaa2a1ce 100644
--- a/copyparty/authsrv.py
+++ b/copyparty/authsrv.py
@@ -212,7 +212,7 @@ class Lim(object):
df, du, err = get_df(abspath, True)
if err:
- t = "failed to read disk space usage for [%s]: %s"
+ t = "failed to read disk space usage for %r: %s"
self.log(t % (abspath, err), 3)
self.dfv = 0xAAAAAAAAA # 42.6 GiB
else:
@@ -526,7 +526,7 @@ class VFS(object):
"""returns [vfsnode,fs_remainder] if user has the requested permissions"""
if relchk(vpath):
if self.log:
- self.log("vfs", "invalid relpath [{}]".format(vpath))
+ self.log("vfs", "invalid relpath %r @%s" % (vpath, uname))
raise Pebkac(422)
cvpath = undot(vpath)
@@ -543,11 +543,11 @@ class VFS(object):
if req and uname not in d and uname != LEELOO_DALLAS:
if vpath != cvpath and vpath != "." and self.log:
ap = vn.canonical(rem)
- t = "{} has no {} in [{}] => [{}] => [{}]"
- self.log("vfs", t.format(uname, msg, vpath, cvpath, ap), 6)
+ t = "%s has no %s in %r => %r => %r"
+ self.log("vfs", t % (uname, msg, vpath, cvpath, ap), 6)
- t = 'you don\'t have %s-access in "/%s" or below "/%s"'
- raise Pebkac(err, t % (msg, cvpath, vn.vpath))
+ t = "you don't have %s-access in %r or below %r"
+ raise Pebkac(err, t % (msg, "/" + cvpath, "/" + vn.vpath))
return vn, rem
@@ -693,8 +693,8 @@ class VFS(object):
and fsroot in seen
):
if self.log:
- t = "bailing from symlink loop,\n prev: {}\n curr: {}\n from: {}/{}"
- self.log("vfs.walk", t.format(seen[-1], fsroot, self.vpath, rem), 3)
+ t = "bailing from symlink loop,\n prev: %r\n curr: %r\n from: %r / %r"
+ self.log("vfs.walk", t % (seen[-1], fsroot, self.vpath, rem), 3)
return
if "xdev" in self.flags or "xvol" in self.flags:
@@ -818,8 +818,8 @@ class VFS(object):
if vdev != st.st_dev:
if self.log:
- t = "xdev: {}[{}] => {}[{}]"
- self.log("vfs", t.format(vdev, self.realpath, st.st_dev, ap), 3)
+ t = "xdev: %s[%r] => %s[%r]"
+ self.log("vfs", t % (vdev, self.realpath, st.st_dev, ap), 3)
return None
@@ -829,7 +829,7 @@ class VFS(object):
return vn
if self.log:
- self.log("vfs", "xvol: [{}]".format(ap), 3)
+ self.log("vfs", "xvol: %r" % (ap,), 3)
return None
@@ -914,7 +914,7 @@ class AuthSrv(object):
self.idp_accs[uname] = gnames
- t = "reinitializing due to new user from IdP: [%s:%s]"
+ t = "reinitializing due to new user from IdP: [%r:%r]"
self.log(t % (uname, gnames), 3)
if not broker:
@@ -1568,7 +1568,7 @@ class AuthSrv(object):
continue
if self.args.shr_v:
- t = "loading %s share [%s] by [%s] => [%s]"
+ t = "loading %s share %r by %r => %r"
self.log(t % (s_pr, s_k, s_un, s_vp))
if s_pw:
@@ -1765,7 +1765,7 @@ class AuthSrv(object):
use = True
try:
_ = float(zs)
- zs = "%sg" % (zs)
+ zs = "%sg" % (zs,)
except:
pass
lim.dfl = unhumanize(zs)
@@ -2538,7 +2538,7 @@ class AuthSrv(object):
return
elif self.args.chpw_v == 2:
- t = "chpw: %d changed" % (len(uok))
+ t = "chpw: %d changed" % (len(uok),)
if urst:
t += ", \033[0munchanged:\033[35m %s" % (", ".join(list(urst)))
diff --git a/copyparty/fsutil.py b/copyparty/fsutil.py
index a3099485..73ae6cd5 100644
--- a/copyparty/fsutil.py
+++ b/copyparty/fsutil.py
@@ -42,14 +42,14 @@ class Fstab(object):
self.cache = {}
fs = "ext4"
- msg = "failed to determine filesystem at [{}]; assuming {}\n{}"
+ msg = "failed to determine filesystem at %r; assuming %s\n%s"
if ANYWIN:
fs = "vfat"
try:
path = self._winpath(path)
except:
- self.log(msg.format(path, fs, min_ex()), 3)
+ self.log(msg % (path, fs, min_ex()), 3)
return fs
path = undot(path)
@@ -61,11 +61,11 @@ class Fstab(object):
try:
fs = self.get_w32(path) if ANYWIN else self.get_unix(path)
except:
- self.log(msg.format(path, fs, min_ex()), 3)
+ self.log(msg % (path, fs, min_ex()), 3)
fs = fs.lower()
self.cache[path] = fs
- self.log("found {} at {}".format(fs, path))
+ self.log("found %s at %r" % (fs, path))
return fs
def _winpath(self, path: str) -> str:
diff --git a/copyparty/httpcli.py b/copyparty/httpcli.py
index df2ec1bb..abd9b3dc 100644
--- a/copyparty/httpcli.py
+++ b/copyparty/httpcli.py
@@ -479,8 +479,8 @@ class HttpCli(object):
if vpath.startswith(self.args.R):
vpath = vpath[len(self.args.R) + 1 :]
else:
- t = "incorrect --rp-loc or webserver config; expected vpath starting with [{}] but got [{}]"
- self.log(t.format(self.args.R, vpath), 1)
+ t = "incorrect --rp-loc or webserver config; expected vpath starting with %r but got %r"
+ self.log(t % (self.args.R, vpath), 1)
self.ouparam = uparam.copy()
@@ -518,7 +518,7 @@ class HttpCli(object):
return self.tx_qr()
if relchk(self.vpath) and (self.vpath != "*" or self.mode != "OPTIONS"):
- self.log("invalid relpath [{}]".format(self.vpath))
+ self.log("invalid relpath %r" % ("/" + self.vpath,))
self.cbonk(self.conn.hsrv.gmal, self.req, "bad_vp", "invalid relpaths")
return self.tx_404() and self.keepalive
@@ -598,7 +598,7 @@ class HttpCli(object):
self.uname = idp_usr
self.html_head += "\n"
else:
- self.log("unknown username: [%s]" % (idp_usr), 1)
+ self.log("unknown username: %r" % (idp_usr,), 1)
if self.args.ipu and self.uname == "*":
self.uname = self.conn.ipu_iu[self.conn.ipu_nm.map(self.ip)]
@@ -663,7 +663,7 @@ class HttpCli(object):
origin = self.headers.get("origin", ">")
proto = "https://" if self.is_https else "http://"
guess = "modifying" if (origin and host) else "stripping"
- t = "cors-reject %s because request-header Origin='%s' does not match request-protocol '%s' and host '%s' based on request-header Host='%s' (note: if this request is not malicious, check if your reverse-proxy is accidentally %s request headers, in particular 'Origin', for example by running copyparty with --ihead='*' to show all request headers)"
+ t = "cors-reject %s because request-header Origin=%r does not match request-protocol %r and host %r based on request-header Host=%r (note: if this request is not malicious, check if your reverse-proxy is accidentally %s request headers, in particular 'Origin', for example by running copyparty with --ihead='*' to show all request headers)"
self.log(t % (self.mode, origin, proto, self.host, host, guess), 3)
raise Pebkac(403, "rejected by cors-check")
@@ -709,7 +709,7 @@ class HttpCli(object):
if pex.code != 404 or self.do_log:
self.log(
- "http%d: %s\033[0m, %s" % (pex.code, msg, self.vpath),
+ "http%d: %s\033[0m, %r" % (pex.code, msg, "/" + self.vpath),
6 if em.startswith("client d/c ") else 3,
)
@@ -1154,8 +1154,8 @@ class HttpCli(object):
return self.tx_res(res_path)
if res_path != undot(res_path):
- t = "malicious user; attempted path traversal [{}] => [{}]"
- self.log(t.format(self.vpath, res_path), 1)
+ t = "malicious user; attempted path traversal %r => %r"
+ self.log(t % ("/" + self.vpath, res_path), 1)
self.cbonk(self.conn.hsrv.gmal, self.req, "trav", "path traversal")
self.tx_404()
@@ -1166,11 +1166,11 @@ class HttpCli(object):
return True
if not self.can_read and not self.can_write and not self.can_get:
- t = "@{} has no access to [{}]"
+ t = "@%s has no access to %r"
if "on403" in self.vn.flags:
t += " (on403)"
- self.log(t.format(self.uname, self.vpath))
+ self.log(t % (self.uname, "/" + self.vpath))
ret = self.on40x(self.vn.flags["on403"], self.vn, self.rem)
if ret == "true":
return True
@@ -1189,7 +1189,7 @@ class HttpCli(object):
if self.vpath:
ptn = self.args.nonsus_urls
if not ptn or not ptn.search(self.vpath):
- self.log(t.format(self.uname, self.vpath))
+ self.log(t % (self.uname, "/" + self.vpath))
return self.tx_404(True)
@@ -1435,14 +1435,14 @@ class HttpCli(object):
if depth == "infinity":
# allow depth:0 from unmapped root, but require read-axs otherwise
if not self.can_read and (self.vpath or self.asrv.vfs.realpath):
- t = "depth:infinity requires read-access in /%s"
- t = t % (self.vpath,)
+ t = "depth:infinity requires read-access in %r"
+ t = t % ("/" + self.vpath,)
self.log(t, 3)
raise Pebkac(401, t)
if not stat.S_ISDIR(topdir["st"].st_mode):
- t = "depth:infinity can only be used on folders; /%s is 0o%o"
- t = t % (self.vpath, topdir["st"])
+ t = "depth:infinity can only be used on folders; %r is 0o%o"
+ t = t % ("/" + self.vpath, topdir["st"])
self.log(t, 3)
raise Pebkac(400, t)
@@ -1468,7 +1468,7 @@ class HttpCli(object):
elif depth == "0" or not stat.S_ISDIR(st.st_mode):
# propfind on a file; return as topdir
if not self.can_read and not self.can_get:
- self.log("inaccessible: [%s]" % (self.vpath,))
+ self.log("inaccessible: %r" % ("/" + self.vpath,))
raise Pebkac(401, "authenticate")
elif depth == "1":
@@ -1495,7 +1495,7 @@ class HttpCli(object):
raise Pebkac(412, t.format(depth, t2))
if not self.can_read and not self.can_write and not fgen:
- self.log("inaccessible: [%s]" % (self.vpath,))
+ self.log("inaccessible: %r" % ("/" + self.vpath,))
raise Pebkac(401, "authenticate")
fgen = itertools.chain([topdir], fgen)
@@ -1573,7 +1573,7 @@ class HttpCli(object):
raise Pebkac(405, "WebDAV is disabled in server config")
if not self.can_write:
- self.log("{} tried to proppatch [{}]".format(self.uname, self.vpath))
+ self.log("%s tried to proppatch %r" % (self.uname, "/" + self.vpath))
raise Pebkac(401, "authenticate")
from xml.etree import ElementTree as ET
@@ -1631,7 +1631,7 @@ class HttpCli(object):
# win7+ deadlocks if we say no; just smile and nod
if not self.can_write and "Microsoft-WebDAV" not in self.ua:
- self.log("{} tried to lock [{}]".format(self.uname, self.vpath))
+ self.log("%s tried to lock %r" % (self.uname, "/" + self.vpath))
raise Pebkac(401, "authenticate")
from xml.etree import ElementTree as ET
@@ -1697,7 +1697,7 @@ class HttpCli(object):
raise Pebkac(405, "WebDAV is disabled in server config")
if not self.can_write and "Microsoft-WebDAV" not in self.ua:
- self.log("{} tried to lock [{}]".format(self.uname, self.vpath))
+ self.log("%s tried to lock %r" % (self.uname, "/" + self.vpath))
raise Pebkac(401, "authenticate")
self.send_headers(None, 204)
@@ -1851,7 +1851,7 @@ class HttpCli(object):
if "save" in opt:
post_sz, _, _, _, path, _ = self.dump_to_file(False)
- self.log("urlform: {} bytes, {}".format(post_sz, path))
+ self.log("urlform: %d bytes, %r" % (post_sz, path))
elif "print" in opt:
reader, _ = self.get_body_reader()
buf = b""
@@ -1862,8 +1862,8 @@ class HttpCli(object):
if buf:
orig = buf.decode("utf-8", "replace")
- t = "urlform_raw {} @ {}\n {}\n"
- self.log(t.format(len(orig), self.vpath, orig))
+ t = "urlform_raw %d @ %r\n %r\n"
+ self.log(t % (len(orig), "/" + self.vpath, orig))
try:
zb = unquote(buf.replace(b"+", b" "))
plain = zb.decode("utf-8", "replace")
@@ -1889,8 +1889,8 @@ class HttpCli(object):
plain,
)
- t = "urlform_dec {} @ {}\n {}\n"
- self.log(t.format(len(plain), self.vpath, plain))
+ t = "urlform_dec %d @ %r\n %r\n"
+ self.log(t % (len(plain), "/" + self.vpath, plain))
except Exception as ex:
self.log(repr(ex))
@@ -2140,7 +2140,7 @@ class HttpCli(object):
try:
ext = self.conn.hsrv.magician.ext(path)
except Exception as ex:
- self.log("filetype detection failed for [{}]: {}".format(path, ex), 6)
+ self.log("filetype detection failed for %r: %s" % (path, ex), 6)
ext = None
if ext:
@@ -2240,8 +2240,8 @@ class HttpCli(object):
def handle_stash(self, is_put: bool) -> bool:
post_sz, sha_hex, sha_b64, remains, path, url = self.dump_to_file(is_put)
spd = self._spd(post_sz)
- t = "{} wrote {}/{} bytes to {} # {}"
- self.log(t.format(spd, post_sz, remains, path, sha_b64[:28])) # 21
+ t = "%s wrote %d/%d bytes to %r # %s"
+ self.log(t % (spd, post_sz, remains, path, sha_b64[:28])) # 21
ac = self.uparam.get(
"want", self.headers.get("accept", "").lower().split(";")[-1]
@@ -2271,7 +2271,7 @@ class HttpCli(object):
flags: dict[str, Any],
) -> None:
now = time.time()
- t = "bad-chunk: %.3f %s %s %d %s %s %s"
+ t = "bad-chunk: %.3f %s %s %d %s %s %r"
t = t % (now, bad_sha, good_sha, ofs, self.ip, self.uname, ap)
self.log(t, 5)
@@ -2411,7 +2411,7 @@ class HttpCli(object):
body = json.loads(json_buf.decode(enc, "replace"))
try:
zds = {k: v for k, v in body.items()}
- zds["hash"] = "%d chunks" % (len(body["hash"]))
+ zds["hash"] = "%d chunks" % (len(body["hash"]),)
except:
zds = body
t = "POST len=%d type=%s ip=%s user=%s req=%r json=%s"
@@ -2455,7 +2455,7 @@ class HttpCli(object):
if not bos.path.isdir(dst):
bos.makedirs(dst)
except OSError as ex:
- self.log("makedirs failed [{}]".format(dst))
+ self.log("makedirs failed %r" % (dst,))
if not bos.path.isdir(dst):
if ex.errno == errno.EACCES:
raise Pebkac(500, "the server OS denied write-access")
@@ -2480,7 +2480,7 @@ class HttpCli(object):
# strip common suffix (uploader's folder structure)
vp_req, vp_vfs = vroots(self.vpath, vjoin(dbv.vpath, vrem))
if not ret["purl"].startswith(vp_vfs):
- t = "share-mapping failed; req=[%s] dbv=[%s] vrem=[%s] n1=[%s] n2=[%s] purl=[%s]"
+ t = "share-mapping failed; req=%r dbv=%r vrem=%r n1=%r n2=%r purl=%r"
zt = (self.vpath, dbv.vpath, vrem, vp_req, vp_vfs, ret["purl"])
raise Pebkac(500, t % zt)
ret["purl"] = vp_req + ret["purl"][len(vp_vfs) :]
@@ -2529,13 +2529,13 @@ class HttpCli(object):
# search by query params
q = body["q"]
n = body.get("n", self.args.srch_hits)
- self.log("qj: {} |{}|".format(q, n))
+ self.log("qj: %r |%d|" % (q, n))
hits, taglist, trunc = idx.search(self.uname, vols, q, n)
msg = len(hits)
idx.p_end = time.time()
idx.p_dur = idx.p_end - t0
- self.log("q#: {} ({:.2f}s)".format(msg, idx.p_dur))
+ self.log("q#: %r (%.2fs)" % (msg, idx.p_dur))
order = []
for t in self.args.mte:
@@ -2646,7 +2646,7 @@ class HttpCli(object):
t = "your client is sending %d bytes which is too much (server expected %d bytes at most)"
raise Pebkac(400, t % (remains, maxsize))
- t = "writing %s %s+%d #%d+%d %s"
+ t = "writing %r %s+%d #%d+%d %s"
chunkno = cstart0[0] // chunksize
zs = " ".join([chashes[0][:15]] + [x[:9] for x in chashes[1:]])
self.log(t % (path, cstart0, remains, chunkno, len(chashes), zs))
@@ -2758,7 +2758,7 @@ class HttpCli(object):
cinf = self.headers.get("x-up2k-stat", "")
spd = self._spd(postsize)
- self.log("{:70} thank {}".format(spd, cinf))
+ self.log("%70s thank %r" % (spd, cinf))
self.reply(b"thank")
return True
@@ -2840,7 +2840,7 @@ class HttpCli(object):
logpwd = "%" + ub64enc(zb[:12]).decode("ascii")
if pwd != "x":
- self.log("invalid password: {}".format(logpwd), 3)
+ self.log("invalid password: %r" % (logpwd,), 3)
self.cbonk(self.conn.hsrv.gpwd, pwd, "pw", "invalid passwords")
msg = "naw dude"
@@ -2876,7 +2876,7 @@ class HttpCli(object):
rem = sanitize_vpath(rem, "/")
fn = vfs.canonical(rem)
if not fn.startswith(vfs.realpath):
- self.log("invalid mkdir [%s] [%s]" % (self.gctx, vpath), 1)
+ self.log("invalid mkdir %r %r" % (self.gctx, vpath), 1)
raise Pebkac(422)
if not nullwrite:
@@ -3042,9 +3042,9 @@ class HttpCli(object):
elif bos.path.exists(abspath):
try:
wunlink(self.log, abspath, vfs.flags)
- t = "overwriting file with new upload: %s"
+ t = "overwriting file with new upload: %r"
except:
- t = "toctou while deleting for ?replace: %s"
+ t = "toctou while deleting for ?replace: %r"
self.log(t % (abspath,))
else:
open_args = {}
@@ -3127,7 +3127,7 @@ class HttpCli(object):
f, tnam = ren_open(tnam, "wb", self.args.iobuf, **open_args)
try:
tabspath = os.path.join(fdir, tnam)
- self.log("writing to {}".format(tabspath))
+ self.log("writing to %r" % (tabspath,))
sz, sha_hex, sha_b64 = copier(
p_data, f, hasher, max_sz, self.args.s_wr_slp
)
@@ -3312,7 +3312,7 @@ class HttpCli(object):
jmsg["files"].append(jpart)
vspd = self._spd(sz_total, False)
- self.log("{} {}".format(vspd, msg))
+ self.log("%s %r" % (vspd, msg))
suf = ""
if not nullwrite and self.args.write_uplog:
@@ -3575,7 +3575,7 @@ class HttpCli(object):
if req == zs:
return True
- t = "wrong dirkey, want %s, got %s\n vp: %s\n ap: %s"
+ t = "wrong dirkey, want %s, got %s\n vp: %r\n ap: %r"
self.log(t % (zs, req, self.req, ap), 6)
return False
@@ -3603,7 +3603,7 @@ class HttpCli(object):
if req == zs:
return True
- t = "wrong filekey, want %s, got %s\n vp: %s\n ap: %s"
+ t = "wrong filekey, want %s, got %s\n vp: %r\n ap: %r"
self.log(t % (zs, req, self.req, ap), 6)
return False
@@ -3665,7 +3665,7 @@ class HttpCli(object):
elif ph == "srv.htime":
sv = datetime.now(UTC).strftime("%Y-%m-%d, %H:%M:%S")
else:
- self.log("unknown placeholder in server config: [%s]" % (ph), 3)
+ self.log("unknown placeholder in server config: [%s]" % (ph,), 3)
continue
sv = self.conn.hsrv.ptn_hsafe.sub("_", sv)
@@ -3822,7 +3822,7 @@ class HttpCli(object):
self.pipes.set(req_path, job)
except Exception as ex:
if getattr(ex, "errno", 0) != errno.ENOENT:
- self.log("will not pipe [%s]; %s" % (ap_data, ex), 6)
+ self.log("will not pipe %r; %s" % (ap_data, ex), 6)
ptop = None
#
@@ -4112,7 +4112,7 @@ class HttpCli(object):
if lower >= data_end:
if data_end:
t = "pipe: uploader is too slow; aborting download at %.2f MiB"
- self.log(t % (data_end / M))
+ self.log(t % (data_end / M,))
raise Pebkac(416, "uploader is too slow")
raise Pebkac(416, "no data available yet; please retry in a bit")
@@ -4256,7 +4256,7 @@ class HttpCli(object):
cdis = "attachment; filename=\"{}.{}\"; filename*=UTF-8''{}.{}"
cdis = cdis.format(afn, ext, ufn, ext)
- self.log(cdis)
+ self.log(repr(cdis))
self.send_headers(None, mime=mime, headers={"Content-Disposition": cdis})
fgen = vn.zipgen(
@@ -4920,7 +4920,7 @@ class HttpCli(object):
raise Pebkac(500, "server busy, cannot unpost; please retry in a bit")
filt = self.uparam.get("filter") or ""
- lm = "ups [{}]".format(filt)
+ lm = "ups %r" % (filt,)
self.log(lm)
if self.args.shr and self.vpath.startswith(self.args.shr1):
@@ -5731,7 +5731,7 @@ class HttpCli(object):
linf = stats.get(fn) or bos.lstat(fspath)
inf = bos.stat(fspath) if stat.S_ISLNK(linf.st_mode) else linf
except:
- self.log("broken symlink: {}".format(repr(fspath)))
+ self.log("broken symlink: %r" % (fspath,))
continue
is_dir = stat.S_ISDIR(inf.st_mode)
@@ -5846,8 +5846,7 @@ class HttpCli(object):
erd_efn = s3enc(idx.mem_cur, rd, fn)
r = icur.execute(q, erd_efn)
except:
- t = "tag read error, {}/{}\n{}"
- self.log(t.format(rd, fn, min_ex()))
+ self.log("tag read error, %r / %r\n%s" % (rd, fn, min_ex()))
break
tags = {k: v for k, v in r}
@@ -5967,10 +5966,10 @@ class HttpCli(object):
if doc.lower().endswith(".md") and "exp" in vn.flags:
doctxt = self._expand(doctxt, vn.flags.get("exp_md") or [])
else:
- self.log("doc 2big: [{}]".format(doc), c=6)
+ self.log("doc 2big: %r" % (doc,), 6)
doctxt = "( size of textfile exceeds serverside limit )"
else:
- self.log("doc 404: [{}]".format(doc), c=6)
+ self.log("doc 404: %r" % (doc,), 6)
doctxt = "( textfile not found )"
if doctxt is not None:
diff --git a/copyparty/mtag.py b/copyparty/mtag.py
index 8bbd969c..583e9328 100644
--- a/copyparty/mtag.py
+++ b/copyparty/mtag.py
@@ -194,7 +194,7 @@ def au_unpk(
except Exception as ex:
if ret:
- t = "failed to decompress audio file [%s]: %r"
+ t = "failed to decompress audio file %r: %r"
log(t % (abspath, ex))
wunlink(log, ret, vn.flags if vn else VF_CAREFUL)
@@ -582,7 +582,7 @@ class MTag(object):
raise Exception()
except Exception as ex:
if self.args.mtag_v:
- self.log("mutagen-err [{}] @ [{}]".format(ex, abspath), "90")
+ self.log("mutagen-err [%s] @ %r" % (ex, abspath), "90")
return self.get_ffprobe(abspath) if self.can_ffprobe else {}
@@ -699,8 +699,8 @@ class MTag(object):
ret[tag] = zj[tag]
except:
if self.args.mtag_v:
- t = "mtag error: tagname {}, parser {}, file {} => {}"
- self.log(t.format(tagname, parser.bin, abspath, min_ex()))
+ t = "mtag error: tagname %r, parser %r, file %r => %r"
+ self.log(t % (tagname, parser.bin, abspath, min_ex()), 6)
if ap != abspath:
wunlink(self.log, ap, VF_CAREFUL)
diff --git a/copyparty/smbd.py b/copyparty/smbd.py
index d165f10f..b138ffdb 100644
--- a/copyparty/smbd.py
+++ b/copyparty/smbd.py
@@ -263,7 +263,7 @@ class SMB(object):
time.time(),
"",
):
- yeet("blocked by xbu server config: " + vpath)
+ yeet("blocked by xbu server config: %r" % (vpath,))
ret = bos.open(ap, flags, *a, mode=chmod, **ka)
if wr:
diff --git a/copyparty/sutil.py b/copyparty/sutil.py
index 6befbe8a..d706a235 100644
--- a/copyparty/sutil.py
+++ b/copyparty/sutil.py
@@ -110,7 +110,7 @@ def errdesc(
report = ["copyparty failed to add the following files to the archive:", ""]
for fn, err in errors:
- report.extend([" file: {}".format(fn), "error: {}".format(err), ""])
+ report.extend([" file: %r" % (fn,), "error: %s" % (err,), ""])
btxt = "\r\n".join(report).encode("utf-8", "replace")
btxt = vol_san(list(vfs.all_vols.values()), btxt)
diff --git a/copyparty/tftpd.py b/copyparty/tftpd.py
index f2403fbe..a233e56f 100644
--- a/copyparty/tftpd.py
+++ b/copyparty/tftpd.py
@@ -357,7 +357,7 @@ class Tftpd(object):
time.time(),
"",
):
- yeet("blocked by xbu server config: " + vpath)
+ yeet("blocked by xbu server config: %r" % (vpath,))
if not self.args.tftp_nols and bos.path.isdir(ap):
return self._ls(vpath, "", 0, True)
diff --git a/copyparty/th_cli.py b/copyparty/th_cli.py
index 6bebd3de..9b6e0dd8 100644
--- a/copyparty/th_cli.py
+++ b/copyparty/th_cli.py
@@ -109,13 +109,13 @@ class ThumbCli(object):
fmt = sfmt
elif fmt[:1] == "p" and not is_au and not is_vid:
- t = "cannot thumbnail [%s]: png only allowed for waveforms"
- self.log(t % (rem), 6)
+ t = "cannot thumbnail %r: png only allowed for waveforms"
+ self.log(t % (rem,), 6)
return None
histpath = self.asrv.vfs.histtab.get(ptop)
if not histpath:
- self.log("no histpath for [{}]".format(ptop))
+ self.log("no histpath for %r" % (ptop,))
return None
tpath = thumb_path(histpath, rem, mtime, fmt, self.fmt_ffa)
diff --git a/copyparty/th_srv.py b/copyparty/th_srv.py
index dcfcde17..70f6d644 100644
--- a/copyparty/th_srv.py
+++ b/copyparty/th_srv.py
@@ -239,7 +239,7 @@ class ThumbSrv(object):
def get(self, ptop: str, rem: str, mtime: float, fmt: str) -> Optional[str]:
histpath = self.asrv.vfs.histtab.get(ptop)
if not histpath:
- self.log("no histpath for [{}]".format(ptop))
+ self.log("no histpath for %r" % (ptop,))
return None
tpath = thumb_path(histpath, rem, mtime, fmt, self.fmt_ffa)
@@ -249,7 +249,7 @@ class ThumbSrv(object):
with self.mutex:
try:
self.busy[tpath].append(cond)
- self.log("joined waiting room for %s" % (tpath,))
+ self.log("joined waiting room for %r" % (tpath,))
except:
thdir = os.path.dirname(tpath)
bos.makedirs(os.path.join(thdir, "w"))
@@ -266,11 +266,11 @@ class ThumbSrv(object):
allvols = list(self.asrv.vfs.all_vols.values())
vn = next((x for x in allvols if x.realpath == ptop), None)
if not vn:
- self.log("ptop [{}] not in {}".format(ptop, allvols), 3)
+ self.log("ptop %r not in %s" % (ptop, allvols), 3)
vn = self.asrv.vfs.all_aps[0][1]
self.q.put((abspath, tpath, fmt, vn))
- self.log("conv {} :{} \033[0m{}".format(tpath, fmt, abspath), c=6)
+ self.log("conv %r :%s \033[0m%r" % (tpath, fmt, abspath), 6)
while not self.stopping:
with self.mutex:
@@ -375,8 +375,8 @@ class ThumbSrv(object):
fun(ap_unpk, ttpath, fmt, vn)
break
except Exception as ex:
- msg = "{} could not create thumbnail of {}\n{}"
- msg = msg.format(fun.__name__, abspath, min_ex())
+ msg = "%s could not create thumbnail of %r\n%s"
+ msg = msg % (fun.__name__, abspath, min_ex())
c: Union[str, int] = 1 if " str:
@@ -1060,7 +1060,7 @@ class Up2k(object):
"""mutex(main,reg) me"""
histpath = self.vfs.histtab.get(ptop)
if not histpath:
- self.log("no histpath for [{}]".format(ptop))
+ self.log("no histpath for %r" % (ptop,))
return None
db_path = os.path.join(histpath, "up2k.db")
@@ -1154,7 +1154,7 @@ class Up2k(object):
job["poke"] = time.time()
job["busy"] = {}
else:
- self.log("ign deleted file in snap: [{}]".format(fp))
+ self.log("ign deleted file in snap: %r" % (fp,))
if not n4g:
rm.append(k)
continue
@@ -1386,12 +1386,12 @@ class Up2k(object):
xvol: bool,
) -> tuple[int, int, int]:
if xvol and not rcdir.startswith(top):
- self.log("skip xvol: [{}] -> [{}]".format(cdir, rcdir), 6)
+ self.log("skip xvol: %r -> %r" % (cdir, rcdir), 6)
return 0, 0, 0
if rcdir in seen:
- t = "bailing from symlink loop,\n prev: {}\n curr: {}\n from: {}"
- self.log(t.format(seen[-1], rcdir, cdir), 3)
+ t = "bailing from symlink loop,\n prev: %r\n curr: %r\n from: %r"
+ self.log(t % (seen[-1], rcdir, cdir), 3)
return 0, 0, 0
# total-files-added, total-num-files, recursive-size
@@ -1447,7 +1447,7 @@ class Up2k(object):
and inf.st_dev != dev
and not (ANYWIN and bos.stat(rap).st_dev == dev)
):
- self.log("skip xdev {}->{}: {}".format(dev, inf.st_dev, abspath), 6)
+ self.log("skip xdev %s->%s: %r" % (dev, inf.st_dev, abspath), 6)
continue
if abspath in excl or rap in excl:
unreg.append(rp)
@@ -1476,10 +1476,10 @@ class Up2k(object):
tnf += i2
rsz += i3
except:
- t = "failed to index subdir [{}]:\n{}"
- self.log(t.format(abspath, min_ex()), c=1)
+ t = "failed to index subdir %r:\n%s"
+ self.log(t % (abspath, min_ex()), 1)
elif not stat.S_ISREG(inf.st_mode):
- self.log("skip type-0%o file [%s]" % (inf.st_mode, abspath))
+ self.log("skip type-0%o file %r" % (inf.st_mode, abspath))
else:
# self.log("file: {}".format(abspath))
if rp.endswith(".PARTIAL") and time.time() - lmod < 60:
@@ -1562,7 +1562,7 @@ class Up2k(object):
db.c.execute("insert into cv values (?,?,?)", (crd, cdn, cv))
db.n += 1
except Exception as ex:
- self.log("cover {}/{} failed: {}".format(rd, cv, ex), 6)
+ self.log("cover %r/%r failed: %s" % (rd, cv, ex), 6)
seen_files = set([x[2] for x in files]) # for dropcheck
for sz, lmod, fn in files:
@@ -1584,9 +1584,9 @@ class Up2k(object):
self.pp.n -= 1
dw, dts, dsz, ip, at = in_db[0]
if len(in_db) > 1:
- t = "WARN: multiple entries: [{}] => [{}] |{}|\n{}"
+ t = "WARN: multiple entries: %r => %r |%d|\n%r"
rep_db = "\n".join([repr(x) for x in in_db])
- self.log(t.format(top, rp, len(in_db), rep_db))
+ self.log(t % (top, rp, len(in_db), rep_db))
dts = -1
if fat32 and abs(dts - lmod) == 1:
@@ -1595,10 +1595,8 @@ class Up2k(object):
if dts == lmod and dsz == sz and (nohash or dw[0] != "#" or not sz):
continue
- t = "reindex [{}] => [{}] mtime({}/{}) size({}/{})".format(
- top, rp, dts, lmod, dsz, sz
- )
- self.log(t)
+ t = "reindex %r => %r mtime(%s/%s) size(%s/%s)"
+ self.log(t % (top, rp, dts, lmod, dsz, sz))
self.db_rm(db.c, rd, fn, 0)
tfa += 1
db.n += 1
@@ -1614,14 +1612,14 @@ class Up2k(object):
wark = up2k_wark_from_metadata(self.salt, sz, lmod, rd, fn)
else:
if sz > 1024 * 1024:
- self.log("file: {}".format(abspath))
+ self.log("file: %r" % (abspath,))
try:
hashes, _ = self._hashlist_from_file(
abspath, "a{}, ".format(self.pp.n)
)
except Exception as ex:
- self.log("hash: {} @ [{}]".format(repr(ex), abspath))
+ self.log("hash: %r @ %r" % (ex, abspath))
continue
if not hashes:
@@ -1667,8 +1665,8 @@ class Up2k(object):
assert erd_erd # type: ignore # !rm
if n:
- t = "forgetting {} shadowed autoindexed files in [{}] > [{}]"
- self.log(t.format(n, top, sh_rd))
+ t = "forgetting %d shadowed autoindexed files in %r > %r"
+ self.log(t % (n, top, sh_rd))
q = "delete from dh where (d = ? or d like ?||'/%')"
db.c.execute(q, erd_erd)
@@ -1865,7 +1863,7 @@ class Up2k(object):
stl = bos.lstat(abspath)
st = bos.stat(abspath) if stat.S_ISLNK(stl.st_mode) else stl
except Exception as ex:
- self.log("missing file: %s" % (abspath,), 3)
+ self.log("missing file: %r" % (abspath,), 3)
f404.append((drd, dfn, w))
continue
@@ -1876,12 +1874,12 @@ class Up2k(object):
w2 = up2k_wark_from_metadata(self.salt, sz2, mt2, rd, fn)
else:
if sz2 > 1024 * 1024 * 32:
- self.log("file: {}".format(abspath))
+ self.log("file: %r" % (abspath,))
try:
hashes, _ = self._hashlist_from_file(abspath, pf)
except Exception as ex:
- self.log("hash: {} @ [{}]".format(repr(ex), abspath))
+ self.log("hash: %r @ %r" % (ex, abspath))
continue
if not hashes:
@@ -1901,9 +1899,8 @@ class Up2k(object):
rewark.append((drd, dfn, w2, sz2, mt2))
- t = "hash mismatch: {}\n db: {} ({} byte, {})\n fs: {} ({} byte, {})"
- t = t.format(abspath, w, sz, mt, w2, sz2, mt2)
- self.log(t, 1)
+ t = "hash mismatch: %r\n db: %s (%d byte, %d)\n fs: %s (%d byte, %d)"
+ self.log(t % (abspath, w, sz, mt, w2, sz2, mt2), 1)
if e2vp and (rewark or f404):
self.hub.retcode = 1
@@ -2451,7 +2448,7 @@ class Up2k(object):
q.task_done()
def _log_tag_err(self, parser: Any, abspath: str, ex: Any) -> None:
- msg = "{} failed to read tags from {}:\n{}".format(parser, abspath, ex)
+ msg = "%s failed to read tags from %r:\n%s" % (parser, abspath, ex)
self.log(msg.lstrip(), c=1 if " None:
with self.hashq_mutex:
@@ -5169,7 +5169,7 @@ class Up2k(object):
if not self._hash_t(task) and self.stop:
return
except Exception as ex:
- self.log("failed to hash %s: %s" % (task, ex), 1)
+ self.log("failed to hash %r: %s" % (task, ex), 1)
def _hash_t(
self, task: tuple[str, str, dict[str, Any], str, str, str, float, str, bool]
@@ -5181,7 +5181,7 @@ class Up2k(object):
return True
abspath = djoin(ptop, rd, fn)
- self.log("hashing " + abspath)
+ self.log("hashing %r" % (abspath,))
inf = bos.stat(abspath)
if not inf.st_size:
wark = up2k_wark_from_metadata(
@@ -5274,7 +5274,7 @@ class Up2k(object):
x = pathmod(self.vfs, "", req_vp, {"vp": fvp, "fn": fn})
if not x:
- t = "hook_fx(%s): failed to resolve %s based on %s"
+ t = "hook_fx(%s): failed to resolve %r based on %r"
self.log(t % (act, fvp, req_vp))
continue
diff --git a/copyparty/util.py b/copyparty/util.py
index 6c3cc8ee..736e7905 100644
--- a/copyparty/util.py
+++ b/copyparty/util.py
@@ -1024,7 +1024,7 @@ class ProgressPrinter(threading.Thread):
now = time.time()
if msg and now - tp > 10:
tp = now
- self.log("progress: %s" % (msg,), 6)
+ self.log("progress: %r" % (msg,), 6)
if no_stdout:
continue
@@ -1626,7 +1626,7 @@ class MultipartParser(object):
(only the fallback non-js uploader relies on these filenames)
"""
for ln in read_header(self.sr, 2, 2592000):
- self.log(ln)
+ self.log(repr(ln))
m = self.re_ctype.match(ln)
if m:
@@ -1917,11 +1917,11 @@ def gen_filekey_dbg(
if p2 != fspath:
raise Exception()
except:
- t = "maybe wrong abspath for filekey;\norig: {}\nreal: {}"
- log(t.format(fspath, p2), 1)
+ t = "maybe wrong abspath for filekey;\norig: %r\nreal: %r"
+ log(t % (fspath, p2), 1)
- t = "fk({}) salt({}) size({}) inode({}) fspath({}) at({})"
- log(t.format(ret[:8], salt, fsize, inode, fspath, ctx), 5)
+ t = "fk(%s) salt(%s) size(%d) inode(%d) fspath(%r) at(%s)"
+ log(t % (ret[:8], salt, fsize, inode, fspath, ctx), 5)
return ret
@@ -2277,7 +2277,7 @@ def log_reloc(
rem: str,
) -> None:
nap, nvp, nfn, (nvn, nrem) = pm
- t = "reloc %s:\nold ap [%s]\nnew ap [%s\033[36m/%s\033[0m]\nold vp [%s]\nnew vp [%s\033[36m/%s\033[0m]\nold fn [%s]\nnew fn [%s]\nold vfs [%s]\nnew vfs [%s]\nold rem [%s]\nnew rem [%s]"
+ t = "reloc %s:\nold ap %r\nnew ap %r\033[36m/%r\033[0m\nold vp %r\nnew vp %r\033[36m/%r\033[0m\nold fn %r\nnew fn %r\nold vfs %r\nnew vfs %r\nold rem %r\nnew rem %r"
log(t % (re, ap, nap, nfn, vp, nvp, nfn, fn, nfn, vn.vpath, nvn.vpath, rem, nrem))
@@ -2448,7 +2448,7 @@ def lsof(log: "NamedLogger", abspath: str) -> None:
try:
rc, so, se = runcmd([b"lsof", b"-R", fsenc(abspath)], timeout=45)
zs = (so.strip() + "\n" + se.strip()).strip()
- log("lsof {} = {}\n{}".format(abspath, rc, zs), 3)
+ log("lsof %r = %s\n%s" % (abspath, rc, zs), 3)
except:
log("lsof failed; " + min_ex(), 3)
@@ -2484,17 +2484,17 @@ def _fs_mvrm(
for attempt in range(90210):
try:
if ino and os.stat(bsrc).st_ino != ino:
- t = "src inode changed; aborting %s %s"
+ t = "src inode changed; aborting %s %r"
log(t % (act, src), 1)
return False
if (dst and not atomic) and os.path.exists(bdst):
- t = "something appeared at dst; aborting rename [%s] ==> [%s]"
+ t = "something appeared at dst; aborting rename %r ==> %r"
log(t % (src, dst), 1)
return False
osfun(*args)
if attempt:
now = time.time()
- t = "%sd in %.2f sec, attempt %d: %s"
+ t = "%sd in %.2f sec, attempt %d: %r"
log(t % (act, now - t0, attempt + 1, src))
return True
except OSError as ex:
@@ -2506,7 +2506,7 @@ def _fs_mvrm(
if not attempt:
if not PY2:
ino = os.stat(bsrc).st_ino
- t = "%s failed (err.%d); retrying for %d sec: [%s]"
+ t = "%s failed (err.%d); retrying for %d sec: %r"
log(t % (act, ex.errno, maxtime + 0.99, src))
time.sleep(chill)
@@ -3535,7 +3535,7 @@ def runhook(
log, src, cmd, ap, vp, host, uname, perms, mt, sz, ip, at, txt
)
if log and args.hook_v:
- log("hook(%s) [%s] => \033[32m%s" % (src, cmd, hr), 6)
+ log("hook(%s) %r => \033[32m%s" % (src, cmd, hr), 6)
if not hr:
return {}
for k, v in hr.items():