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,7 +51,7 @@ 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")
|
||||
with open(config_path, "w") as config:
|
||||
# We double nginx's braces because they conflict with Python's f-strings.
|
||||
config.write(
|
||||
f"""
|
||||
|
@ -86,11 +86,11 @@ def generate_nginx_config():
|
|||
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