def post_calendar(): # DEBUG purposes # TODO: be able to receive an icalendar using a post field conf = context.get_conf() if conf.get_boolean('ingest', 'active'): abort(503, "The Opencast service is enabled, so ingoring this command to avoid inconsisten behaviour") repo = context.get_repository() scheduler = context.get_scheduler() logger = context.get_logger() repo.delete_next_mediapackages() ical_data = repo.get_attach('calendar.ical').read() ical.handle_ical(ical_data, None, repo, scheduler, logger) return "OK"
def process_ical(self): """Creates, deletes or updates mediapackages according to scheduled events information given by opencast. """ self.logger.info('Process ical') try: ical_data1 = self.client.ical() except Exception as exc: self.logger.warning('Problems to connect to opencast server: {0}'.format(exc)) self.__set_opencast_down() return # No data but no error implies that the calendar has not been modified (ETAG) if ical_data1: self.ical_data = ical_data1 self.repo.save_attach('calendar.ical', self.ical_data) ical.count = 0 self.last_events = ical.handle_ical(self.ical_data, self.last_events, self.repo, self.scheduler, self.logger) self.dispatcher.emit('ical-processed')
def process_ical(self): """Creates, deletes or updates mediapackages according to scheduled events information given by opencast. """ self.logger.info('Process ical') try: ical_data1 = self.client.ical() except Exception as exc: self.logger.warning( 'Problems to connect to opencast server: {0}'.format(exc)) self.__set_opencast_down() return # No data but no error implies that the calendar has not been modified (ETAG) if ical_data1: self.ical_data = ical_data1 self.repo.save_attach('calendar.ical', self.ical_data) ical.count = 0 self.last_events = ical.handle_ical(self.ical_data, self.last_events, self.repo, self.scheduler, self.logger) self.dispatcher.emit('ical-processed')