Compare commits
2 Commits
e1b9dacd34
...
e498457395
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e498457395 | ||
|
|
dbf0c27a09 |
@ -20,7 +20,7 @@ class Config(object):
|
|||||||
ERRORS_TO = ['kae@midnighthax.com']
|
ERRORS_TO = ['kae@midnighthax.com']
|
||||||
FADE_STEPS = 20
|
FADE_STEPS = 20
|
||||||
FADE_TIME = 3000
|
FADE_TIME = 3000
|
||||||
LOG_LEVEL_STDERR = logging.DEBUG
|
LOG_LEVEL_STDERR = logging.INFO
|
||||||
LOG_LEVEL_SYSLOG = logging.DEBUG
|
LOG_LEVEL_SYSLOG = logging.DEBUG
|
||||||
LOG_NAME = "musicmuster"
|
LOG_NAME = "musicmuster"
|
||||||
MAIL_PASSWORD = os.environ.get('MAIL_PASSWORD')
|
MAIL_PASSWORD = os.environ.get('MAIL_PASSWORD')
|
||||||
|
|||||||
16
app/log.py
16
app/log.py
@ -59,8 +59,20 @@ def log_uncaught_exceptions(ex_cls, ex, tb):
|
|||||||
sys.excepthook = log_uncaught_exceptions
|
sys.excepthook = log_uncaught_exceptions
|
||||||
|
|
||||||
|
|
||||||
def DEBUG(msg):
|
def DEBUG(msg, force_stderr=False):
|
||||||
log.debug(msg)
|
"""
|
||||||
|
Outupt a log message at level DEBUG. If force_stderr is True,
|
||||||
|
output this message to stderr regardless of default stderr level
|
||||||
|
setting.
|
||||||
|
"""
|
||||||
|
|
||||||
|
if force_stderr:
|
||||||
|
old_level = stderr.level
|
||||||
|
stderr.setLevel(logging.DEBUG)
|
||||||
|
log.debug(msg)
|
||||||
|
stderr.setLevel(old_level)
|
||||||
|
else:
|
||||||
|
log.debug(msg)
|
||||||
|
|
||||||
|
|
||||||
def EXCEPTION(msg):
|
def EXCEPTION(msg):
|
||||||
|
|||||||
@ -402,8 +402,9 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def search_database(self):
|
def search_database(self):
|
||||||
dlg = DbDialog(self)
|
with Session() as session:
|
||||||
dlg.exec()
|
dlg = DbDialog(self, session)
|
||||||
|
dlg.exec()
|
||||||
|
|
||||||
def open_playlist(self):
|
def open_playlist(self):
|
||||||
with Session() as session:
|
with Session() as session:
|
||||||
@ -626,8 +627,9 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
|
|
||||||
|
|
||||||
class DbDialog(QDialog):
|
class DbDialog(QDialog):
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent, session):
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
|
self.session = session
|
||||||
self.ui = Ui_Dialog()
|
self.ui = Ui_Dialog()
|
||||||
self.ui.setupUi(self)
|
self.ui.setupUi(self)
|
||||||
self.ui.searchString.textEdited.connect(self.chars_typed)
|
self.ui.searchString.textEdited.connect(self.chars_typed)
|
||||||
@ -637,22 +639,20 @@ class DbDialog(QDialog):
|
|||||||
self.ui.btnClose.clicked.connect(self.close)
|
self.ui.btnClose.clicked.connect(self.close)
|
||||||
self.ui.matchList.itemSelectionChanged.connect(self.selection_changed)
|
self.ui.matchList.itemSelectionChanged.connect(self.selection_changed)
|
||||||
|
|
||||||
with Session() as session:
|
record = Settings.get_int(self.session, "dbdialog_width")
|
||||||
record = Settings.get_int(session, "dbdialog_width")
|
width = record.f_int or 800
|
||||||
width = record.f_int or 800
|
record = Settings.get_int(self.session, "dbdialog_height")
|
||||||
record = Settings.get_int(session, "dbdialog_height")
|
height = record.f_int or 600
|
||||||
height = record.f_int or 600
|
self.resize(width, height)
|
||||||
self.resize(width, height)
|
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
with Session() as session:
|
record = Settings.get_int(self.session, "dbdialog_height")
|
||||||
record = Settings.get_int(session, "dbdialog_height")
|
if record.f_int != self.height():
|
||||||
if record.f_int != self.height():
|
record.update(self.session, {'f_int': self.height()})
|
||||||
record.update(session, {'f_int': self.height()})
|
|
||||||
|
|
||||||
record = Settings.get_int(session, "dbdialog_width")
|
record = Settings.get_int(self.session, "dbdialog_width")
|
||||||
if record.f_int != self.width():
|
if record.f_int != self.width():
|
||||||
record.update(session, {'f_int': self.width()})
|
record.update(self.session, {'f_int': self.width()})
|
||||||
|
|
||||||
def add_selected(self):
|
def add_selected(self):
|
||||||
if not self.ui.matchList.selectedItems():
|
if not self.ui.matchList.selectedItems():
|
||||||
@ -660,8 +660,7 @@ class DbDialog(QDialog):
|
|||||||
|
|
||||||
item = self.ui.matchList.currentItem()
|
item = self.ui.matchList.currentItem()
|
||||||
track_id = item.data(Qt.UserRole)
|
track_id = item.data(Qt.UserRole)
|
||||||
with Session() as session:
|
self.add_track(track_id)
|
||||||
self.add_track(session, track_id)
|
|
||||||
|
|
||||||
def add_selected_and_close(self):
|
def add_selected_and_close(self):
|
||||||
self.add_selected()
|
self.add_selected()
|
||||||
@ -669,29 +668,27 @@ class DbDialog(QDialog):
|
|||||||
|
|
||||||
def chars_typed(self, s):
|
def chars_typed(self, s):
|
||||||
if len(s) > 0:
|
if len(s) > 0:
|
||||||
with Session() as session:
|
matches = Tracks.search_titles(self.session, s)
|
||||||
matches = Tracks.search_titles(session, s)
|
self.ui.matchList.clear()
|
||||||
self.ui.matchList.clear()
|
if matches:
|
||||||
if matches:
|
for track in matches:
|
||||||
for track in matches:
|
t = QListWidgetItem()
|
||||||
t = QListWidgetItem()
|
t.setText(
|
||||||
t.setText(
|
f"{track.title} - {track.artist} "
|
||||||
f"{track.title} - {track.artist} "
|
f"[{helpers.ms_to_mmss(track.duration)}]"
|
||||||
f"[{helpers.ms_to_mmss(track.duration)}]"
|
)
|
||||||
)
|
t.setData(Qt.UserRole, track.id)
|
||||||
t.setData(Qt.UserRole, track.id)
|
self.ui.matchList.addItem(t)
|
||||||
self.ui.matchList.addItem(t)
|
|
||||||
|
|
||||||
def double_click(self, entry):
|
def double_click(self, entry):
|
||||||
track_id = entry.data(Qt.UserRole)
|
track_id = entry.data(Qt.UserRole)
|
||||||
with Session() as session:
|
self.add_track(track_id)
|
||||||
self.add_track(session, track_id)
|
|
||||||
# Select search text to make it easier for next search
|
# Select search text to make it easier for next search
|
||||||
self.select_searchtext()
|
self.select_searchtext()
|
||||||
|
|
||||||
def add_track(self, session, track_id):
|
def add_track(self, track_id):
|
||||||
track = Tracks.track_from_id(session, track_id)
|
track = Tracks.track_from_id(self.session, track_id)
|
||||||
self.parent().visible_playlist().add_to_playlist(session, track)
|
self.parent().visible_playlist().add_to_playlist(self.session, track)
|
||||||
# Select search text to make it easier for next search
|
# Select search text to make it easier for next search
|
||||||
self.select_searchtext()
|
self.select_searchtext()
|
||||||
|
|
||||||
@ -705,8 +702,7 @@ class DbDialog(QDialog):
|
|||||||
|
|
||||||
item = self.ui.matchList.currentItem()
|
item = self.ui.matchList.currentItem()
|
||||||
track_id = item.data(Qt.UserRole)
|
track_id = item.data(Qt.UserRole)
|
||||||
with Session() as session:
|
self.ui.dbPath.setText(Tracks.get_path(self.session, track_id))
|
||||||
self.ui.dbPath.setText(Tracks.get_path(session, track_id))
|
|
||||||
|
|
||||||
|
|
||||||
class SelectPlaylistDialog(QDialog):
|
class SelectPlaylistDialog(QDialog):
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user