Compare commits

..

No commits in common. "be4f19757cf2cb6374aa9aeda688683df2214624" and "6a2bcfff195d13e20bad0ac1b0bd0e7aea80e4c1" have entirely different histories.

4 changed files with 25 additions and 35 deletions

View File

@ -55,14 +55,25 @@ syslog.addFilter(local_filter)
stderr.addFilter(local_filter)
stderr.addFilter(debug_filter)
stderr_fmt = logging.Formatter('[%(asctime)s] %(leveltag)s: %(message)s',
datefmt='%H:%M:%S')
syslog_fmt = logging.Formatter(
'[%(name)s] %(module)s.%(funcName)s - %(leveltag)s: %(message)s'
)
stderr.setFormatter(stderr_fmt)
syslog.setFormatter(syslog_fmt)
class VerboseExceptionFormatter(logging.Formatter):
def formatException(self, exc_info):
msg = stackprinter.format(exc_info)
lines = msg.split('\n')
lines_indented = ["" + line + "\n" for line in lines]
msg_indented = "".join(lines_indented)
return msg_indented
stderr_fmt = '[%(asctime)s] %(leveltag)s: %(message)s'
stderr_formatter = VerboseExceptionFormatter(stderr_fmt, datefmt='%H:%M:%S')
stderr.setFormatter(stderr_formatter)
syslog_fmt = '[%(name)s] %(module)s.%(funcName)s - %(leveltag)s: %(message)s'
syslog_formatter = VerboseExceptionFormatter(syslog_fmt)
syslog.setFormatter(syslog_formatter)
# add the handlers to the log
log.addHandler(stderr)
log.addHandler(syslog)
@ -74,7 +85,7 @@ def log_uncaught_exceptions(ex_cls, ex, tb):
print("\033[1;31;47m")
logging.critical(''.join(traceback.format_tb(tb)))
print("\033[1;37;40m")
print(stackprinter.format(ex, style="darkbg2", add_summary=True))
stackprinter.show(style="lightbg")
msg = stackprinter.format(ex)
send_mail(Config.ERRORS_TO, Config.ERRORS_FROM,
"Exception from musicmuster", msg)

View File

@ -593,27 +593,6 @@ class PlaylistRows(Base):
.values(row_number=PlaylistRows.row_number + move_by)
)
@staticmethod
def indexed_by_row(session: Session, playlist_id: int) -> dict:
"""
Return a dictionary of playlist_rows indexed by row number for
the passed playlist_id.
"""
plrs = session.execute(
select(PlaylistRows)
.where(
PlaylistRows.playlist_id == playlist_id,
)
.order_by(PlaylistRows.row_number)
).scalars().all()
result = {}
for plr in plrs:
result[plr.row_number] = plr
return result
class Settings(Base):
"""Manage settings"""

View File

@ -1663,6 +1663,6 @@ if __name__ == "__main__":
send_mail(Config.ERRORS_TO, Config.ERRORS_FROM,
"Exception from musicmuster", msg)
print("\033[1;31;47mUnhandled exception starts")
stackprinter.show(style="darkbg")
print("Unhandled exception ends\033[1;37;40m")
print("\033[1;31;47mUnhandled exception starts\033[1;37;40m")
stackprinter.show(style="darkbg2")
print("\033[1;31;47mUnhandled exception ends\033[1;37;40m")

View File

@ -827,11 +827,11 @@ class PlaylistTab(QTableWidget):
the row number is correct (in case tracks have been reordered).
"""
plr_dict = PlaylistRows.indexed_by_row(session, self.playlist_id)
for row in range(self.rowCount()):
plr = session.get(PlaylistRows, self._get_playlistrow_id(row))
# Set the row number and playlist id (even if correct)
plr_dict[row].row_number = row
plr_dict[row].playlist_id = self.playlist_id
plr.row_number = row
plr.playlist_id = self.playlist_id
# Any rows in the database with a row_number higher that the
# current value of 'row' should not be there. Commit session