Fixup replace_files for Alchemical

This commit is contained in:
Keith Edmunds 2024-04-27 20:25:22 +01:00
parent 134961abfd
commit 189efb379f
2 changed files with 15 additions and 10 deletions

View File

@ -4,20 +4,25 @@
# the current directory contains a "better" version of the file than the
# parent (eg, bettet bitrate).
# Standard library imports
import os
import pydymenu # type: ignore
import shutil
import sys
from typing import List
# PyQt imports
# Third party imports
import pydymenu # type: ignore
from sqlalchemy.exc import IntegrityError
from sqlalchemy.orm.session import Session
# App imports
from helpers import (
get_tags,
set_track_metadata,
)
from models import Tracks
from dbconfig import Session
from sqlalchemy.exc import IntegrityError
from typing import List
from models import db, Tracks
# ###################### SETTINGS #########################
process_name_and_tags_matches = True
@ -42,7 +47,7 @@ def main():
# We only want to run this against the production database because
# we will affect files in the common pool of tracks used by all
# databases
if "musicmuster_prod" not in os.environ.get("MM_DB"):
if "musicmuster_prod" not in os.environ.get("ALCHEMICAL_DATABASE_URI"):
response = input("Not on production database - c to continue: ")
if response != "c":
sys.exit(0)
@ -51,7 +56,7 @@ def main():
assert source_dir != parent_dir
# Scan parent directory
with Session() as session:
with db.Session() as session:
all_tracks = Tracks.get_all(session)
parent_tracks = [a for a in all_tracks if parent_dir in a.path]
parent_fnames = [os.path.basename(a.path) for a in parent_tracks]
@ -239,7 +244,7 @@ def process_track(src, dst, title, artist, bitrate):
if not do_processing:
return
with Session() as session:
with db.Session() as session:
track = Tracks.get_by_path(session, dst)
if track:
# Update path, but workaround MariaDB bug

View File

@ -59,7 +59,7 @@ explicit_package_bases = true
[tool.pytest.ini_options]
addopts = "--exitfirst --showlocals --capture=no"
pythonpath = [".", "app"]
filterwarnings = "ignore:'audioop' is deprecated"
filterwarnings = ["ignore:'audioop' is deprecated", "ignore:pkg_resources"]
[tool.vulture]
exclude = ["migrations", "app/ui", "archive"]