Compare commits

..

8 Commits

Author SHA1 Message Date
ed
e3f1d19756 v0.9.8 2021-03-15 01:13:46 +01:00
ed
93c2bd6ef6 fix tree trying to make surprise appearances 2021-03-13 02:29:13 +01:00
ed
4d0e5ff6db turns out whitespace compresses better than tabs 2021-03-13 00:16:07 +01:00
ed
0893f06919 browser: reload music player on column-sort
so tracks play in the right order
2021-03-13 00:15:53 +01:00
ed
46b6abde3f fuse-client: password from file 2021-03-13 00:14:22 +01:00
ed
0696610dee give up, just try both and see what sticks 2021-03-13 00:14:07 +01:00
ed
edf0d3684c sfx: improvements from r0c 2021-03-13 00:13:10 +01:00
ed
7af159f5f6 heh 2021-03-09 21:36:14 +01:00
9 changed files with 68 additions and 48 deletions

View File

@@ -212,6 +212,7 @@ pip install black bandit pylint flake8 # vscode tooling
in the `scripts` folder:
* run `make -C deps-docker` to build all dependencies
* `git tag v1.2.3 && git push origin --tags`
* create github release with `make-tgz-release.sh`
* upload to pypi with `make-pypi-release.(sh|bat)`
* create sfx with `make-sfx.sh`

View File

@@ -1008,6 +1008,12 @@ def main():
log = null_log
dbg = null_log
if ar.a and ar.a.startswith("$"):
fn = ar.a[1:]
log("reading password from file [{}]".format(fn))
with open(fn, "rb") as f:
ar.a = f.read().decode("utf-8").strip()
if WINDOWS:
os.system("rem")

View File

@@ -1,8 +1,8 @@
# coding: utf-8
VERSION = (0, 9, 7)
VERSION = (0, 9, 8)
CODENAME = "the strongest music server"
BUILD_DT = (2021, 3, 8)
BUILD_DT = (2021, 3, 15)
S_VERSION = ".".join(map(str, VERSION))
S_BUILD_DT = "{0:04d}-{1:02d}-{2:02d}".format(*BUILD_DT)

View File

@@ -837,7 +837,11 @@ def chkcmd(*argv):
def gzip_orig_sz(fn):
with open(fsenc(fn), "rb") as f:
f.seek(-4, 2)
return struct.unpack(b"I", f.read(4))[0]
rv = f.read(4)
try:
return struct.unpack(b"I", rv)[0]
except:
return struct.unpack("I", rv)[0]
def py_desc():
@@ -847,7 +851,11 @@ def py_desc():
if ofs > 0:
py_ver = py_ver[:ofs]
bitness = struct.calcsize(b"P") * 8
try:
bitness = struct.calcsize(b"P") * 8
except:
bitness = struct.calcsize("P") * 8
host_os = platform.system()
compiler = platform.python_compiler()

View File

