Skip to content

Commit

Permalink
Drop Whitenoise, Flask can serve static files by itself
Browse files Browse the repository at this point in the history
Signed-off-by: Aurélien Bompard <[email protected]>
  • Loading branch information
abompard committed Jun 5, 2024
1 parent a472850 commit f9245a4
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 23 deletions.
5 changes: 0 additions & 5 deletions mirrormanager2/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
from flask_admin import Admin
from flask_oidc import OpenIDConnect
from sqlalchemy.orm import configure_mappers
from whitenoise import WhiteNoise

from mirrormanager2 import __version__, local_auth
from mirrormanager2.admin import register_views as register_admin_views
Expand Down Expand Up @@ -133,8 +132,4 @@ def create_app(config=None):

XMLRPC.connect(app, "/xmlrpc")

# More static files
app.wsgi_app = WhiteNoise(app.wsgi_app)
app.wsgi_app.add_files(os.path.join(app.config["MM_LOG_DIR"], "crawler"), prefix="crawler/")

return app
2 changes: 1 addition & 1 deletion mirrormanager2/templates/fedora/host.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ <h2>Host {{ host.name }}
<p>
{% if host.private %}Last Checked In: {{ host.last_checked_in or '-' }} <br />{% endif %}
{% if not host.private %}Last Crawled: {% if host.last_crawled %} {{ host.last_crawled
}} <a href="{{url_for('base.index')}}crawler/{{host.id}}.log">[Log]</a> {% else %} - {% endif %} <br />
}} <a href="{{url_for('base.crawler_log', host_id=host.id)}}">[Log]</a> {% else %} - {% endif %} <br />
Last Crawl Duration: {{ host.last_crawl_duration }} seconds
{% if host.crawl_failures > 0 %}<br/>Number of consecutive crawl failures: {{ host.crawl_failures }} {% endif %}{% endif %}
</p>
Expand Down
7 changes: 7 additions & 0 deletions mirrormanager2/views.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import datetime
import os
import re

import flask
Expand Down Expand Up @@ -1255,3 +1256,9 @@ def propagation(repo_id):
return flask.render_template(
"propagation.html", repos=repos, repo=repo, labels=labels, datasets=datasets
)


@views.route("/crawler/<int:host_id>.log")
def crawler_log(self, host_id):
crawler_log_dir = os.path.join(flask.current_app.config["MM_LOG_DIR"], "crawler")
return flask.utils.send_from_directory(crawler_log_dir, f"{host_id}.log", max_age=None)
16 changes: 1 addition & 15 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ click = "^8.1.7"
geoip2 = "^4.7.0"
gunicorn = {version = "^21.2.0", optional = true}
psycopg2 = {version = "^2.9.9", optional = true}
whitenoise = "^6.6.0"
rich = "^13.7.0"
mrtparse = "^2.2.0"
requests = "^2.31.0"
Expand Down
1 change: 0 additions & 1 deletion utility/mirrormanager2.spec
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ BuildRequires: python%{python_pkgversion}-fedora-messaging
BuildRequires: python%{python_pkgversion}-sqlalchemy-helpers
BuildRequires: python%{python_pkgversion}-click
BuildRequires: python%{python_pkgversion}-geoip2
BuildRequires: python%{python_pkgversion}-whitenoise
BuildRequires: python%{python_pkgversion}-rich
BuildRequires: python%{python_pkgversion}-mrtparse
BuildRequires: python%{python_pkgversion}-requests
Expand Down

0 comments on commit f9245a4

Please sign in to comment.