Wrap _addToDb functionality in a try:except block
This commit is contained in:
parent
e17d03b376
commit
89574d4bbd
@ -141,6 +141,7 @@ def insertSchedule(sch_record):
|
|||||||
return document
|
return document
|
||||||
|
|
||||||
def _insertToDb(data :list, type :str):
|
def _insertToDb(data :list, type :str):
|
||||||
|
try:
|
||||||
if type == "full":
|
if type == "full":
|
||||||
mongo.dropCollection("timetable")
|
mongo.dropCollection("timetable")
|
||||||
mongo.putTimetable(data)
|
mongo.putTimetable(data)
|
||||||
@ -151,8 +152,12 @@ def _insertToDb(data :list, type :str):
|
|||||||
singleList = [item]
|
singleList = [item]
|
||||||
mongo.putTimetable(singleList)
|
mongo.putTimetable(singleList)
|
||||||
elif item['transactionType'] == "Delete":
|
elif item['transactionType'] == "Delete":
|
||||||
mongo.deleteTimetableData({'trainUid': item['trainUid']})
|
mongo.deleteTimetableData({'trainUid': item['trainUid']}) ## Also need to consider the STP indicator and end date here else I am deleting LTP services when an STP is meant to be deleted.
|
||||||
return True #If Successful else False
|
return True #If Successfuls
|
||||||
|
except Exception as e:
|
||||||
|
log.out("timetable._insertToDb: Error inserting timetable data", "ERR")
|
||||||
|
log.out(f"timteable._insertToDb: {e}")
|
||||||
|
return False # If error inserting timetable
|
||||||
|
|
||||||
def _helpParseStops(schedule_segment):
|
def _helpParseStops(schedule_segment):
|
||||||
stops = []
|
stops = []
|
||||||
|
Reference in New Issue
Block a user