Compare commits
No commits in common. "e4984573956aad3e67939dd91b5d60c38ff48a68" and "e1b9dacd3463dfbad8c562e92be5e52c4e0ed0e2" have entirely different histories.
e498457395
...
e1b9dacd34
@ -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.INFO
|
LOG_LEVEL_STDERR = logging.DEBUG
|
||||||
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,20 +59,8 @@ def log_uncaught_exceptions(ex_cls, ex, tb):
|
|||||||
sys.excepthook = log_uncaught_exceptions
|
sys.excepthook = log_uncaught_exceptions
|
||||||
|
|
||||||
|
|
||||||
def DEBUG(msg, force_stderr=False):
|
def DEBUG(msg):
|
||||||
"""
|
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,9 +402,8 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def search_database(self):
|
def search_database(self):
|
||||||
with Session() as session:
|
dlg = DbDialog(self)
|
||||||
dlg = DbDialog(self, session)
|
dlg.exec()
|
||||||
dlg.exec()
|
|
||||||
|
|
||||||
def open_playlist(self):
|
def open_playlist(self):
|
||||||
with Session() as session:
|
with Session() as session:
|
||||||
@ -627,9 +626,8 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
|
|
||||||
|
|
||||||
class DbDialog(QDialog):
|
class DbDialog(QDialog):
|
||||||
def __init__(self, parent, session):
|
def __init__(self, parent=None):
|
||||||
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)
|
||||||
@ -639,20 +637,22 @@ 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)
|
||||||
|
|
||||||
record = Settings.get_int(self.session, "dbdialog_width")
|
with Session() as session:
|
||||||
width = record.f_int or 800
|
record = Settings.get_int(session, "dbdialog_width")
|
||||||
record = Settings.get_int(self.session, "dbdialog_height")
|
width = record.f_int or 800
|
||||||
height = record.f_int or 600
|
record = Settings.get_int(session, "dbdialog_height")
|
||||||
self.resize(width, height)
|
height = record.f_int or 600
|
||||||
|
self.resize(width, height)
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
record = Settings.get_int(self.session, "dbdialog_height")
|
with Session() as session:
|
||||||
if record.f_int != self.height():
|
record = Settings.get_int(session, "dbdialog_height")
|
||||||
record.update(self.session, {'f_int': self.height()})
|
if record.f_int != self.height():
|
||||||
|
record.update(session, {'f_int': self.height()})
|
||||||
|
|
||||||
record = Settings.get_int(self.session, "dbdialog_width")
|
record = Settings.get_int(session, "dbdialog_width")
|
||||||
if record.f_int != self.width():
|
if record.f_int != self.width():
|
||||||
record.update(self.session, {'f_int': self.width()})
|
record.update(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,7 +660,8 @@ 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)
|
||||||
self.add_track(track_id)
|
with Session() as session:
|
||||||
|
self.add_track(session, track_id)
|
||||||
|
|
||||||
def add_selected_and_close(self):
|
def add_selected_and_close(self):
|
||||||
self.add_selected()
|
self.add_selected()
|
||||||
@ -668,27 +669,29 @@ class DbDialog(QDialog):
|
|||||||
|
|
||||||
def chars_typed(self, s):
|
def chars_typed(self, s):
|
||||||
if len(s) > 0:
|
if len(s) > 0:
|
||||||
matches = Tracks.search_titles(self.session, s)
|
with Session() as session:
|
||||||
self.ui.matchList.clear()
|
matches = Tracks.search_titles(session, s)
|
||||||
if matches:
|
self.ui.matchList.clear()
|
||||||
for track in matches:
|
if matches:
|
||||||
t = QListWidgetItem()
|
for track in matches:
|
||||||
t.setText(
|
t = QListWidgetItem()
|
||||||
f"{track.title} - {track.artist} "
|
t.setText(
|
||||||
f"[{helpers.ms_to_mmss(track.duration)}]"
|
f"{track.title} - {track.artist} "
|
||||||
)
|
f"[{helpers.ms_to_mmss(track.duration)}]"
|
||||||
t.setData(Qt.UserRole, track.id)
|
)
|
||||||
self.ui.matchList.addItem(t)
|
t.setData(Qt.UserRole, track.id)
|
||||||
|
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)
|
||||||
self.add_track(track_id)
|
with Session() as session:
|
||||||
|
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, track_id):
|
def add_track(self, session, track_id):
|
||||||
track = Tracks.track_from_id(self.session, track_id)
|
track = Tracks.track_from_id(session, track_id)
|
||||||
self.parent().visible_playlist().add_to_playlist(self.session, track)
|
self.parent().visible_playlist().add_to_playlist(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()
|
||||||
|
|
||||||
@ -702,7 +705,8 @@ 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)
|
||||||
self.ui.dbPath.setText(Tracks.get_path(self.session, track_id))
|
with Session() as session:
|
||||||
|
self.ui.dbPath.setText(Tracks.get_path(session, track_id))
|
||||||
|
|
||||||
|
|
||||||
class SelectPlaylistDialog(QDialog):
|
class SelectPlaylistDialog(QDialog):
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user