mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
housekeep: reformat files with pre-hooks
Signed-off-by: Leonidas Spyropoulos <artafinde@archlinux.org>
This commit is contained in:
parent
4d5909256f
commit
a54b6935a1
4 changed files with 55 additions and 54 deletions
|
@ -1,7 +1,7 @@
|
|||
import pickle
|
||||
from typing import Any, Callable
|
||||
|
||||
from sqlalchemy import orm
|
||||
from typing import Callable, Any
|
||||
|
||||
from aurweb import config
|
||||
from aurweb.aur_redis import redis_connection
|
||||
|
|
|
@ -81,7 +81,9 @@ async def rss_modified(request: Request):
|
|||
|
||||
# we use redis for caching the results of the feedgen
|
||||
cache_expire = config.getint("cache", "expiry_time_rss", 300)
|
||||
feed = lambda_cache("rss_modified", lambda: make_rss_feed(request, packages), cache_expire)
|
||||
feed = lambda_cache(
|
||||
"rss_modified", lambda: make_rss_feed(request, packages), cache_expire
|
||||
)
|
||||
|
||||
response = Response(feed, media_type="application/rss+xml")
|
||||
return response
|
||||
|
|
|
@ -51,46 +51,46 @@ def generate_nginx_config():
|
|||
fastapi_bind = aurweb.config.get("fastapi", "bind_address")
|
||||
fastapi_host = fastapi_bind.split(":")[0]
|
||||
config_path = os.path.join(temporary_dir, "nginx.conf")
|
||||
config = open(config_path, "w")
|
||||
# We double nginx's braces because they conflict with Python's f-strings.
|
||||
config.write(
|
||||
f"""
|
||||
events {{}}
|
||||
daemon off;
|
||||
error_log /dev/stderr info;
|
||||
pid {os.path.join(temporary_dir, "nginx.pid")};
|
||||
http {{
|
||||
access_log /dev/stdout;
|
||||
client_body_temp_path {os.path.join(temporary_dir, "client_body")};
|
||||
proxy_temp_path {os.path.join(temporary_dir, "proxy")};
|
||||
fastcgi_temp_path {os.path.join(temporary_dir, "fastcgi")}1 2;
|
||||
uwsgi_temp_path {os.path.join(temporary_dir, "uwsgi")};
|
||||
scgi_temp_path {os.path.join(temporary_dir, "scgi")};
|
||||
server {{
|
||||
listen {fastapi_host}:{FASTAPI_NGINX_PORT};
|
||||
location / {{
|
||||
try_files $uri @proxy_to_app;
|
||||
}}
|
||||
location @proxy_to_app {{
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_redirect off;
|
||||
proxy_buffering off;
|
||||
proxy_pass http://{fastapi_bind};
|
||||
with open(config_path, "w") as config:
|
||||
# We double nginx's braces because they conflict with Python's f-strings.
|
||||
config.write(
|
||||
f"""
|
||||
events {{}}
|
||||
daemon off;
|
||||
error_log /dev/stderr info;
|
||||
pid {os.path.join(temporary_dir, "nginx.pid")};
|
||||
http {{
|
||||
access_log /dev/stdout;
|
||||
client_body_temp_path {os.path.join(temporary_dir, "client_body")};
|
||||
proxy_temp_path {os.path.join(temporary_dir, "proxy")};
|
||||
fastcgi_temp_path {os.path.join(temporary_dir, "fastcgi")}1 2;
|
||||
uwsgi_temp_path {os.path.join(temporary_dir, "uwsgi")};
|
||||
scgi_temp_path {os.path.join(temporary_dir, "scgi")};
|
||||
server {{
|
||||
listen {fastapi_host}:{FASTAPI_NGINX_PORT};
|
||||
location / {{
|
||||
try_files $uri @proxy_to_app;
|
||||
}}
|
||||
location @proxy_to_app {{
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_redirect off;
|
||||
proxy_buffering off;
|
||||
proxy_pass http://{fastapi_bind};
|
||||
}}
|
||||
}}
|
||||
}}
|
||||
}}
|
||||
"""
|
||||
)
|
||||
"""
|
||||
)
|
||||
return config_path
|
||||
|
||||
|
||||
def spawn_child(args):
|
||||
def spawn_child(_args):
|
||||
"""Open a subprocess and add it to the global state."""
|
||||
if verbosity >= 1:
|
||||
print(f":: Spawning {args}", file=sys.stderr)
|
||||
children.append(subprocess.Popen(args))
|
||||
print(f":: Spawning {_args}", file=sys.stderr)
|
||||
children.append(subprocess.Popen(_args))
|
||||
|
||||
|
||||
def start():
|
||||
|
@ -171,17 +171,17 @@ def start():
|
|||
)
|
||||
|
||||
|
||||
def _kill_children(
|
||||
children: Iterable, exceptions: list[Exception] = []
|
||||
) -> list[Exception]:
|
||||
def _kill_children(_children: Iterable, exceptions=None) -> list[Exception]:
|
||||
"""
|
||||
Kill each process found in `children`.
|
||||
|
||||
:param children: Iterable of child processes
|
||||
:param _children: Iterable of child processes
|
||||
:param exceptions: Exception memo
|
||||
:return: `exceptions`
|
||||
"""
|
||||
for p in children:
|
||||
if exceptions is None:
|
||||
exceptions = []
|
||||
for p in _children:
|
||||
try:
|
||||
p.terminate()
|
||||
if verbosity >= 1:
|
||||
|
@ -191,17 +191,17 @@ def _kill_children(
|
|||
return exceptions
|
||||
|
||||
|
||||
def _wait_for_children(
|
||||
children: Iterable, exceptions: list[Exception] = []
|
||||
) -> list[Exception]:
|
||||
def _wait_for_children(_children: Iterable, exceptions=None) -> list[Exception]:
|
||||
"""
|
||||
Wait for each process to end found in `children`.
|
||||
|
||||
:param children: Iterable of child processes
|
||||
:param _children: Iterable of child processes
|
||||
:param exceptions: Exception memo
|
||||
:return: `exceptions`
|
||||
"""
|
||||
for p in children:
|
||||
if exceptions is None:
|
||||
exceptions = []
|
||||
for p in _children:
|
||||
try:
|
||||
rc = p.wait()
|
||||
if rc != 0 and rc != -15:
|
||||
|
|
|
@ -1,30 +1,29 @@
|
|||
"""add indicies on PackageBases for RSS order by
|
||||
"""add indices on PackageBases for RSS order by
|
||||
|
||||
Revision ID: 38e5b9982eea
|
||||
Revises: 7d65d35fae45
|
||||
Create Date: 2024-08-03 01:35:39.104283
|
||||
|
||||
"""
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import mysql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '38e5b9982eea'
|
||||
down_revision = '7d65d35fae45'
|
||||
revision = "38e5b9982eea"
|
||||
down_revision = "7d65d35fae45"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_index('BasesModifiedTS', 'PackageBases', ['ModifiedTS'], unique=False)
|
||||
op.create_index('BasesSubmittedTS', 'PackageBases', ['SubmittedTS'], unique=False)
|
||||
op.create_index("BasesModifiedTS", "PackageBases", ["ModifiedTS"], unique=False)
|
||||
op.create_index("BasesSubmittedTS", "PackageBases", ["SubmittedTS"], unique=False)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_index('BasesSubmittedTS', table_name='PackageBases')
|
||||
op.drop_index('BasesModifiedTS', table_name='PackageBases')
|
||||
op.drop_index("BasesSubmittedTS", table_name="PackageBases")
|
||||
op.drop_index("BasesModifiedTS", table_name="PackageBases")
|
||||
# ### end Alembic commands ###
|
||||
|
|
Loading…
Add table
Reference in a new issue