def _get_meetings(self, committee_id, from_date, to_date): try: meetings = DataserviceCommitteeMeeting.get(committee_id, from_date, to_date) return meetings except Exception as e: err_msg = ERR_MSG.format(committee_id) err_msg_report = ERR_MSG_REPORT.format(committee_id, str(e)) DataserviceCommitteeMeeting.error_report(err_msg, err_msg_report) self._log_error(err_msg) return []
def _committee_meeting_get(self, committee_id, fromdate, proxies): return [ CommitteeMeeting({ "data": dict(COMMITTEE_MEETING_SOURCE_DATA, committee_agenda_id=5) }), CommitteeMeeting({ "data": dict(COMMITTEE_MEETING_SOURCE_DATA, committee_agenda_id=6) }) ]
def _get_meetings(self, committee_id, from_date, to_date): try: meetings = DataserviceCommitteeMeeting.get(committee_id, from_date, to_date) return meetings except Exception as e: err_msg = ERR_MSG.format(committee_id) err_msg_report = ERR_MSG_REPORT.format(committee_id, str(e)) DataserviceCommitteeMeeting.error_report(err_msg, err_msg_report) self._log_error(err_msg) send_chat_notification(__name__, "Received unexpected exception from DataServiceCommitteeMeeting.get()", {'exception': traceback.format_exc(), 'committee_id': committee_id, 'from_date': from_date, 'to_date': to_date}) return []
def _get_meetings(self, committee_id, from_date, to_date): try: meetings = DataserviceCommitteeMeeting.get(committee_id, from_date, to_date) return meetings except KnessetDataServiceRequestException as e: err_msg = ERR_MSG.format(committee_id) err_msg_report = ERR_MSG_REPORT.format(committee_id, str(e)) DataserviceCommitteeMeeting.error_report(err_msg, err_msg_report) self._log_error(err_msg) send_chat_exception_notification(__name__, "Failed to fetch from committee meetings knesset dataservice", {'committee_id': committee_id, 'from_date': from_date, 'to_date': to_date, 'url': e.url}, e) return []
def _get_meetings(self, committee_id, from_date, to_date): try: meetings = DataserviceCommitteeMeeting.get(committee_id, from_date, to_date) return meetings except KnessetDataServiceRequestException as e: err_msg = ERR_MSG.format(committee_id) err_msg_report = ERR_MSG_REPORT.format(committee_id, str(e)) DataserviceCommitteeMeeting.error_report(err_msg, err_msg_report) self._log_error(err_msg) send_chat_exception_notification( __name__, "Failed to fetch from committee meetings knesset dataservice", { 'committee_id': committee_id, 'from_date': from_date, 'to_date': to_date, 'url': e.url }, e) return []
def __init__(self, name=None, parent_datapackage_path=None, protocols_resource=None): self._protocols_resource = protocols_resource json_table_schema = CommitteeMeeting.get_json_table_schema() json_table_schema["fields"].append({ "type": "string", "name": "scraper_errors" }) super(CommitteeMeetingsResource, self).__init__(name, parent_datapackage_path, json_table_schema)
def update_from_dataservice(self, dataservice_object=None): from committees.management.commands.scrape_committee_meetings import Command as ScrapeCommitteeMeetingCommand from knesset_data.dataservice.committees import CommitteeMeeting as DataserviceCommitteeMeeting if dataservice_object is None: ds_meetings = [ ds_meeting for ds_meeting in DataserviceCommitteeMeeting.get(self.committee.knesset_id, self.date - timedelta(days=1), self.date + timedelta(days=1)) if str(ds_meeting.id) == str(self.knesset_id) ] if len(ds_meetings) != 1: raise Exception('could not found corresponding dataservice meeting') dataservice_object = ds_meetings[0] meeting_transformed = ScrapeCommitteeMeetingCommand().get_committee_meeting_fields_from_dataservice(dataservice_object) [setattr(self, k, v) for k,v in meeting_transformed.iteritems()] self.save()
def _get_meetings(self, committee_id, datetime_from, datetime_to): # the knesset dataservice allows to get meetings only using a function with these parameters # see https://github.com/hasadna/knesset-data/issues/25 return CommitteeMeeting.get(committee_id, datetime_from, datetime_to)
def _committee_meeting_get(self, committee_id, fromdate, proxies): return CommitteeMeeting.get(committee_id, fromdate, proxies=proxies)