mirror of
https://github.com/9001/copyparty.git
synced 2025-08-17 09:02:15 -06:00
add server info banner thing
This commit is contained in:
parent
1c3aa0d2c5
commit
8a959f6ac4
4
.vscode/settings.json
vendored
4
.vscode/settings.json
vendored
|
@ -37,7 +37,7 @@
|
||||||
"python.linting.banditEnabled": true,
|
"python.linting.banditEnabled": true,
|
||||||
"python.linting.flake8Args": [
|
"python.linting.flake8Args": [
|
||||||
"--max-line-length=120",
|
"--max-line-length=120",
|
||||||
"--ignore=E722,F405,E203,W503,W293",
|
"--ignore=E722,F405,E203,W503,W293,E402",
|
||||||
],
|
],
|
||||||
"python.linting.banditArgs": [
|
"python.linting.banditArgs": [
|
||||||
"--ignore=B104"
|
"--ignore=B104"
|
||||||
|
@ -55,6 +55,6 @@
|
||||||
//
|
//
|
||||||
// things you may wanna edit:
|
// things you may wanna edit:
|
||||||
//
|
//
|
||||||
"python.pythonPath": ".venv/bin/python",
|
"python.pythonPath": "/usr/bin/python3",
|
||||||
//"python.linting.enabled": true,
|
//"python.linting.enabled": true,
|
||||||
}
|
}
|
|
@ -137,6 +137,8 @@ def main():
|
||||||
ap.add_argument("-q", action="store_true", help="quiet")
|
ap.add_argument("-q", action="store_true", help="quiet")
|
||||||
ap.add_argument("-ed", action="store_true", help="enable ?dots")
|
ap.add_argument("-ed", action="store_true", help="enable ?dots")
|
||||||
ap.add_argument("-nw", action="store_true", help="disable writes (benchmark)")
|
ap.add_argument("-nw", action="store_true", help="disable writes (benchmark)")
|
||||||
|
ap.add_argument("-nih", action="store_true", help="no info hostname")
|
||||||
|
ap.add_argument("-nid", action="store_true", help="no info disk-usage")
|
||||||
al = ap.parse_args()
|
al = ap.parse_args()
|
||||||
|
|
||||||
SvcHub(al).run()
|
SvcHub(al).run()
|
||||||
|
|
|
@ -6,6 +6,7 @@ import stat
|
||||||
import gzip
|
import gzip
|
||||||
import time
|
import time
|
||||||
import json
|
import json
|
||||||
|
import socket
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import calendar
|
import calendar
|
||||||
|
|
||||||
|
@ -1076,6 +1077,27 @@ class HttpCli(object):
|
||||||
|
|
||||||
break
|
break
|
||||||
|
|
||||||
|
srv_info = []
|
||||||
|
|
||||||
|
try:
|
||||||
|
if not self.args.nih:
|
||||||
|
srv_info.append(str(socket.gethostname()).split('.')[0])
|
||||||
|
except:
|
||||||
|
self.log("#wow #whoa")
|
||||||
|
pass
|
||||||
|
|
||||||
|
try:
|
||||||
|
# some fuses misbehave
|
||||||
|
if not self.args.nid:
|
||||||
|
sv = os.statvfs(abspath)
|
||||||
|
free = humansize(sv.f_frsize * sv.f_bfree, True)
|
||||||
|
total = humansize(sv.f_frsize * sv.f_blocks, True)
|
||||||
|
|
||||||
|
srv_info.append(free + " free")
|
||||||
|
srv_info.append(total)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
ts = ""
|
ts = ""
|
||||||
# ts = "?{}".format(time.time())
|
# ts = "?{}".format(time.time())
|
||||||
|
|
||||||
|
@ -1090,6 +1112,7 @@ class HttpCli(object):
|
||||||
prologue=logues[0],
|
prologue=logues[0],
|
||||||
epilogue=logues[1],
|
epilogue=logues[1],
|
||||||
title=html_escape(self.vpath, quote=False),
|
title=html_escape(self.vpath, quote=False),
|
||||||
|
srv_info='</span> /// <span>'.join(srv_info)
|
||||||
)
|
)
|
||||||
self.reply(html.encode("utf-8", "replace"))
|
self.reply(html.encode("utf-8", "replace"))
|
||||||
return True
|
return True
|
||||||
|
|
|
@ -334,6 +334,21 @@ def read_header(sr):
|
||||||
return ret[:ofs].decode("utf-8", "surrogateescape").split("\r\n")
|
return ret[:ofs].decode("utf-8", "surrogateescape").split("\r\n")
|
||||||
|
|
||||||
|
|
||||||
|
def humansize(sz, terse=False):
|
||||||
|
for unit in ['B', 'KiB', 'MiB', 'GiB', 'TiB']:
|
||||||
|
if sz < 1024:
|
||||||
|
break
|
||||||
|
|
||||||
|
sz /= 1024
|
||||||
|
|
||||||
|
ret = ' '.join([str(sz)[:4].rstrip('.'), unit])
|
||||||
|
|
||||||
|
if not terse:
|
||||||
|
return ret
|
||||||
|
|
||||||
|
return ret.replace('iB', '').replace(' ', '')
|
||||||
|
|
||||||
|
|
||||||
def undot(path):
|
def undot(path):
|
||||||
ret = []
|
ret = []
|
||||||
for node in path.split("/"):
|
for node in path.split("/"):
|
||||||
|
|
|
@ -131,6 +131,17 @@ a {
|
||||||
.logue {
|
.logue {
|
||||||
padding: .2em 1.5em;
|
padding: .2em 1.5em;
|
||||||
}
|
}
|
||||||
|
#srv_info {
|
||||||
|
opacity: .5;
|
||||||
|
font-size: .8em;
|
||||||
|
color: #fc5;
|
||||||
|
position: absolute;
|
||||||
|
top: .5em;
|
||||||
|
left: 2em;
|
||||||
|
}
|
||||||
|
#srv_info span {
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
a.play {
|
a.play {
|
||||||
color: #e70;
|
color: #e70;
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,6 +53,10 @@
|
||||||
|
|
||||||
<h2><a href="?h">control-panel</a></h2>
|
<h2><a href="?h">control-panel</a></h2>
|
||||||
|
|
||||||
|
{%- if srv_info %}
|
||||||
|
<div id="srv_info"><span>{{ srv_info }}</span></div>
|
||||||
|
{%- endif %}
|
||||||
|
|
||||||
<div id="widget">
|
<div id="widget">
|
||||||
<div id="wtoggle">♫</div>
|
<div id="wtoggle">♫</div>
|
||||||
<div id="widgeti">
|
<div id="widgeti">
|
||||||
|
|
Loading…
Reference in a new issue