def load_from_redis(redis_data): arrival = ot_utils.unix_time_to_localtime(int(redis_data[1])) data = json.loads(redis_data[0]) if data[0] == str(None): stop_id = None else: stop_id = int(data[0]) departure = ot_utils.isoformat_to_localtime(data[1]) if data[1] else None return DetectedStopTime(stop_id, arrival, departure)
def get_current(self): data = load_by_key(get_train_tracker_data_key(self.tracker_id)) if data: (state, stop_id, timestamp) = data timestamp = ot_utils.isoformat_to_localtime(timestamp) if stop_id == str(None): stop_id = None else: stop_id = int(stop_id) return state, stop_id, timestamp else: return DetectorState.states.INITIAL, None, None