diff --git a/src/aura_engine/scheduling/timetable.py b/src/aura_engine/scheduling/timetable.py index a4957818dd0167f590f55096e51501447c9c1314..c4ac583bc712b71eb61e8e6acd5d73dc8b48911c 100644 --- a/src/aura_engine/scheduling/timetable.py +++ b/src/aura_engine/scheduling/timetable.py @@ -56,6 +56,7 @@ class TimetableService: last_successful_fetch: datetime = None cache_location: str = None timetable_file: str = None + restorable: bool def __init__(self, cache_location: str): """ @@ -66,7 +67,7 @@ class TimetableService: """ self.config = AuraConfig.instance.config self.logger = logging.getLogger("engine") - jsonpickle.set_encoder_options("json", sort_keys=True, indent=4) + jsonpickle.set_encoder_options("json", sort_keys=False, indent=2) if cache_location[-1] != "/": cache_location += "/" @@ -74,6 +75,7 @@ class TimetableService: os.makedirs(cache_location, exist_ok=True) self.cache_location = cache_location self.timetable_file = self.cache_location + "/timetable.json" + self.restorable = False @synchronized def refresh(self): @@ -125,7 +127,7 @@ class TimetableService: """ try: with open(self.timetable_file, "w") as file: - file.write(jsonpickle.encode(self.timetable)) + file.write(jsonpickle.encode(self.timetable, unpicklable=self.restorable)) self.logger.info(SU.green("timetable.json stored")) except Exception as e: self.logger.error(SU.red(f"Error while storing {self.timetable_file}"), e)