mirror of
https://github.com/maxdorninger/MediaManager.git
synced 2026-04-17 15:13:24 +02:00
refactor: reformat code
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import sys
|
||||
|
||||
sys.path = ['', '..'] + sys.path[1:]
|
||||
sys.path = ["", ".."] + sys.path[1:]
|
||||
|
||||
|
||||
from logging.config import fileConfig
|
||||
@@ -38,13 +38,22 @@ from media_manager.torrent.models import Torrent
|
||||
from media_manager.tv.models import Show, Season, Episode, SeasonFile, SeasonRequest
|
||||
|
||||
from media_manager.database import Base
|
||||
|
||||
target_metadata = Base.metadata
|
||||
|
||||
# this is to keep pycharm from complaining about/optimizing unused imports
|
||||
# noinspection PyStatementEffect
|
||||
User, OAuthAccount, IndexerQueryResult, Torrent, Show, Season, Episode, SeasonFile, SeasonRequest
|
||||
|
||||
|
||||
(
|
||||
User,
|
||||
OAuthAccount,
|
||||
IndexerQueryResult,
|
||||
Torrent,
|
||||
Show,
|
||||
Season,
|
||||
Episode,
|
||||
SeasonFile,
|
||||
SeasonRequest,
|
||||
)
|
||||
|
||||
|
||||
# other values from the config, defined by the needs of env.py,
|
||||
@@ -52,8 +61,9 @@ User, OAuthAccount, IndexerQueryResult, Torrent, Show, Season, Episode, SeasonFi
|
||||
# my_important_option = config.get_main_option("my_important_option")
|
||||
# ... etc.
|
||||
|
||||
|
||||
class DbConfig(BaseSettings):
|
||||
model_config = SettingsConfigDict(env_prefix='DB_')
|
||||
model_config = SettingsConfigDict(env_prefix="DB_")
|
||||
HOST: str = "localhost"
|
||||
PORT: int = 5432
|
||||
USER: str = "MediaManager"
|
||||
@@ -62,8 +72,19 @@ class DbConfig(BaseSettings):
|
||||
|
||||
|
||||
db_config = DbConfig()
|
||||
db_url = "postgresql+psycopg" + "://" + db_config.USER + ":" + db_config.PASSWORD + "@" + db_config.HOST + ":" + str(
|
||||
db_config.PORT) + "/" + db_config.DBNAME
|
||||
db_url = (
|
||||
"postgresql+psycopg"
|
||||
+ "://"
|
||||
+ db_config.USER
|
||||
+ ":"
|
||||
+ db_config.PASSWORD
|
||||
+ "@"
|
||||
+ db_config.HOST
|
||||
+ ":"
|
||||
+ str(db_config.PORT)
|
||||
+ "/"
|
||||
+ db_config.DBNAME
|
||||
)
|
||||
|
||||
config.set_main_option("sqlalchemy.url", db_url)
|
||||
|
||||
@@ -106,9 +127,7 @@ def run_migrations_online() -> None:
|
||||
)
|
||||
|
||||
with connectable.connect() as connection:
|
||||
context.configure(
|
||||
connection=connection, target_metadata=target_metadata
|
||||
)
|
||||
context.configure(connection=connection, target_metadata=target_metadata)
|
||||
|
||||
with context.begin_transaction():
|
||||
context.run_migrations()
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
"""Initial migration
|
||||
|
||||
Revision ID: 93fb07842385
|
||||
Revises:
|
||||
Revises:
|
||||
Create Date: 2025-05-27 21:36:18.532068
|
||||
|
||||
"""
|
||||
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = '93fb07842385'
|
||||
revision: str = "93fb07842385"
|
||||
down_revision: Union[str, None] = None
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
@@ -20,13 +21,21 @@ depends_on: Union[str, Sequence[str], None] = None
|
||||
def upgrade() -> None:
|
||||
"""Upgrade schema."""
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column('season', 'size')
|
||||
op.drop_column("season", "size")
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Downgrade schema."""
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('season',
|
||||
sa.Column('size', sa.INTEGER(), server_default=sa.text('0'), autoincrement=False, nullable=False))
|
||||
op.add_column(
|
||||
"season",
|
||||
sa.Column(
|
||||
"size",
|
||||
sa.INTEGER(),
|
||||
server_default=sa.text("0"),
|
||||
autoincrement=False,
|
||||
nullable=False,
|
||||
),
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
@@ -48,6 +48,7 @@ log = logging.getLogger(__name__)
|
||||
from media_manager.database import init_db
|
||||
import media_manager.tv.router as tv_router
|
||||
import media_manager.torrent.router as torrent_router
|
||||
|
||||
init_db()
|
||||
log.info("Database initialized")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user