show tracker status
This commit is contained in:
parent
e279cfe6c3
commit
b3ed93c669
|
@ -88,7 +88,7 @@ class ClientCache(object):
|
|||
self.data.torrents[cid] = client.rpc.core.get_torrents_status({"label": self.options["label"]},
|
||||
['name', 'label', 'save_path', 'is_seed',
|
||||
'is_finished', 'progress', 'files',
|
||||
'paused', 'peers', 'eta'])
|
||||
'paused', 'peers', 'eta', 'tracker_status'])
|
||||
newkeys = self.data.torrents[cid].keys()
|
||||
for key in list(self.data.moves[cid].keys()):
|
||||
if key not in newkeys:
|
||||
|
@ -324,6 +324,26 @@ def tsortbyname(dict_items):
|
|||
return sorted(dict_items, key=lambda x: x[1]["name"].lower())
|
||||
|
||||
|
||||
def bytes_size(size, decimals=1, format="{} {}/s"):
|
||||
# https://stackoverflow.com/a/49361727
|
||||
power = 2**10
|
||||
n = 0
|
||||
power_labels = {0: 'B', 1: 'KB', 2: 'MB', 3: 'GB', 4: 'TB'}
|
||||
while size > power:
|
||||
size /= power
|
||||
n += 1
|
||||
return format.format(round(size, decimals), power_labels[n])
|
||||
|
||||
|
||||
def time_format(seconds):
|
||||
if seconds < 60:
|
||||
return "{}s".format(seconds)
|
||||
elif seconds < 60 * 60:
|
||||
return "{}m".format(seconds // 60)
|
||||
else:
|
||||
return "{}h".format(seconds // (60 * 60))
|
||||
|
||||
|
||||
def main():
|
||||
logging.basicConfig(level=logging.WARNING,
|
||||
format="%(asctime)-15s %(levelname)-8s %(filename)s:%(lineno)d %(message)s")
|
||||
|
@ -367,7 +387,9 @@ def main():
|
|||
autoescape=select_autoescape(['html', 'xml']))
|
||||
tpl.filters.update(tsortbyname=tsortbyname,
|
||||
len=len,
|
||||
jsond=json.dumps)
|
||||
jsond=json.dumps,
|
||||
bsize=bytes_size,
|
||||
time_format=time_format,)
|
||||
|
||||
def validate_password(realm, user, passw):
|
||||
return user == passw # lol
|
||||
|
|
|
@ -71,8 +71,11 @@
|
|||
<td>{{ tkey[0:8] }}</td>
|
||||
<td>{{ tor.name }}</td>
|
||||
<td>{{ tor.save_path }}</td>
|
||||
<td>{% if tor.paused %}paused
|
||||
{% else %}downloading @ {{ tor.peers | sum(attribute='down_speed') }} B/s ({{ tor.eta or "?" }}s)
|
||||
<td>
|
||||
{{ tor.tracker_status }}
|
||||
<br />
|
||||
{% if tor.paused %}paused
|
||||
{% else %}downloading @ {{ tor.peers | sum(attribute='down_speed') | bsize }}{% if tor.eta %} (eta {{ tor.eta|time_format }}){% endif %}
|
||||
{% endif %}</td>
|
||||
<td>{{ tor.progress|round(2) }}%</td>
|
||||
<td>
|
||||
|
|
Loading…
Reference in New Issue