cleanup
This commit is contained in:
parent
6241264147
commit
1d6d5da86e
2 changed files with 11 additions and 6 deletions
|
@ -3,7 +3,7 @@ import urllib
|
|||
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from tables import engine, TableNotification
|
||||
from tables import TableNotification
|
||||
import log
|
||||
|
||||
logger = log.get_logger(__name__)
|
||||
|
@ -46,10 +46,8 @@ class Notification:
|
|||
response = conn.getresponse()
|
||||
logger.debug(f"Pushover response code: {response.getcode()}")
|
||||
if response.getcode() == 200:
|
||||
n = TableNotification(type=type_of_error, message=f"{message}", medium='pushover', success=True)
|
||||
success = True
|
||||
else:
|
||||
logger.error(f"Pushover notification failed. Code {response.getcode()}: {response.read().decode()}")
|
||||
n = TableNotification(type=type_of_error, message=f"{message}", medium='pushover', success=False)
|
||||
with Session(engine) as session:
|
||||
session.add(n)
|
||||
session.commit()
|
||||
success = False
|
||||
TableNotification.insert(type_of_error, f"{message}", 'pushover', success)
|
||||
|
|
|
@ -22,6 +22,13 @@ class TableNotification(Base):
|
|||
|
||||
__mapper_args__ = {"eager_defaults": True}
|
||||
|
||||
@classmethod
|
||||
def insert(cls, type_of_error, message, medium, success):
|
||||
with Session(engine) as session:
|
||||
n = TableNotification(type=type_of_error, message=message, medium=medium, success=success)
|
||||
session.add(n)
|
||||
session.commit()
|
||||
|
||||
@classmethod
|
||||
def get_won_notifications_today(cls):
|
||||
with Session(engine) as session:
|
||||
|
|
Loading…
Reference in a new issue