Commit 3f440670 authored by Hugo Posnic's avatar Hugo Posnic

Better way to handle protocols

parent ed2e766f
......@@ -91,4 +91,4 @@ ENV/
.ropeproject
# Generated files
docs/*
docs/
......@@ -102,7 +102,7 @@
<tr>
<th>Mirror <span class="sort-arrow"></span></th>
<th>Country <span class="sort-arrow"></span></th>
<th>Protocol <span class="sort-arrow"></span></th>
<th>Protocol(s) <span class="sort-arrow"></span></th>
<th class="sorter-sync">Last sync (hh:mm)<span class="sort-arrow"></span></th>
<th class="sorter-branch">Stable <span class="sort-arrow"></span></th>
<th class="sorter-branch">Testing <span class="sort-arrow"></span></th>
......
......@@ -11,9 +11,22 @@ $(function () {
if(country) {
if(filters["country"] == "all")
country = "all";
var protocol = $("td:eq(2)", this).text();
if(protocol) {
condition = filters["country"] == country && filters[protocol];
var protocols = $("td:eq(2)", this).text();
if(protocols) {
condition = filters["country"] == country;
protocols = protocols.split(", ");
if(filters["http"] && protocols.includes("http")) {
condition = condition && true;
}
else if(filters["https"] && protocols.includes("https")) {
condition = condition && true;
}
else if(filters["ftp"] && protocols.includes("ftp")) {
condition = condition && true;
}
else {
condition = condition && false;
}
$(this).toggle(condition);
}
}
......
This diff is collapsed.
......@@ -60,7 +60,7 @@ class Builder():
html_output += "<tr class=\"table-{}\">".format(color)
html_output += "<td><a href=\"{url}\">{url}</a></td>".format(url=state["url"])
html_output += "<td>{}</td>".format(state["country"].replace("_", " "))
html_output += "<td>{}</td>".format(state["protocol"])
html_output += "<td>{}</td>".format(", ".join(state["protocols"]))
html_output += "<td>{}</td>".format(state["last_sync"])
icon = '<td><img src="../data/img/{}.png" data-toggle="tooltip" data-placement="top" alt="{desc}" title="{desc}"></td>'
for i, branch in enumerate(BRANCHES):
......
......@@ -3,6 +3,5 @@
VERSION = "1.0"
MIRRORS_URL = "http://repo.manjaro.org/new/manjaro-web-repo/mirrors.json"
BRANCHES = ("stable", "testing", "unstable")
PROTOCOLS = ("ftp", "https", "http")
ROOT_FOLDER = "/var/www/manjaro-web-repo/docroot/new/manjaro-web-repo/"
OUTPUT_FOLDER = "docs/"
......@@ -49,13 +49,14 @@ class StatusChecker():
for country in self.mirrors:
print("{}:".format(country))
for mirror in self.mirrors[country]:
mirror = Mirror(mirror, country)
protocols = self.mirrors[country][mirror]["protocols"]
mirror = Mirror(mirror, country, protocols)
print("\t{}".format(mirror.mirror))
if mirror.get_state_file():
mirror.read_state_file(self.hashes)
self.states.append({
"url": mirror.mirror,
"protocol": mirror.protocol,
"protocols": mirror.protocols,
"country": mirror.country,
"last_sync": mirror.last_sync,
"branches": mirror.branches
......@@ -65,7 +66,7 @@ class StatusChecker():
if __name__ == "__main__":
print("--------------------------------")
print("----Manjaro mirror's tracker----")
print("--------------------------------\n")
print("--------------------------------")
status_checker = StatusChecker()
status_checker.get_mirrors()
status_checker.get_hashes()
......
......@@ -3,19 +3,18 @@
import json
import urllib.request
import datetime
import urllib.parse
from conf import BRANCHES, PROTOCOLS
from conf import BRANCHES
class Mirror():
"""Handle all mirror's properties"""
def __init__(self, mirror, country):
def __init__(self, mirror, country, protocols):
self.state_file = None
self.mirror = mirror
self.country = country
self.protocol = str()
self.protocols = protocols
self.last_sync = str()
self.branches = list()
......@@ -42,8 +41,6 @@ class Mirror():
self.last_sync = "{}:{}".format(str(int(elapsed_hours)).zfill(2),
str(int(elapsed_minutes)).zfill(2))
protocol = urllib.parse.urlsplit(self.mirror)[0]
if protocol in PROTOCOLS:
self.protocol = protocol
for i, branch in enumerate(BRANCHES):
try:
with urllib.request.urlopen(self.mirror + branch + "/state") as response:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment