Commit 8d04a182 authored by David Trattnig's avatar David Trattnig
Browse files

Fixes to make Fetcher compatible with new logic.

parent 0d1f509c
......@@ -29,7 +29,7 @@ class CalendarFetcher:
# fetch upcoming schedules from STEERING
try:
self.logger.debug("Fetching schedules from STEERING")
self.__fetch_schedule_data__()
self.fetched_schedule_data = self.__fetch_schedule_data__()
except urllib.error.HTTPError as e:
self.logger.critical("Cannot fetch from " + self.url["calendar"] + "! Reason: " + str(e))
self.fetched_schedule_data = None
......@@ -89,6 +89,7 @@ class CalendarFetcher:
# ------------------------------------------------------------------------------------------ #
def __fetch_schedule_data__(self):
servicetype = "calendar"
schedule = None
# fetch data from steering
......@@ -118,7 +119,7 @@ class CalendarFetcher:
self.logger.critical("no JSON data checks. I believe what i get here")
#self.fetched_schedule_data = self.remove_unnecessary_data(schedule)
return self.remove_unnecessary_data(schedule_from_pv)
return self.remove_unnecessary_data(schedule)
# ------------------------------------------------------------------------------------------ #
def __fetch_schedule_playlists__(self):
......@@ -219,12 +220,12 @@ class CalendarFetcher:
# Send request to the API and read the data
try:
if type not in self.data:
if type not in self.url_parameter:
if self.url[type] == "":
return False
request = urllib.request.Request(url)
else:
request = urllib.request.Request(url, self.data[type])
request = urllib.request.Request(url, self.url_parameter[type])
response = urllib.request.urlopen(request)
html_response = response.read()
......@@ -252,7 +253,7 @@ class CalendarFetcher:
schedule = self.remove_data_in_the_past(schedule)
count_after = len(schedule)
self.logger.info("Removed %d unnecessary schedules from response." % (count_before - count_after))
self.logger.info("Removed %d unnecessary schedules from response. Entries left: %d" % ((count_before - count_after), count_after))
return schedule
# ------------------------------------------------------------------------------------------ #
def remove_data_more_than_24h_in_the_future(self, schedule_from_pv):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment