Tidying
This commit is contained in:
parent
9232c740a0
commit
1588f3c86c
@ -30,9 +30,11 @@ smtpFrom = os.getenv("OWL_EML_FROM")
|
||||
|
||||
log.out("mailer.py: Mailer module loaded", "DBUG")
|
||||
|
||||
def submitLogs():
|
||||
def submitLogs(retry :bool = False):
|
||||
if retry:
|
||||
log.out("mailer.submitLogs: Retrying fetch and send")
|
||||
text :str = fetchLogs()
|
||||
sendMail(text)
|
||||
sendMail(text, retry)
|
||||
|
||||
def fetchLogs():
|
||||
with open("dbman-log", "r") as tmpfile:
|
||||
@ -46,7 +48,7 @@ def deleteLogs():
|
||||
print("No logfile to tidy")
|
||||
|
||||
|
||||
def sendMail(msg_body :str):
|
||||
def sendMail(msg_body :str, retry):
|
||||
message = MIMEMultipart()
|
||||
message['From'] = smtpFrom
|
||||
message['To'] = "server-notification-receipt@fjla.uk"
|
||||
@ -71,6 +73,12 @@ def sendMail(msg_body :str):
|
||||
server.login(smtpUser, smtpPass)
|
||||
server.sendmail(smtpFrom, "server-notification-receipt@fjla.uk", text)
|
||||
except Exception as e:
|
||||
print("mailer.sendMail: Error sending message", e)
|
||||
log.out(f"mailer.sendMail: Error sending message: {e}", "EROR")
|
||||
if not retry:
|
||||
os.remove("cif_data")
|
||||
log.out("mailer.sendMail: Removing CIF Data to shrink email size")
|
||||
submitLogs(retry = True)
|
||||
else:
|
||||
print("Error retrying to mail logs, giving up")
|
||||
finally:
|
||||
deleteLogs()
|
@ -14,7 +14,7 @@
|
||||
# program. If not, see
|
||||
# https://git.fjla.uk/OwlBoard/db-manager/src/branch/main/LICENSE
|
||||
|
||||
version = "2023.6.4"
|
||||
version = "2023.6.5"
|
||||
print(f"main.py: Initialising db-manager v{version}")
|
||||
|
||||
#Third Party Imports
|
||||
|
@ -37,7 +37,6 @@ def load(): # Programatically add a `toc` field to each entry.
|
||||
with open(file_location, "r") as data:
|
||||
try:
|
||||
pis = yaml.safe_load(data)
|
||||
#print(pis)
|
||||
return pis["pis"]
|
||||
except yaml.YAMLError as exc:
|
||||
print(exc)
|
||||
@ -53,7 +52,7 @@ def parse(codeList):
|
||||
code = i['code']
|
||||
for ii in codeList:
|
||||
if stops == ii['stops'] and code != ii['code']:
|
||||
print(f"Identical stopping pattern found: {ii['code']}")
|
||||
log.out(f"Identical stopping pattern found: {ii['code']}","DBUG")
|
||||
codeList.remove(ii) # Instead of removing, I should add a property (duplicate: true), then I can filter this out on the backend when searching by start and end stations and just use query one for other queries, this means that when searching by code, a perfectly valid code won't show 0 results.
|
||||
tiplocs = []
|
||||
for iii in stops:
|
||||
@ -75,5 +74,5 @@ def getTiploc(crs :str):
|
||||
if 'TIPLOC' in res:
|
||||
return res['TIPLOC']
|
||||
except Exception as e:
|
||||
log.out("pis.getTiploc: Error finding tiploc:", query)
|
||||
print("ERROR", e)
|
||||
log.out(f"pis.getTiploc: Error finding tiploc: {query}", "EROR")
|
||||
log.out(f"ERROR: {e}", "EROR")
|
Reference in New Issue
Block a user