Commit 9e1bb6ef authored by shadMod's avatar shadMod 💬

black reformat

parent 5231d5c2
Pipeline #283 passed with stage
in 0 seconds
...@@ -64,9 +64,13 @@ class Downloads: ...@@ -64,9 +64,13 @@ class Downloads:
else: else:
self._mirrors = {} self._mirrors = {}
for distro in self.config["mirrors"]["for"]: for distro in self.config["mirrors"]["for"]:
found_mirrors = list(sorted(launchpad.get_cdimage_mirrors( found_mirrors = list(
sorted(
launchpad.get_cdimage_mirrors(
distro, self.config["mirrors"]["country"] distro, self.config["mirrors"]["country"]
))) )
)
)
if found_mirrors: if found_mirrors:
self._mirrors[distro] = found_mirrors self._mirrors[distro] = found_mirrors
if not self._mirrors: if not self._mirrors:
...@@ -167,14 +171,18 @@ class Downloads: ...@@ -167,14 +171,18 @@ class Downloads:
# Store only if the cache isn't available # Store only if the cache isn't available
if self._cache is None: if self._cache is None:
with open(self._cache_file, "w") as f: with open(self._cache_file, "w") as f:
json.dump({ json.dump(
{
"config-hash": self._config_hash, "config-hash": self._config_hash,
"version": CACHE_FILE_VERSION, "version": CACHE_FILE_VERSION,
"content": { "content": {
"mirrors": self.mirrors, "mirrors": self.mirrors,
"md5sums": self.md5sums, "md5sums": self.md5sums,
}, },
}, f, separators=(",", ":")) },
f,
separators=(",", ":"),
)
# Invalidate the cache in this instance # Invalidate the cache in this instance
delattr(self, "_cache_cache") delattr(self, "_cache_cache")
...@@ -260,16 +268,19 @@ class Downloads: ...@@ -260,16 +268,19 @@ class Downloads:
torrent = "torrent" in flask.request.form torrent = "torrent" in flask.request.form
payload = signer.dumps({ payload = signer.dumps(
{
"url": self.url_for(distro, release, arch, torrent), "url": self.url_for(distro, release, arch, torrent),
"md5": self.md5sums["%s:%s:%s" % (distro, release, arch)], "md5": self.md5sums["%s:%s:%s" % (distro, release, arch)],
"name": "%s %s%s" % ( "name": "%s %s%s"
% (
self.config["distros"][distro]["name"], self.config["distros"][distro]["name"],
self.config["releases"][release]["version"], self.config["releases"][release]["version"],
" LTS" if self.config["releases"][release]["lts"] else "", " LTS" if self.config["releases"][release]["lts"] else "",
), ),
"theme": distro, "theme": distro,
}) }
)
return flask.redirect(flask.url_for(".thanks", payload=payload)) return flask.redirect(flask.url_for(".thanks", payload=payload))
@bp.route("/grazie/<payload>") @bp.route("/grazie/<payload>")
...@@ -287,10 +298,11 @@ class Downloads: ...@@ -287,10 +298,11 @@ class Downloads:
"""Generate the sub-navbar for /download""" """Generate the sub-navbar for /download"""
result = [] result = []
for name, distro in self.config["distros"].items(): for name, distro in self.config["distros"].items():
result.append({ result.append(
{
"name": distro["name"], "name": distro["name"],
"endpoint": "download.landing", "endpoint": "download.landing",
"endpoint-args": {"distro": name}, "endpoint-args": {"distro": name},
}) }
)
return result return result
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