From ddce8f239167048318593af9aa281ef24fd4343d Mon Sep 17 00:00:00 2001 From: Keith Edmunds Date: Sat, 27 Mar 2021 16:27:48 +0000 Subject: [PATCH] Remove pytiger; select next track at end --- app/config.py | 3 ++- app/log.py | 2 +- app/model.py | 14 +++----------- app/musicmuster.py | 12 +++++++++++- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/app/config.py b/app/config.py index 070b7c3..fc494f9 100644 --- a/app/config.py +++ b/app/config.py @@ -8,8 +8,9 @@ class Config(object): DBFS_SILENCE = -50 DISPLAY_SQL = False ERRORS_TO = ['kae@midnighthax.com'] - LOG_LEVEL_STDERR = logging.INFO + LOG_LEVEL_STDERR = logging.DEBUG LOG_LEVEL_SYSLOG = logging.DEBUG + LOG_NAME = "musicmuster" MAIL_PASSWORD = os.environ.get('MAIL_PASSWORD') MAIL_PORT = int(os.environ.get('MAIL_PORT') or 25) MAIL_SERVER = os.environ.get('MAIL_SERVER') or "woodlands.midnighthax.com" diff --git a/app/log.py b/app/log.py index 72494e8..a5527f0 100755 --- a/app/log.py +++ b/app/log.py @@ -18,7 +18,7 @@ class LevelTagFilter(logging.Filter): return True -log = logging.getLogger("musicmuster") +log = logging.getLogger(Config.LOG_NAME) log.setLevel(logging.DEBUG) # stderr diff --git a/app/model.py b/app/model.py index b18b2ce..8f30dd2 100644 --- a/app/model.py +++ b/app/model.py @@ -1,11 +1,8 @@ #!/usr/bin/python3 -import logging import os import sqlalchemy -import pytiger.logging.config - from sqlalchemy.ext.declarative import declarative_base from sqlalchemy import Column, Float, DateTime, Integer, String from sqlalchemy.orm.exc import NoResultFound @@ -13,20 +10,15 @@ from sqlalchemy.orm import sessionmaker from config import Config -from log import ERROR, DEBUG -# from log import INFO, ERROR, DEBUG +from log import DEBUG, ERROR, INFO -# "Constants" -# Instantiate logging -pytiger.logging.config.basic_config(stderr=False, level=logging.INFO) -log = logging.getLogger(__name__) -log.info("Starting") +INFO("Starting") # Create session at the global level as per # https://docs.sqlalchemy.org/en/13/orm/session_basics.html # Set up database connection -log.info("Connect to database") +INFO("Connect to database") engine = sqlalchemy.create_engine(f"{Config.MYSQL_CONNECT}?charset=utf8", encoding='utf-8', echo=Config.DISPLAY_SQL) diff --git a/app/musicmuster.py b/app/musicmuster.py index 130afc4..93759da 100755 --- a/app/musicmuster.py +++ b/app/musicmuster.py @@ -284,6 +284,17 @@ class Window(QMainWindow, Ui_MainWindow): ms_to_mmss(self.music.get_current_silence_at() - playtime)) self.label_end_timer.setText( ms_to_mmss(self.music.get_current_duration() - playtime)) + else: + # When music ends, ensure next track is selected + if self.playlist.selectionModel().hasSelection(): + row = self.playlist.currentRow() + track_id = int(self.playlist.item(row, 0).text()) + if track_id == self.music.get_current_track_id(): + # Current track highlighted: select next + try: + self.playlist.selectRow(row + 1) + except AttributeError: + pass def add_to_playlist(self, track): """ @@ -318,7 +329,6 @@ class Window(QMainWindow, Ui_MainWindow): self.actionPlay_next.setEnabled(True) - class DbDialog(QDialog): def __init__(self, parent=None): super().__init__(parent)