From 8f3008432b3e8e960216143bebfebca6cfffd246 Mon Sep 17 00:00:00 2001 From: Jordan Date: Tue, 25 Jun 2019 23:26:20 -0700 Subject: display family count conditionally, clean family dir if it exists --- tor-metrics/generate.py | 2 ++ tor-metrics/templates/base.html | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/tor-metrics/generate.py b/tor-metrics/generate.py index fdb0a25..b6b2b3c 100755 --- a/tor-metrics/generate.py +++ b/tor-metrics/generate.py @@ -33,6 +33,8 @@ def unsorted(relays, filename, is_index): def effective_family(relays): template = env.get_template('effective_family.html') output_path = os.path.join(config.CONFIG['output_root'], 'family') + if os.path.exists(output_path): + rmtree(output_path) relay_list = relays.json['relays'] q_relays = [] # qualified relays w/ > 1 effective family member for relay in relay_list: diff --git a/tor-metrics/templates/base.html b/tor-metrics/templates/base.html index 697418f..a3f4560 100644 --- a/tor-metrics/templates/base.html +++ b/tor-metrics/templates/base.html @@ -37,9 +37,10 @@ {% set obs_bandwidth = '%s %s'|format((relay['observed_bandwidth'] / 1000)|round(2, 'common'), 'KB/s') %}{% endif %} {% if category != 'family' %} + {% if relay['effective_family']|length > 1 %} {{ relay['nickname'] }} ({{ relay['effective_family']|length }}) {% else %} - {{ relay['nickname'] }}{% endif %} + {{ relay['nickname'] }}{% endif %}{% endif %} {{ obs_bandwidth }} {{ relay['or_addresses'][0].split(':', 1)[0] }} -- cgit v1.2.3-54-g00ecf