mirror of
https://github.com/9001/copyparty.git
synced 2025-08-17 09:02:15 -06:00
u2c: misc windows fixes
* support globbing/wildcards on windows * add `osc 9;4` to show upload progress in the taskbar (currently windows-only; linux is picking it up) * workaround msys2-terminal not normalizing absolute paths which contain whitespace * show a helpful "now hashing..." while the first file is being hashed, since it kinda looks like a deadlock on windows otherwise
This commit is contained in:
parent
d7aa7dfe64
commit
9163780000
52
bin/u2c.py
52
bin/u2c.py
|
@ -1,8 +1,8 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
from __future__ import print_function, unicode_literals
|
from __future__ import print_function, unicode_literals
|
||||||
|
|
||||||
S_VERSION = "2.6"
|
S_VERSION = "2.7"
|
||||||
S_BUILD_DT = "2024-11-10"
|
S_BUILD_DT = "2024-12-06"
|
||||||
|
|
||||||
"""
|
"""
|
||||||
u2c.py: upload to copyparty
|
u2c.py: upload to copyparty
|
||||||
|
@ -1033,8 +1033,8 @@ class Ctl(object):
|
||||||
handshake(self.ar, file, False)
|
handshake(self.ar, file, False)
|
||||||
|
|
||||||
def _fancy(self):
|
def _fancy(self):
|
||||||
|
atexit.register(self.cleanup_vt100)
|
||||||
if VT100 and not self.ar.ns:
|
if VT100 and not self.ar.ns:
|
||||||
atexit.register(self.cleanup_vt100)
|
|
||||||
ss.scroll_region(3)
|
ss.scroll_region(3)
|
||||||
|
|
||||||
Daemon(self.hasher)
|
Daemon(self.hasher)
|
||||||
|
@ -1042,6 +1042,7 @@ class Ctl(object):
|
||||||
Daemon(self.handshaker)
|
Daemon(self.handshaker)
|
||||||
Daemon(self.uploader)
|
Daemon(self.uploader)
|
||||||
|
|
||||||
|
last_sp = -1
|
||||||
while True:
|
while True:
|
||||||
with self.exit_cond:
|
with self.exit_cond:
|
||||||
self.exit_cond.wait(0.07)
|
self.exit_cond.wait(0.07)
|
||||||
|
@ -1080,6 +1081,12 @@ class Ctl(object):
|
||||||
else:
|
else:
|
||||||
txt = " "
|
txt = " "
|
||||||
|
|
||||||
|
if not VT100: # OSC9;4 (taskbar-progress)
|
||||||
|
sp = int(self.up_b * 100 / self.nbytes) or 1
|
||||||
|
if last_sp != sp:
|
||||||
|
last_sp = sp
|
||||||
|
txt += "\033]9;4;1;%d\033\\" % (sp,)
|
||||||
|
|
||||||
if not self.up_br:
|
if not self.up_br:
|
||||||
spd = self.hash_b / ((time.time() - self.t0) or 1)
|
spd = self.hash_b / ((time.time() - self.t0) or 1)
|
||||||
eta = (self.nbytes - self.hash_b) / (spd or 1)
|
eta = (self.nbytes - self.hash_b) / (spd or 1)
|
||||||
|
@ -1097,6 +1104,8 @@ class Ctl(object):
|
||||||
tail = "\033[K\033[u" if VT100 and not self.ar.ns else "\r"
|
tail = "\033[K\033[u" if VT100 and not self.ar.ns else "\r"
|
||||||
|
|
||||||
t = "%s eta @ %s/s, %s, %d# left\033[K" % (self.eta, spd, sleft, nleft)
|
t = "%s eta @ %s/s, %s, %d# left\033[K" % (self.eta, spd, sleft, nleft)
|
||||||
|
if not self.hash_b:
|
||||||
|
t = " now hashing..."
|
||||||
eprint(txt + "\033]0;{0}\033\\\r{0}{1}".format(t, tail))
|
eprint(txt + "\033]0;{0}\033\\\r{0}{1}".format(t, tail))
|
||||||
|
|
||||||
if self.ar.wlist:
|
if self.ar.wlist:
|
||||||
|
@ -1117,7 +1126,10 @@ class Ctl(object):
|
||||||
handshake(self.ar, file, False)
|
handshake(self.ar, file, False)
|
||||||
|
|
||||||
def cleanup_vt100(self):
|
def cleanup_vt100(self):
|
||||||
ss.scroll_region(None)
|
if VT100:
|
||||||
|
ss.scroll_region(None)
|
||||||
|
else:
|
||||||
|
eprint("\033]9;4;0\033\\")
|
||||||
eprint("\033[J\033]0;\033\\")
|
eprint("\033[J\033]0;\033\\")
|
||||||
|
|
||||||
def cb_hasher(self, file, ofs):
|
def cb_hasher(self, file, ofs):
|
||||||
|
@ -1538,6 +1550,38 @@ source file/folder selection uses rsync syntax, meaning that:
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
# msys2 doesn't uncygpath absolute paths with whitespace
|
||||||
|
if not VT100:
|
||||||
|
zsl = []
|
||||||
|
for fn in ar.files:
|
||||||
|
if re.search("^/[a-z]/", fn):
|
||||||
|
fn = r"%s:\%s" % (fn[1:2], fn[3:])
|
||||||
|
zsl.append(fn.replace("/", "\\"))
|
||||||
|
ar.files = zsl
|
||||||
|
|
||||||
|
fok = []
|
||||||
|
fng = []
|
||||||
|
for fn in ar.files:
|
||||||
|
if os.path.exists(fn):
|
||||||
|
fok.append(fn)
|
||||||
|
elif VT100:
|
||||||
|
fng.append(fn)
|
||||||
|
else:
|
||||||
|
# windows leaves glob-expansion to the invoked process... okayyy let's get to work
|
||||||
|
from glob import glob
|
||||||
|
|
||||||
|
fns = glob(fn)
|
||||||
|
if fns:
|
||||||
|
fok.extend(fns)
|
||||||
|
else:
|
||||||
|
fng.append(fn)
|
||||||
|
|
||||||
|
if fng:
|
||||||
|
t = "some files/folders were not found:\n %s"
|
||||||
|
raise Exception(t % ("\n ".join(fng),))
|
||||||
|
|
||||||
|
ar.files = fok
|
||||||
|
|
||||||
if ar.drd:
|
if ar.drd:
|
||||||
ar.dr = True
|
ar.dr = True
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue