Compare commits

..

2 Commits

Author SHA1 Message Date
Keith Edmunds
f35b8b93b1 Fix up cron database check 2023-10-16 20:39:53 +01:00
Keith Edmunds
64c3e3066b Filter virtualenv lines from stackprinter dump 2023-10-16 20:31:32 +01:00
3 changed files with 12 additions and 4 deletions

View File

@ -75,7 +75,11 @@ def log_uncaught_exceptions(_ex_cls, ex, tb):
print("\033[1;31;47m") print("\033[1;31;47m")
logging.critical("".join(traceback.format_tb(tb))) logging.critical("".join(traceback.format_tb(tb)))
print("\033[1;37;40m") print("\033[1;37;40m")
print(stackprinter.format(ex, style="darkbg")) print(
stackprinter.format(
ex, suppressed_paths=["/pypoetry/virtualenvs/"], style="darkbg"
)
)
if os.environ["MM_ENV"] == "PRODUCTION": if os.environ["MM_ENV"] == "PRODUCTION":
msg = stackprinter.format(ex) msg = stackprinter.format(ex)
send_mail( send_mail(

View File

@ -731,7 +731,7 @@ class Tracks(Base):
def get_all(cls, session) -> List["Tracks"]: def get_all(cls, session) -> List["Tracks"]:
"""Return a list of all tracks""" """Return a list of all tracks"""
return session.execute(select(cls)).scalars().all() return session.execute(select(cls)).scalars().unique().all()
@classmethod @classmethod
def get_by_path(cls, session: scoped_session, path: str) -> Optional["Tracks"]: def get_by_path(cls, session: scoped_session, path: str) -> Optional["Tracks"]:
@ -742,7 +742,7 @@ class Tracks(Base):
try: try:
return session.execute( return session.execute(
select(Tracks).where(Tracks.path == path) select(Tracks).where(Tracks.path == path)
).scalar_one() ).unique().scalar_one()
except NoResultFound: except NoResultFound:
return None return None

View File

@ -2180,5 +2180,9 @@ if __name__ == "__main__":
) )
else: else:
print("\033[1;31;47mUnhandled exception starts") print("\033[1;31;47mUnhandled exception starts")
print(stackprinter.format(exc, style="darkbg")) print(
stackprinter.format(
exc, suppressed_paths=["/pypoetry/virtualenvs/"], style="darkbg"
)
)
print("Unhandled exception ends\033[1;37;40m") print("Unhandled exception ends\033[1;37;40m")