Compare commits

...

4 Commits

Author SHA1 Message Date
Keith Edmunds
61adc43b45 Add profiling to paste_rows and related functions 2024-11-01 15:18:47 +00:00
Keith Edmunds
3783996ba4 Handle file not found when scanning track 2024-11-01 11:47:38 +00:00
Keith Edmunds
2ce7f671ba Ensure new playlists are marked as open 2024-10-27 19:35:41 +00:00
Keith Edmunds
2fb1974598 Upgrade environment; remove snoop 2024-10-11 15:33:56 +01:00
7 changed files with 515 additions and 512 deletions

1
.envrc
View File

@ -1,4 +1,5 @@
layout poetry
export LINE_PROFILE=1
export MAIL_PASSWORD="ewacyay5seu2qske"
export MAIL_PORT=587
export MAIL_SERVER="smtp.fastmail.com"

View File

@ -132,7 +132,11 @@ def get_audio_metadata(filepath: str) -> Dict[str, str | int | float]:
metadata: Dict[str, str | int | float] = {}
metadata["mtime"] = os.path.getmtime(filepath)
try:
metadata["mtime"] = os.path.getmtime(filepath)
except FileNotFoundError:
show_warning(None, "File not found", f"Filepath {filepath} not found")
return {}
# Set start_gap, fade_at and silence_at
audio = get_audio_segment(filepath)
@ -200,7 +204,10 @@ def get_tags(path: str) -> Dict[str, Any]:
Return a dictionary of title, artist, duration-in-milliseconds and path.
"""
tag = TinyTag.get(path)
try:
tag = TinyTag.get(path)
except FileNotFoundError:
return {}
return dict(
title=tag.title,

View File

@ -8,6 +8,7 @@ import sys
# PyQt imports
# Third party imports
import line_profiler
from sqlalchemy import (
bindparam,
delete,
@ -563,6 +564,7 @@ class PlaylistRows(dbtables.PlaylistRowsTable):
)
@staticmethod
@line_profiler.profile
def update_plr_row_numbers(
session: Session, playlist_id: int, sqla_map: List[dict[str, int]]
) -> None:

View File

@ -44,6 +44,7 @@ from PyQt6.QtWidgets import (
)
# Third party imports
import line_profiler
import pipeclient
from pygame import mixer
from sqlalchemy.exc import IntegrityError
@ -534,6 +535,7 @@ class Window(QMainWindow, Ui_MainWindow):
if playlist:
playlist.mark_open()
session.commit()
return playlist
else:
log.error("Failed to create playlist")
@ -1019,11 +1021,11 @@ class Window(QMainWindow, Ui_MainWindow):
session, template, playlist_name
)
# Need to ensure that the new playlist is committed to
# the database before it is opened by the model.
session.commit()
if playlist:
playlist.mark_open()
# Need to ensure that the new playlist is committed to
# the database before it is opened by the model.
session.commit()
self.create_playlist_tab(playlist)
else:
log.error("Playlist failed to create")
@ -1067,7 +1069,8 @@ class Window(QMainWindow, Ui_MainWindow):
else:
webbrowser.get("browser").open_new_tab(url)
def paste_rows(self) -> None:
@line_profiler.profile
def paste_rows(self, dummy_for_profiling=None) -> None:
"""
Paste earlier cut rows.
"""

View File

@ -26,6 +26,7 @@ from PyQt6.QtGui import (
)
# Third party imports
import line_profiler
import obswebsocket # type: ignore
# import snoop # type: ignore
@ -736,7 +737,8 @@ class PlaylistModel(QAbstractTableModel):
self.update_track_times()
self.invalidate_rows(row_numbers)
def move_rows(self, from_rows: list[int], to_row_number: int) -> None:
@line_profiler.profile
def move_rows(self, from_rows: list[int], to_row_number: int, dummy_for_profiling=None) -> None:
"""
Move the playlist rows given to to_row and below.
"""
@ -986,7 +988,8 @@ class PlaylistModel(QAbstractTableModel):
# Update display
self.invalidate_row(track_sequence.previous.row_number)
def refresh_data(self, session: db.session) -> None:
@line_profiler.profile
def refresh_data(self, session: db.session, dummy_for_profiling=None) -> None:
"""Populate dicts for data calls"""
# Populate self.playlist_rows with playlist data

986
poetry.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -7,11 +7,11 @@ authors = ["Keith Edmunds <kae@midnighthax.com>"]
[tool.poetry.dependencies]
python = "^3.11"
tinytag = "^1.10.1"
SQLAlchemy = "^2.0.31"
python-vlc = "^3.0.20123"
SQLAlchemy = "^2.0.35"
python-vlc = "^3.0.21203"
mysqlclient = "^2.2.4"
mutagen = "^1.47.0"
alembic = "^1.13.2"
alembic = "^1.13.3"
pydub = "^0.25.1"
python-slugify = "^8.0.4"
pyfzf = "^0.3.1"
@ -22,7 +22,7 @@ pyqtgraph = "^0.13.3"
colorlog = "^6.8.2"
alchemical = "^1.0.2"
obs-websocket-py = "^1.0"
pygame = "^2.6.0"
pygame = "^2.6.1"
psutil = "^6.0.0"
pyqt6-webengine = "^6.7.0"
@ -39,7 +39,6 @@ flakehell = "^0.9.0"
mypy = "^1.7.0"
pytest-cov = "^5.0.0"
pytest = "^8.1.1"
snoop = "^0.4.3"
black = "^24.3.0"
types-psutil = "^6.0.0.20240621"
pdbp = "^1.5.3"