@@ -6,7 +6,7 @@ function dbg(msg) {
ebi('path').innerHTML = msg;
}
makeSortable(ebi('files'));
makeSortable(ebi('files'), reload_mp);
// extract songs + add play column
@@ -739,9 +739,11 @@ var treectl = (function () {
var treesz = icfg_get('treesz', 16);
treesz = Math.min(Math.max(treesz, 4), 50);
console.log('treesz [' + treesz + ']');
var entreed = false;
function entree(e) {
ev(e);
entreed = true;
ebi('path').style.display = 'none';
var tree = ebi('tree');
@@ -749,22 +751,29 @@ var treectl = (function () {
swrite('entreed', 'tree');
get_tree("", get_evpath(), true);
window.addEventListener('scroll', onscroll);
window.addEventListener('resize', onresize);
onresize();
}
function detree(e) {
ev(e);
entreed = false;
ebi('tree').style.display = 'none';
ebi('path').style.display = 'inline-block';
ebi('wrap').style.marginLeft = '0';
swrite('entreed', 'na');
window.removeEventListener('resize', onresize);
window.removeEventListener('scroll', onscroll);
}
function onscroll() {
if (!entreed)
return;
var top = ebi('wrap').getBoundingClientRect().top;
ebi('tree').style.top = Math.max(0, parseInt(top)) + 'px';
}
window.addEventListener('scroll', onscroll);
function periodic() {
onscroll();
@@ -773,6 +782,9 @@ var treectl = (function () {
periodic();
function onresize(e) {
if (!entreed)
return;
var q = '#tree';
var nq = 0;
while (dyn) {
@@ -786,7 +798,6 @@ var treectl = (function () {
ebi('wrap').style.marginLeft = w + 'em';
onscroll();
}
window.addEventListener('resize', onresize);
function get_tree(top, dst, rst) {
var xhr = new XMLHttpRequest();
@@ -1349,9 +1360,19 @@ function ev_row_tgl(e) {
}
function reload_mp() {
if (mp && mp.au) {
mp.au.pause();
mp.au = null;
}
widget.close();
mp = init_mp();
}
function reload_browser(not_mp) {
filecols.set_style();
makeSortable(ebi('files'));
makeSortable(ebi('files'), reload_mp);
var parts = get_evpath().split('/');
var rm = document.querySelectorAll('#path>a+a+a');
@@ -1375,14 +1396,8 @@ function reload_browser(not_mp) {
oo[a].textContent = hsz;
}
if (!not_mp) {
if (mp && mp.au) {
mp.au.pause();
mp.au = null;
}
widget.close();
mp = init_mp();
}
if (!not_mp)
reload_mp();
if (window['up2k'])
up2k.set_fsearch();

View File

@@ -128,7 +128,7 @@ function sortTable(table, col) {
});
for (i = 0; i < tr.length; ++i) tb.appendChild(tr[vl[i][1]]);
}
function makeSortable(table) {
function makeSortable(table, cb) {
var th = table.tHead, i;
th && (th = th.rows[0]) && (th = th.cells);
if (th) i = th.length;
@@ -137,6 +137,8 @@ function makeSortable(table) {
th[i].onclick = function (e) {
ev(e);
sortTable(table, i);
if (cb)
cb();
};
}(i));
}

View File

@@ -20,6 +20,7 @@ set -e
# -rwxr-xr-x 0 ed ed 183808 Nov 19 00:43 copyparty-extras/sfx-lite/copyparty-sfx.py
command -v gnutar && tar() { gnutar "$@"; }
command -v gtar && tar() { gtar "$@"; }
command -v gsed && sed() { gsed "$@"; }
td="$(mktemp -d)"
@@ -29,11 +30,11 @@ pwd
dl_text() {
command -v curl && exec curl "$@"
command -v curl >/dev/null && exec curl "$@"
exec wget -O- "$@"
}
dl_files() {
command -v curl && exec curl -L --remote-name-all "$@"
command -v curl >/dev/null && exec curl -L --remote-name-all "$@"
exec wget "$@"
}
export -f dl_files

View File

@@ -180,7 +180,7 @@ tmv "$f"
# up2k goes from 28k to 22k laff
echo entabbening
find | grep -E '\.(js|css|html|py)$' | while IFS= read -r f; do
find | grep -E '\.(js|css|html)$' | while IFS= read -r f; do
unexpand -t 4 --first-only <"$f" >t
tmv "$f"
done

View File

@@ -1,9 +1,8 @@
#!/usr/bin/env python
# coding: utf-8
# coding: latin-1
from __future__ import print_function, unicode_literals
import os, sys, time, shutil, signal, tarfile, hashlib, platform, tempfile
import subprocess as sp
import os, sys, time, shutil, runpy, tarfile, hashlib, platform, tempfile, traceback
"""
run me with any version of python, i will unpack and run copyparty
@@ -344,20 +343,24 @@ def get_payload():
break
def confirm():
def confirm(rv):
msg()
msg(traceback.format_exc())
msg("*** hit enter to exit ***")
try:
raw_input() if PY2 else input()
except:
pass
sys.exit(rv)
def run(tmp, j2ver):
global cpp
msg("jinja2:", j2ver or "bundled")
msg("sfxdir:", tmp)
msg()
# "systemd-tmpfiles-clean.timer"?? HOW do you even come up with this shit
try:
@@ -373,30 +376,16 @@ def run(tmp, j2ver):
if j2ver:
del ld[-1]
cmd = (
"import sys, runpy; "
+ "".join(['sys.path.insert(0, r"' + x + '"); ' for x in ld])
+ 'runpy.run_module("copyparty", run_name="__main__")'
)
cmd = [sys.executable, "-c", cmd] + list(sys.argv[1:])
for x in ld:
sys.path.insert(0, x)
cmd = [str(x) for x in cmd]
msg("\n", cmd, "\n")
cpp = sp.Popen(cmd)
try:
cpp.wait()
runpy.run_module(str("copyparty"), run_name=str("__main__"))
except SystemExit as ex:
if ex.code:
confirm(ex.code)
except:
cpp.wait()
if cpp.returncode != 0:
confirm()
sys.exit(cpp.returncode)
def bye(sig, frame):
if cpp is not None:
cpp.terminate()
confirm(1)
def main():
@@ -430,8 +419,6 @@ def main():
# skip 0
signal.signal(signal.SIGTERM, bye)
tmp = unpack()
try:
@@ -439,7 +426,7 @@ def main():
except:
j2ver = None
return run(tmp, j2ver)
run(tmp, j2ver)
if __name__ == "__main__":