add mtp queue to status page

This commit is contained in:
ed 2021-06-12 02:23:48 +02:00
parent ca27f8587c
commit d53c212516
4 changed files with 24 additions and 2 deletions

View file

@ -1379,7 +1379,7 @@ class HttpCli(object):
vstate = {("/" + k).rstrip("/") + "/": v for k, v in vs["volstate"].items()} vstate = {("/" + k).rstrip("/") + "/": v for k, v in vs["volstate"].items()}
else: else:
vstate = {} vstate = {}
vs = {"scanning": None, "hashq": None, "tagq": None} vs = {"scanning": None, "hashq": None, "tagq": None, "mtpq": None}
html = self.j2( html = self.j2(
"splash", "splash",
@ -1391,6 +1391,7 @@ class HttpCli(object):
scanning=vs["scanning"], scanning=vs["scanning"],
hashq=vs["hashq"], hashq=vs["hashq"],
tagq=vs["tagq"], tagq=vs["tagq"],
mtpq=vs["mtpq"],
url_suf=suf, url_suf=suf,
) )
self.reply(html.encode("utf-8"), headers=NO_STORE) self.reply(html.encode("utf-8"), headers=NO_STORE)

View file

@ -132,11 +132,25 @@ class Up2k(object):
self.log_func("up2k", msg + "\033[K", c) self.log_func("up2k", msg + "\033[K", c)
def get_state(self): def get_state(self):
mtpq = 0
q = "select count(w) from mt where k = 't:mtp'"
got_lock = self.mutex.acquire(timeout=0.5)
if got_lock:
for cur in self.cur.values():
try:
mtpq += cur.execute(q).fetchone()[0]
except:
pass
self.mutex.release()
else:
mtpq = "?"
ret = { ret = {
"volstate": self.volstate, "volstate": self.volstate,
"scanning": hasattr(self, "pp"), "scanning": hasattr(self, "pp"),
"hashq": self.n_hashq, "hashq": self.n_hashq,
"tagq": self.n_tagq, "tagq": self.n_tagq,
"mtpq": mtpq,
} }
return json.dumps(ret, indent=4) return json.dumps(ret, indent=4)

View file

@ -34,6 +34,9 @@ table {
padding: .3em .6em; padding: .3em .6em;
text-align: left; text-align: left;
} }
.num {
border-right: 1px solid #bbb;
}
.num td { .num td {
padding: .1em .7em .1em 0; padding: .1em .7em .1em 0;
} }
@ -67,4 +70,7 @@ html.dark input {
border-radius: .5em; border-radius: .5em;
padding: .5em .7em; padding: .5em .7em;
margin: 0 .5em 0 0; margin: 0 .5em 0 0;
}
html.dark .num {
border-color: #777;
} }

View file

@ -20,7 +20,8 @@
<tr><td>scanning</td><td>{{ scanning }}</td></tr> <tr><td>scanning</td><td>{{ scanning }}</td></tr>
<tr><td>hash-q</td><td>{{ hashq }}</td></tr> <tr><td>hash-q</td><td>{{ hashq }}</td></tr>
<tr><td>tag-q</td><td>{{ tagq }}</td></tr> <tr><td>tag-q</td><td>{{ tagq }}</td></tr>
</table> <tr><td>mtp-q</td><td>{{ mtpq }}</td></tr>
</table>
</td><td> </td><td>
<table class="vols"> <table class="vols">
<thead><tr><th>vol</th><th>action</th><th>status</th></tr></thead> <thead><tr><th>vol</th><th>action</th><th>status</th></tr></thead>